┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐
│ CALL │──▶│ 402 │──▶│ PAY │──▶│ TX │──▶│ OK │
└──────┘ └──────┘ └──────┘ └──────┘ └──────┘
01 02 03 04 05
~1.4s round-trip · 0.0001 USDC + gasQuickstart
Pay a toll, run a call. Five steps, zero accounts. Examples use the forthcoming TOLL gateway URL — drop in your own x402-compatible endpoint today if you want to test the flow.
01 · Point an agent at the gateway
Any HTTP client works. The example uses pseudocode close to what an MCP-style agent loop looks like.
const TOLL_GATEWAY = "https://toll.computer/v1";
const agent = new Agent({
wallet: yourBaseWallet, // any EOA or smart wallet on Base
toolPaymentLimit: 0.05, // hard cap per call, USDC
});02 · Make a call
The agent issues a normal HTTP POST to a registered tool. No API key, no session, no signup.
const res = await fetch(
`${TOLL_GATEWAY}/tools/crypto.price`,
{
method: "POST",
body: JSON.stringify({ ticker: "ETH" }),
}
);03 · Handle the 402
If the tool requires payment, the gateway returns HTTP 402 Payment Required with payment metadata in headers.
HTTP/1.1 402 Payment Required
X-Payment-Required: 0.0001 USDC
X-Payment-Address: 0x7a3...d22f
X-Payment-Chain: base
X-Payment-Token: USDC
X-Payment-Nonce: 01HXT7...K904 · Settle on Base
The agent's wallet signs a USDC transfer for the requested amount to the requested address on Base. Sub-second confirmation, fee under one cent.
const tx = await agent.wallet.transfer({
token: "USDC",
chain: "base",
to: paymentHeader.address,
amount: paymentHeader.amount,
nonce: paymentHeader.nonce,
});
await tx.wait(); // ~600ms on Base05 · Retry with the receipt
Re-send the original request with X-Payment-Receipt: <tx hash>. The gateway verifies the on-chain payment and returns the tool's response.
const final = await fetch(
`${TOLL_GATEWAY}/tools/crypto.price`,
{
method: "POST",
headers: { "X-Payment-Receipt": tx.hash },
body: JSON.stringify({ ticker: "ETH" }),
}
);
// → 200 OK
// { "ticker": "ETH", "price": 3847.21, "ts": 1763680842 }The whole loop
agent ──▶ tool (POST)
agent ◀── 402 (price, address, nonce)
agent ──▶ Base (sign USDC tx)
Base ◀── confirmed (block, hash)
agent ──▶ tool (retry + receipt)
agent ◀── 200 (response)
total: ~1.4s · cost: 0.0001 USDC + ~0.0003 USDC gasNext steps
- Read the x402 protocol spec we implement.
- See how $TOLL is used by tool operators and curators.
- Want to list a tool? Join the early-operator channel (see footer).