The flow
x402 is built on HTTP. When a service requires payment, it returns HTTP 402 (Payment Required)
with a signed payment quote in the response body. Your client reads the quote, signs a USDC
payment on Base from your wallet, and retries the original request with an
x-payment header containing the signed payment. The service verifies the payment
on-chain and returns the result.
1. Your agent → POST /scrape (initial request)
2. Service ← 402 Payment Required (payment quote in body)
3. Your agent → signs USDC payment on Base
4. Your agent → POST /scrape (retry with x-payment header)
5. Service ← 200 OK + result (payment settled) What you need
- A wallet with USDC on Base.
- An x402 client library that handles the 402 → sign → retry loop automatically.
- If using MCP: the MCP server handles the payment flow. Configure
X402_PAYMENT_HEADERif your wallet is external.
Client libraries
The x402 spec ships with official client libraries:
# TypeScript/Node
npm install x402
# Python
pip install x402
# Go
go get github.com/coinbase/x402-go See x402.org for the full specification and client library docs.
Settlement
Payment settles on Base (Coinbase's L2) in ~2 seconds. USDC is the only accepted currency. Settlement wallets are public on Basescan — you can verify every payment.
- Microservices (13 services): 0x1C68…B3bC
- Molt Swarm (3 services): 0x61F2…AfFf5
Charge-on-failure protection
Payment only settles when the service returns HTTP 2xx with non-empty content. If the call fails for any reason (timeout, HTTP error, JS crash, empty response), the x402 SDK does not settle payment. This was patched across the full fleet on 2026-05-07 — the v1.0.0 bug (settling on any non-5xx) is fixed.