Let your agent pay anyone: the non-custodial x402 payments toolkit
An autonomous agent that can pay is far more useful than one that can't - but
you don't want a middleman holding your money. Agent402's payments tools are
non-custodial: they help an agent move its own USDC with its own key.
These tools never hold, sign, or send funds - they decode quotes, read public
chain state, and build the authorization you sign. (Two paths elsewhere on
the service are not non-custodial and we say so: a prepaid credits balance is
money held until it is spent, and a card report purchase is held by the payment
processor until the report is delivered.) Everything below works on
Base, Polygon, Arbitrum, Optimism, Ethereum, and Robinhood Chain (network param, default
base), and needs no API key.
1. What does this endpoint cost? - /api/x402-quote
Point it at any paid URL and get the decoded HTTP 402 terms:
curl "https://agent402.tools/api/x402-quote?url=https://agent402.tools/api/uuid&method=GET"
# { "url": "https://agent402.tools/api/uuid", "status": 402, "paymentRequired": true, "x402Version": 2,
# "accepts": [{ "scheme": "exact", "network": "eip155:8453", "amount": "1000",
# "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "payTo": "0x…",
# "maxTimeoutSeconds": 300, "extra": { "name": "USD Coin", "version": "2" } }, … ] }
2. Who am I paying? - /api/ens-resolve
Turn a human-readable name into a payable address:
curl "https://agent402.tools/api/ens-resolve?name=vitalik.eth"
# { "name":"vitalik.eth", "address":"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", "found":true }
3. Can I afford it? - /api/usdc-balance + /api/gas-estimate
curl "https://agent402.tools/api/usdc-balance?address=0xYOURWALLET&network=base"
# { "usdc":"12.5", "raw":"12500000", "network":"base" }
curl "https://agent402.tools/api/gas-estimate?network=base"
# { "gasPriceGwei":"0.0051", "network":"base" }
4. Build the authorization to sign - /api/transfer-authorization
This returns the exact EIP-3009 transferWithAuthorization typed data for a
gasless USDC transfer. Agent402 builds it; your agent signs it locally:
curl -X POST https://agent402.tools/api/transfer-authorization \
-H "Content-Type: application/json" \
-d '{"from":"0xYOURWALLET","to":"0xRECIPIENT","amount":0.01,"network":"base"}'
# { "typedData": { "domain":{...}, "primaryType":"TransferWithAuthorization", "message":{...} }, ... }
Sign it with your own key - Agent402 never sees it:
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.AGENT_KEY);
const { typedData } = await (await fetch("https://agent402.tools/api/transfer-authorization", {
method: "POST", headers: { "Content-Type": "application/json" },
body: JSON.stringify({ from: account.address, to: recipient, amount: 0.01 }),
})).json();
const signature = await account.signTypedData(typedData); // submit to the facilitator / payTo's x402 flow
5. Did it settle? - /api/x402-verify
After a payment lands, confirm it on-chain - and optionally that it paid the right address at least a minimum amount:
curl "https://agent402.tools/api/x402-verify?hash=0xTXHASH&network=base&to=0xRECIPIENT&min=0.001"
# { "settled":true, "status":"success", "transfers":[{"from":"0x…","to":"0x…","usdc":"0.001"}], "matched":true }
Why non-custodial matters
These tools never touch your money: you keep your key, you sign, you send. That's the right architecture for agent payments, and it's the one Agent402 ships. The whole kit is open source and priced per call in USDC (or proof-of-work on the free tools).
Packages for this guide
- Strands Agents (
agent402-strands)