Agents · x402

Pay the toll. Get the route.

One endpoint, paid per call in USDC over HTTP 402. No sign-up, no API key, no account to leak. $0.002 buys the best split across every funded Uniswap v4 pool and the transaction that executes it.

Try it as an agent

Asks for a route for 0.01 ETH → USDG and pays for it from your wallet, exactly as a bot would.

The endpoint

GET /api/v1/route?in=<token>&out=<token>&amount=<raw>&recipient=<address>&slippage=<bps>
ParamMeaning
in, outToken addresses on the chain. ETH is 0x0000000000000000000000000000000000000000.
amountExact input, in the input token's smallest unit (wei for ETH).
recipientWho receives the output. Pass a fresh address for a shadow delivery.
slippageBasis points each leg may land under its quote before the whole swap reverts. Default 50.

The exchange

  1. Call without payment. The answer is 402 with accepts[0]: scheme exact, network base, asset USDC, maxAmountRequired 2000 (0.002 USDC), payTo.
  2. Sign an EIP-3009 TransferWithAuthorization for that amount against the USDC domain (name and version are in extra). Signing costs no gas and moves nothing.
  3. Call again with the base64 JSON payment in X-PAYMENT. Any x402 client library does steps 1 to 3 for you.
  4. The facilitator verifies the signature before the route is computed and settles it after. The answer carries the route and X-PAYMENT-RESPONSE with the settlement transaction. If no route exists, nothing is settled and the authorization expires.

The answer

{ "chainId": 4663, "tokenIn": { "address", "symbol", "decimals" }, "tokenOut": { "address", "symbol", "decimals" }, "quote": { "out": "what the split returns", "single": "what the best single route returns", "legs": [ { "share", "amountIn", "out", "hops": [ { "pool": { "c0", "c1", "fee", "ts", "hooks" }, "zeroForOne" } ] } ], "considered", "pools", "block" }, "tx": { "to": "Universal Router", "data": "0x…", "value": "wei" } }

Before you sign

  • Simulate tx from your own address first. Prices move between the quote and the block; each leg has its own minimum, so a bad fill reverts instead of landing short.
  • ERC-20 inputs need the usual Permit2 allowances: the token approved to Permit2, and Permit2 approving the Universal Router.
  • Quotes come from running the swaps through each pool and its hook inside one read-only call, so hooks that charge, refuse or rebate are priced as they really behave.