r/LangChain • • 10d ago

Projects [Open Tool] Built an HTTP 402 Pay-Per-Call Crypto Risk, DEX Slippage & Perp Arbitrage M2M Oracle for LangChain / CrewAI Agents (3 Free Calls/Day, 0.25 USDC On-Chain Gate)

When building autonomous crypto trading or DeFi research agents in LangChain / CrewAI / Python, you usually have to stitch together 3 separate APIs before your bot can safely execute a swap or delta-neutral trade:

  1. Bytecode security / honeypot check (GoPlus)
  2. Cross-pool DEX liquidity & AMM slippage impact in bps (DexScreener)
  3. CEX perpetual funding rate arbitrage spreads net of taker fees (Binance Futures + Bybit Linear)

I built NeonOracle x402 v2.0 — a zero-KYC Machine-to-Machine (M2M) micro-API using the HTTP 402 Payment Required pattern so autonomous agents can query all three in a single atomic JSON call and pay per call directly on-chain (Base or Solana USDC) without Stripe or human OAuth.

  • Interactive M2M Terminal Sandbox: https://meer9374-a11y.github.io/neonops-web3-suite/m2m.html
  • OpenAPI 3.1.0 Discovery JSON: https://meer9374-a11y.github.io/neonops-web3-suite/openapi.json

Ready-to-Use Python / LangChain @tool

from langchain_core.tools import tool
import requests, os

@tool
def neon_m2m_crypto_risk_and_arb_oracle_v2(
    token_address: str,
    chain: str = "base",
    symbol: str = "ETH",
    notional_usd: float = 25000.0
) -> dict:
    """
    NeonOracle x402 v2.0 M2M Tool for Autonomous Trading Agents.
    Returns composite contract risk score (0-100), GoPlus honeypot/tax audit,
    DexScreener pool depth + AMM price impact in bps for `notional_usd`,
    and fee-adjusted Binance/Bybit perpetual funding arbitrage APR.
    """
    api_key = os.getenv("NEON_24H_API_KEY", "")
    tx_hash = os.getenv("NEON_PAYMENT_TX_HASH", "")
    pay_chain = os.getenv("NEON_PAYMENT_CHAIN", "base")
    base_url = os.getenv("NEON_ORACLE_BASE_URL", "http://localhost:3402")

    endpoint = f"{base_url}/api/v1/intel" if (api_key or tx_hash) else f"{base_url}/api/v1/preview"
    headers = {"X-Payment-Chain": pay_chain}
    if api_key:
        headers["X-API-Key"] = api_key
    elif tx_hash:
        headers["X-Payment-Tx-Hash"] = tx_hash

    r = requests.get(
        endpoint,
        params={"token": token_address, "chain": chain, "symbol": symbol, "notional_usd": notional_usd},
        headers=headers,
        timeout=10
    )
    return r.json()

How the HTTP 402 M2M Gate Works

  • Free Preview (/api/v1/preview): 3 calls/day per IP, zero headers required.
  • Pay-Per-Call (/api/v1/intel): Calling without X-Payment-Tx-Hash returns HTTP 402 Payment Required with Base (0x6137ED1A93c8CFF1a6C3112A14bE04883f58E5F7) and Solana (5YtLdjEVDQxP2Kh4xVSccxhMKhx8SuZd6wYaGXYcRwFp) USDC payment metadata (0.25 USDC single call with anti-replay lock, or 19.00 USDC for an auto-issued 24-hour reusable X-API-Key: nk_live_24h_...).
2 Upvotes

0 comments sorted by