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>
| Param | Meaning |
|---|---|
in, out | Token addresses on the chain. ETH is 0x0000000000000000000000000000000000000000. |
amount | Exact input, in the input token's smallest unit (wei for ETH). |
recipient | Who receives the output. Pass a fresh address for a shadow delivery. |
slippage | Basis points each leg may land under its quote before the whole swap reverts. Default 50. |
The exchange
- Call without payment. The answer is
402withaccepts[0]: schemeexact, networkbase, asset USDC,maxAmountRequired2000 (0.002 USDC),payTo. - Sign an EIP-3009
TransferWithAuthorizationfor that amount against the USDC domain (nameandversionare inextra). Signing costs no gas and moves nothing. - Call again with the base64 JSON payment in
X-PAYMENT. Any x402 client library does steps 1 to 3 for you. - The facilitator verifies the signature before the route is computed and settles it after. The answer carries the route and
X-PAYMENT-RESPONSEwith 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
txfrom 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.
Protocol V4