x402 Payment Protocol

The internet-native payment protocol enabling autonomous, programmable payments with 1 line of code. No fees, 2-second settlement, $0.001 minimum payment.

What Is X402?

x402 is an open-source payments protocol built on HTTP that enables digital payments on the internet. It leverages the long-reserved HTTP 402 "Payment Required" status code to create a standardized way for servers to request payment for resources and for clients to fulfill those payments programmatically.

The protocol addresses fundamental problems with traditional internet payments: credit cards require high friction, impose steep minimums, and don't align with the programmatic nature of digital services. x402 enables true micropayments with settlements as fast as 200 milliseconds on blockchain rollups.

Key Features

  • Zero Fees: No transaction fees for customers or merchants
  • Instant Settlement: Money in your wallet in 2 seconds, not T+2 days
  • True Micropayments: $0.001 minimum payment enables pay-per-use models
  • Chain Agnostic: Not tied to any specific blockchain or token
  • HTTP Native: Integrates seamlessly with standard web service requests
  • Trust Minimizing: Prevents unauthorized fund movement
  • Open Standard: No dependence on single entities, fully open-source
  • Developer Friendly: Abstract cryptographic complexity, simple integration

How X402 Works

The x402 protocol involves three main actors working together to enable seamless payments:

  • Clients: Entities seeking to pay for resources (users, AI agents, applications)
  • Resource Servers: HTTP servers providing APIs or content that require payment
  • Facilitator Servers: Third-party services handling payment verification and blockchain settlement

The payment flow works as follows:

  1. Client requests a resource from the server
  2. Server responds with HTTP 402 status and payment requirements (amount, asset, network)
  3. Client creates a payment payload matching the requirements
  4. Client sends the request again with the payment in the X-PAYMENT header
  5. Server or facilitator validates the payment authenticity
  6. Facilitator submits the payment transaction to the blockchain
  7. Server responds with the requested resource and payment confirmation

Facilitators

Facilitator servers are a critical component of the x402 ecosystem. They act as trusted intermediaries that handle the blockchain-specific complexities of payment verification and settlement.

Facilitators expose three key endpoints:

  • POST /verify: Validates payment authenticity and prevents fraud
  • POST /settle: Executes blockchain transactions and handles settlement
  • GET /supported: Lists supported scheme/network combinations

By abstracting blockchain complexity, facilitators enable resource servers to accept payments without deep blockchain expertise. They ensure payments are valid, prevent double-spending, and handle the technical details of on-chain settlement across multiple blockchain networks.

Use Cases

x402 enables new business models and use cases that were previously impossible or impractical:

  • AI Agent Commerce: AI agents can make autonomous payments for API calls, data access, and services without human intervention
  • Per-Inference AI Services: Pay only for the AI inferences you use, not monthly subscriptions
  • Content Micropayments: Publishers can charge per-article instead of requiring full subscriptions
  • Pay-Per-Use APIs: Eliminate API keys, accounts, and rate limits in favor of usage-based payments
  • Gaming Microtransactions: Per-play gaming models with instant, low-cost payments
  • IoT & Machine-to-Machine Payments: Devices can pay each other programmatically for services and resources

About The Project

x402 is developed by Coinbase and released as open-source software under the Apache 2.0 license. The project has gained significant traction with over 2,500 GitHub stars, 380 forks, and 65+ contributors from the developer community.

The protocol is guided by five core principles:

  1. Open Standard: Avoiding dependence on single entities
  2. HTTP Native: Seamless integration with web services
  3. Chain and Token Agnostic: Supporting multiple blockchains and signing standards
  4. Trust Minimizing: Preventing unauthorized fund movement
  5. User-Friendly: Abstracting cryptographic complexity from developers

The project is actively maintained with comprehensive documentation, examples in multiple programming languages (TypeScript, Python, Java, Go), and a growing ecosystem of integrations and services.

Ecosystem Tokens

The x402 ecosystem has grown to include various tokens and projects building on the protocol. The ecosystem has a combined market cap of approximately $50.7 million and includes tokens across multiple blockchains including Base, Solana, and others.

Token Symbol Blockchain Market Cap Description
Daydreams DREAMS Solana $24.08M Generative agent library for playing anything on-chain. Provides x402-enabled LLM inference for agents and applications.
SANTA by Virtuals SANTA Base $3.3M Offers dynamic learning, teaching agents to adapt to new services through example-driven configurations.
Heurist HEU Base N/A Full-stack infrastructure for the AI economy. Provides crypto skills for AI agents with MCP and x402 support.

For live prices and a complete list of x402 ecosystem tokens, visit CoinGecko's x402 Ecosystem page.

Technical Implementation

Implementing x402 in your application is straightforward. For a basic TypeScript server, it's as simple as adding a single line of middleware:

paymentMiddleware("0xYourAddress", { "/your-endpoint": "$0.01" })

The protocol supports multiple "schemes" (payment methods) and blockchain networks. The initial "exact" scheme transfers specific amounts. Payment requirements specify the amount, asset (like USDC), network (like Ethereum or Base), and timeout parameters.

All payment data is transmitted via standard HTTP headers, making it compatible with existing web infrastructure and tools.

Resources & Links