About x402 Protocol
Breathes life into the long-dormant HTTP status code 402 – Payment Required.
Overview
The x402 protocol enables websites and APIs to require small payments directly through the HTTP layer. It allows automated systems—like AI agents—to pay for resources without traditional checkout flows, logins, or credit cards.
Open & Web-Native
Uses standard HTTP headers and status codes. No new sessions or logins are needed. It works with any HTTP stack.
Zero Fees & Instant
Transactions settle within seconds on fast chains like Base. The protocol itself charges 0 fees.
Blockchain Agnostic
Not tied to a single chain or token. Most implementations currently use stablecoins like USDC for price stability.
Frictionless
Developers can add x402 middleware with only a few lines of code. Agents pay without manual intervention.
How It Works
- 1
Request Resource
Client requests a protected resource (e.g., `GET /api/data`).
- 2
402 Payment Required
Server responds with HTTP 402 and a `WWW-Authenticate` header detailing price and address.
- 3
Payment & Sign
Client signs a payment payload (often via EIP-3009) and sends the transaction on-chain.
- 4
Access Granted
Client resubmits request with proof. Server verifies and returns 200 OK.
Limitations
- EIP-3009 Dependence: Currently relies on tokens supporting `transferWithAuthorization` (like USDC on Base).
- Latency: Two-step verification can introduce latency compared to centralized gateways.
- Facilitator Trust: Often relies on a facilitator service to verify payments, which centralizes part of the flow.