Skip to main content
Charge a known amount before returning an API response. In the Base USDC flow used here, x402 carries an EIP-3009 authorization through the HTTP 402 Payment Required handshake, then a facilitator verifies and settles it.

Demo

The demo above is mock only. If you want to see onchain demos on Vibenet, head to Base chain demos.
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.
Treat the facilitator response and your own fulfillment record as separate checks. Make the route idempotent so a retried paid request cannot deliver the same one-time resource twice.

Move to Base Mainnet

The public x402.org facilitator supports testnets only. Before you take a route live on Base mainnet:
  1. 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.
  2. Set network to Base mainnet (eip155:8453) and payTo to a mainnet address you control.
  3. Confirm the asset. A dollar price such as "$0.01" on Base resolves to USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913), which settles through EIP-3009 transferWithAuthorization on the USDC contract. Other ERC-20 tokens settle through Permit2.
  4. Call your facilitator’s supported endpoint and check that it lists eip155:8453 with the scheme your route uses.
The CDP Facilitator supports Base mainnet with the 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.