live · base mainnet openapi contract
x402 · gasless swap

Your agent swaps with zero ETH.
One signature. Gas is on us.

A pay-per-call swap API for onchain agents. The caller signs a single x402 payment in USDC — no ETH, no approvals, no key sharing. fold sponsors the gas and routes the swap; the output token lands directly in the caller's wallet.

endpoint
POST https://x402.fold.computer/swap
How it works
01

Agent calls /swap

POST with tokenOut, amountUsdc, recipient. The first response is HTTP 402 with payment terms.

02

Agent signs the x402 payment

A single EIP-3009 signature in USDC. No gas, no on-chain approval — the private key never leaves the agent.

03

fold settles, then swaps

The payment settles first, then fold runs the swap through an aggregator and sends the output token straight to recipient. Gas fully sponsored.

Call it
# 1) hit the endpoint — receive 402 payment terms
curl -X POST https://x402.fold.computer/swap \
  -H "Content-Type: application/json" \
  -d '{"tokenOut":"0x4200...0006","amountUsdc":1.0,"recipient":"0xYOURADDR"}'

# 2) re-send with the signed x402 PAYMENT-SIGNATURE header
# any x402 client does this for you — see the typescript tab
import { x402Client, wrapFetchWithPayment } from "@x402/fetch"
import { ExactEvmScheme } from "@x402/evm/exact/client"

const client = new x402Client()
client.register("eip155:*", new ExactEvmScheme(signer))
const pay = wrapFetchWithPayment(fetch, client)

const res = await pay("https://x402.fold.computer/swap", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    tokenOut: "0x4200000000000000000000000000000000000006", // WETH
    amountUsdc: 1.0,                  // swap amount + 0.01 fee
    recipient: signer.address,        // where the token lands
  }),
})
// agent holds zero ETH — token arrives in recipient's wallet
Request body
fieldtypedescription
tokenOut requiredaddressBase token to receive (any aggregator-liquid token)
amountUsdc requirednumberTotal USDC to pay — swap amount plus a 0.01 fee
recipient requiredaddressWhere the output token is sent
Exact, single-use payment (EIP-3009): the caller authorizes one fixed amount to one address, once. No standing allowance, no surprise pulls.
Proven on mainnet
0 ETH
held by caller
1 sig
to swap
Base
eip155:8453