x402
x402.org- Category
- Developer Tools
- Rank
- No. 2862Tools index
Previous survey · No. 2730 ·
- Listed in
- #7 Accept payments
- Pricing
- Paid
- Type
- TOOL
- Use case
- Business & Commerce
- Interfaces
- API
- Builder
- x402-foundation
- GitHub
- 6.8k stars
- Date
About
HTTP 402 stablecoin payments. Open protocol for paying for API/web resources over HTTP 402 with stablecoins. Enables pay-per-request access for agents and apps with no accounts.
What it does
A server answers an unpaid request with a status code that lists what it will accept: price, chain, token and destination address. The client signs a matching authorization, retries with it attached in a header, and gets the response once the charge clears. A separate service called a facilitator can check the signature and submit the transfer onchain, so the seller never runs blockchain nodes. The repository ships reference SDKs in TypeScript, Python and Go, plus the written specification.
Why it's ranked here
It is a standard with real implementations behind it, not a whitepaper. Three language SDKs share one server design, the TypeScript side covers Express, Hono, Next, Fastify, Fetch and Axios, and chain packages span EVM, Solana, Aptos, Stellar, Hedera, Casper and more. The code handles the unglamorous failure cases: a settlement whose receipt times out returns a retryable pending state with the transaction hash, and the server retries once while reconciling against that hash instead of paying twice. Apache 2.0 licensed.
What's good
Server integration is a middleware call with a route map, and the same route config shape appears in all three languages. Three payment schemes cover distinct needs: a fixed price, a capped maximum where the seller settles actual usage, and batched settlement through escrow and offchain vouchers for many tiny charges. Lifecycle hooks before and after verify and settle let a seller abort, recover or grant free access. A dedicated wrapper puts paid tools behind the Model Context Protocol, the standard AI assistants use to call tools.
Tradeoffs
The public facilitator is meant for testnets; the docs say not to assume it is a production path for mainnet, so sellers must pick a provider, run their own, or settle in-process. The default pending-settlement store lives in memory and only works when the retry hits the same process, so replicated facilitators need a shared store such as Redis. On Solana, sellers settling without a facilitator must build their own duplicate-payment detection. Fiat support is an aim in the principles, not something the fetched code implements.
How to use it well
Start on a testnet with the public facilitator and the fixed-price scheme on one route. Before mainnet, choose a facilitator deliberately. If yours runs on serverless, set the confirmation timeout a few seconds under the platform deadline, since a killed process returns an error with no hash to reconcile. Reach for the capped scheme when cost depends on output, such as metered model calls. Use the upfront flow when a slow handler risks the signed transaction expiring. It does not provide wallets, key custody or accounting.
Technical notes+
The typical flow in README.md runs twelve steps over three base64 JSON headers (PAYMENT-REQUIRED, PAYMENT-SIGNATURE, PAYMENT-RESPONSE), as tabulated in docs/core-concepts/http-402.md. In go/server.go the x402ResourceServer is V2 only, caches facilitator /supported responses for five minutes by default, gives precedence to earlier facilitator clients per network and scheme, and scopes scheme hooks through schemeHookAdapters so they no longer leak across schemes. ResolveSettlementOverrideAmount accepts atomic units, a percent floored to two decimals, or a dollar amount. go/http/server.go defines an HTTPAdapter interface per framework and serves paywall HTML to browsers. python/x402/server.py offers async and sync servers; settle_payment wraps settle_with_pending_retry_async. go/mcp/server.go panics at construction on an unregistered scheme. docs/core-concepts/facilitator.md documents a 120 second SVM SettlementCache and a 180000 ms default confirmationTimeoutMs.
Observed
- License
- Apache License 2.0
- SDK languages
- TypeScript (npm @x402 packages), Python (pip install x402), Go module
- Server frameworks (TypeScript)
- Express, Hono, Next, Fastify; clients for Fetch and Axios
- Payment schemes
- exact, upto, batch-settlement (batch-settlement is EVM only)
- Chain packages
- EVM, SVM (Solana), AVM, Aptos, Casper, Stellar, TVM, Hedera, Keeta
- Interfaces
- HTTP middleware, HTTP facilitator client, MCP tool payment wrapper
- Transport
- Three base64-encoded JSON headers on HTTP status 402 responses and retries
- Public facilitator scope
- Documented as intended for development and testnet workflows
Read from README.md, package.json, LICENSE, docs/core-concepts/http-402.md, docs/core-concepts/facilitator.md, docs/schemes/exact.mdx, go/server.go, go/http/server.go, python/x402/server.py, go/mcp/server.go.
Intel on x402
- Your Agent Just Paid for Nothing: 6 Attacks on x402 Payments - Ishween Kaur, SoFi
- x402 isn’t good (yet) — Jan Curn, Apify
- When AI Agents Pay and Sellers Monetize: Building x402 Apps on AWS — Anil Nadiminti, AWS
- Browserbase And Coinbase X402
- Announcing the Monetization Gateway: charge for any resource behind Cloudflare via x402
Tags
Tech Stack
Media

Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.