Base URL
All examples use the dedicated x402 host:Prerequisites
- An EVM wallet
- Funds on one of the supported rails: USDC deposited via Circle Gateway (settles on Base), or USDC / USDT / USD1 in your wallet on BNB Chain
x402-fetch(Node) orx402-requests(Python) installed — any x402 v2 client works
Step 0 — See the 402 challenge (no wallet needed)
accepts entry, sign it, and retry with the PAYMENT-SIGNATURE header. The SDKs below do this for you.
TypeScript example
wrapFetchWithPayment automatically signs, retries, and returns the data. The settlement result (tx, network, payer) is in the PAYMENT-RESPONSE header of the 200.
Python example
Cost math
How much will it actually cost?Troubleshooting
Errors come back as402 with the standard envelope; the facilitator’s message is forwarded in error.message.
404 X402_NOT_SUPPORTED
404 X402_NOT_SUPPORTED
The route is not one of the 15 priced endpoints. See the list.
402 INSUFFICIENT_BALANCE
402 INSUFFICIENT_BALANCE
Base rail: deposit USDC into Circle Gateway. BNB Chain rail: fund the signing wallet with the chosen asset.
402 PAYMENT_ALREADY_USED
402 PAYMENT_ALREADY_USED
Nonce reuse. Generate a fresh 32-byte nonce for every call.
402 PAYMENT_VALIDITY_TOO_SHORT
402 PAYMENT_VALIDITY_TOO_SHORT
validBefore - validAfter must be at least maxTimeoutSeconds from the 402 (345600s on Base).402 PAYMENT_INVALID_SIGNATURE
402 PAYMENT_INVALID_SIGNATURE
Signer must equal the token holder, and the EIP-712 domain must match the
extra block of the accepts entry you chose (on Base that is the Gateway Wallet contract, not the USDC contract).400 PAYMENT_INVALID
400 PAYMENT_INVALID
PAYMENT-SIGNATURE is not valid base64 or does not decode to an x402 v2 payload. Make sure x402Version is 2 — v1 clients fall back to the X-PAYMENT header, which is not accepted.
