What is x402?
A complete explanation of the x402 protocol — how HTTP 402 enables automatic stablecoin payments directly on the web.
At a glance
- The server responds with HTTP 402 Payment Required and machine-readable x402 v2 payment terms
- The buyer's wallet signs a Permit2 authorization (first browser payment may need an on-chain
approve) - In canonical TransX402, the merchant backend calls
POST /facilitate; the facilitator settles on-chain
Background
The HTTP status code 402 Payment Required has existed since the original HTTP/1.1 specification in 1997, but was never widely used — until now. x402 is an open payment protocol developed by Coinbase and supported by Cloudflare that finally puts it to work: it embeds machine-readable payment instructions into standard HTTP responses, enabling instant, automatic stablecoin payments directly on the web.
How a Payment Works
Steps
- 1Client sends GET /content
- 2Server responds with 402 Payment Required
- 3Client retries with PAYMENT-SIGNATURE
- 4Server POST /facilitate (secret API key)
- 5Facilitator verifies and submits on-chain
- 6Blockchain confirms transaction
- 7Server returns 200 OK with the requested content
Client sends a request. A client (browser, app, or AI agent) sends a standard HTTP request, for example to access a premium article:
Server responds with 402. If the content requires payment, the server responds with payment details in JSON:
amount is IDRX base units (2 decimals): Rp 5,000 → "500000". Chain, token, and Permit2 come from GET /config, not hardcoded in your app.
Client signs a payment authorization. The buyer signs a Permit2 payload (signTypedData). Browser Path 4 needs a one-time on-chain approve (user pays gas); later payments are signature-only. Agents can use sponsored approve (Path 3).
Client retries the merchant. The client retries the original request with PAYMENT-SIGNATURE (and X-PAYMENT as fallback). It does not call the facilitator when settlement: "server".
Merchant settles via the facilitator. Your backend (@transx402/server or WordPress PHP) calls POST /facilitate with a secret API key. TransX402 verifies the signature, checks balance and allowance, simulates, submits, and pays settle gas.
Server delivers the content. After a successful facilitate response, the server returns 200 OK with the paid resource.
Authorization Methods
x402 supports several payment authorization methods. IDRX uses Permit2, since it's a standard ERC-20 token without native EIP-3009 support.
| Method | Tokens | Notes |
|---|---|---|
| EIP-3009 | USDC, EURC | Native gasless transfer — simplest approach |
| Permit2 | All ERC-20 (including IDRX) | One-time approval to the Permit2 contract |
| ERC-7710 | Smart contract wallets | For smart contract wallets |
Why Are Transaction Fees So Low?
Fees stay under $0.003 per transaction because of three things working together: cheap L2 settlement, free off-chain signing, and one optimized transaction paid for by the facilitator.
- L2 settlement — Payments settle on low-cost chains like Base, not Ethereum mainnet, where gas is a fraction of a cent instead of dollars.
- Off-chain authorization — The buyer's Permit2 or EIP-3009 signature is free; no gas is spent until the final settlement transaction hits the chain.
- Facilitator pays gas — TransX402 submits one optimized transaction per payment and covers the gas itself, so the buyer never needs ETH.
- No card-rail overhead — There's no interchange fee, acquirer margin, or cross-border FX layer; value moves directly from buyer wallet to merchant wallet as stablecoin.
Because the fixed cost per transaction is tiny on Base, charging Rp 5,000 for a single article is economically viable — see What is IDRX? for why TransX402 defaults to Base.
Why x402 Matters
- Open standard — anyone can build a compatible client, server, or facilitator
- No buyer registration — buyers just need a crypto wallet, no account required
- Gasless for payers — the facilitator covers gas fees
- AI agent compatible — agents can pay for content automatically without human intervention
- Micropayment-friendly — see above for why fees stay low enough for small payments
Ecosystem
x402 is backed by a rapidly growing ecosystem: Coinbase is the primary protocol developer providing official SDKs and the CDP facilitator; Cloudflare integrates it via Agents SDK and MCP Servers; and the two co-founded the x402 Foundation to drive adoption. The protocol processed 75+ million transactions in the 30 days leading up to March 2026.
| Package | Language | Purpose |
|---|---|---|
@x402/fetch | TypeScript | Client — Fetch API wrapper |
@x402/express, @x402/hono, @x402/next | TypeScript | Server middleware |
x402 | Python | Client and server support |
See the official x402 docs for the complete SDK list.
TransX402's Role
Coinbase's CDP facilitator only supports USDC. TransX402 is an x402 facilitator built specifically for IDRX, and it's fully compatible with the wider ecosystem — any x402 client library can be pointed at the TransX402 facilitator. Ready to try it? Head to the Quickstart.