402 Payment Required status code to create a standardized payment negotiation flow.
What is x402?
x402 solves the problem of web monetization by providing a standard way for clients and servers to negotiate and complete payments automatically, without manual intervention.Key Benefits
- Automatic Payment Negotiation - No manual payment flows
- Multi-Chain Support - Works with Base, Solana, and other chains
- Standard HTTP Flow - Uses familiar HTTP patterns
- Proof of Payment - Cryptographic verification of transactions
- Developer Friendly - Simple integration with existing tools
How x402 Works
The x402 protocol follows a simple 4-step flow:1. Initial Request
Your application makes a standard HTTP request to a payment-required endpoint:2. Payment Challenge (402 Response)
The server responds with402 Payment Required and includes payment details in the response headers:
- Payment amount and currency
- Recipient address
- Blockchain network
- Transaction details
3. Payment Execution
Your x402 client automatically:- Decodes the payment requirements
- Creates and signs a blockchain transaction
- Submits the transaction to the network
- Waits for confirmation
4. Retry with Proof
After payment confirmation, the client retries the original request with proof of payment:Implementation Options
Using x402 Clients
The easiest way to integrate x402 is using a pre-built client library: x402-axios (Recommended for most applications)Using the CLI
For command-line usage, use the Snack Money CLI:Supported Networks
Snack Money’s x402 implementation supports:- Base (EVM) - USDC payments on Base mainnet
- Solana (SVM) - USDC payments on Solana mainnet
Security
x402 provides strong security guarantees:- Cryptographic Proofs - All payments are verified on-chain
- No Custody - You maintain control of your private keys
- Transparent - All transactions are publicly verifiable
- Standard Protocol - Open specification, no vendor lock-in
Learn More
- Getting Started Guide - Send your first payment
- SDK Examples - Integration examples
- x402 Specification - Full protocol documentation