Skip to content

x402

x402 ↗ is a payment standard built around HTTP 402 (Payment Required). Services return a 402 response with payment instructions, and clients pay programmatically without accounts, sessions, or API keys.

How it works

  1. A client requests a resource — GET /resource.
  2. The server returns 402 Payment Required with a PAYMENT-REQUIRED header containing Base64-encoded payment details: the price, accepted token, network, and merchant address.
  3. The client constructs a signed payment payload and retries the request with a PAYMENT-SIGNATURE header.
  4. The server verifies the payment payload — directly or by calling a facilitator — and settles the transaction on-chain.
  5. The server returns the resource with a PAYMENT-RESPONSE header containing settlement confirmation.

Key components

Client

The client is any entity that requests a paid resource: a human-operated app, an AI agent, or a programmatic service. Clients need only a crypto wallet — no accounts, credentials, or session tokens to manage.

Server

The server defines payment requirements in the 402 response, verifies incoming payment payloads, settles the transaction, and serves the resource. The x402 SDKs and a facilitator handle most of this automatically.

The facilitator

The facilitator is an optional but recommended third-party service that abstracts blockchain interaction. Rather than connecting to a node directly, the server delegates two operations:

  • POST /verify — Confirms the client's payment payload is valid before the server fulfills the request.
  • POST /settle — Submits the verified payment transaction to the blockchain.

The facilitator does not hold funds. It verifies and broadcasts the client's pre-signed transaction on behalf of the server. https://x402.org/facilitator is the public facilitator operated by Coinbase and is used in all Cloudflare examples. Multiple facilitators ↗ are available across different networks.

Payment schemes and networks

x402 uses payment schemes to define how a payment is constructed and settled on a given network.

SchemeNetworksDescription
exact ↗EVM, Solana, Aptos, Stellar, Hedera, SuiTransfers a fixed token amount — typically ERC-20 ↗ USDC on EVM — to the merchant address.
upto ↗EVMAuthorizes a maximum amount; the actual charge is determined at settlement time based on resource consumption.

Supported networks include Base, Ethereum, Polygon, Optimism, Arbitrum, Avalanche, Solana, Aptos, Stellar, and Sui. Use base-sepolia for testing with free test USDC from the Circle Faucet ↗.

Charge for resources

Pay for resources

SDKs

PackageInstallUse
x402-hononpm install x402-honoHono middleware for Worker servers
@x402/fetchnpm install @x402/fetchFetch wrapper with automatic payment handling
@x402/evmnpm install @x402/evmEVM payment scheme support
agents/x402Included in agentsMCP client with x402 payment support