402 Payment Required handshake, then a facilitator verifies and settles it.
Demo
These examples target Base Sepolia (eip155:84532) and the public x402.org test facilitator. To take a route live, see Move to Base Mainnet.
1
Return Payment Requirements
The unpaid request receives a 402 response with the scheme, network, token, price, and recipient.
2
Sign and Retry
The buyer applies its spend policy, signs the advertised payment, and retries with
PAYMENT-SIGNATURE.3
Verify Before Work
Seller middleware verifies the payload before your protected handler runs.
4
Settle
The facilitator submits the payment and returns settlement details with the response.
Price a Fixed Route
An unpaid request receives 402; a valid paid retry reaches the handler and returns the resource once.
Move to Base Mainnet
The publicx402.org facilitator supports testnets only. Before you take a route live on Base mainnet:
- Choose a production facilitator path: a hosted facilitator that supports Base mainnet, such as the CDP Facilitator, your own facilitator, or self-facilitation inside your resource server. The x402 docs list other production facilitators.
- Set
networkto Base mainnet (eip155:8453) andpayToto a mainnet address you control. - Confirm the asset. A dollar price such as
"$0.01"on Base resolves to USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913), which settles through EIP-3009transferWithAuthorizationon the USDC contract. Other ERC-20 tokens settle through Permit2. - Call your facilitator’s supported endpoint and check that it lists
eip155:8453with the scheme your route uses.
exact, upto, and batch-settlement schemes, screens payments against OFAC and KYT checks, and authenticates with a CDP API key. See Network and token support for other networks and assets.
See Also
Settle Usage-Based Payments
Set the final charge after successful work.
Call a Paid Service
Add network, asset, and spend policy on the buyer.