Key Features
- 💸 HTTP-Native: Built into existing HTTP requests with no additional communication required
- ⚡ Instant Settlement: Sub-second on Celo, compared to days with traditional payments
- 🆓 Zero Protocol Fees: Only pay nominal blockchain gas fees
- 🤖 Agent-First: Designed for autonomous AI agent transactions
- 🌐 Chain Agnostic: Supports 170+ EVM chains including Celo
Why x402?
Traditional payment systems don’t work for AI agents and micropayments:| Challenge | Traditional Payments | x402 |
|---|---|---|
| Setup Time | Days to weeks | Minutes |
| Settlement | 2-7 days | Sub-second on Celo |
| Fees | 2-3% + $0.30 fixed | ~$0.001 gas |
| Minimum Payment | $0.50+ | $0.001 |
| Account Required | Yes | No |
| API Keys | Required | Not needed |
| Chargebacks | Yes (120 days) | No |
| AI Agent Support | Not possible | Native |
How It Works
Step-by-step:- Client requests resource - AI agent or app sends HTTP request to API
- Server returns 402 - If no payment attached, server responds with
HTTP 402 Payment Requiredand payment details in headers - Client signs payment - Client signs payment authorization using their wallet
- Client retries with payment - Request sent again with
X-PAYMENTheader - Server verifies and settles - Payment is verified and settled on-chain
- Server delivers resource - Requested content returned with payment receipt
Using thirdweb SDK
thirdweb provides a complete x402 implementation that supports Celo and 170+ EVM chains. The SDK handles wallet connection, payment signing, and error handling automatically.Client Side (React)
Use theuseFetchWithPayment hook for automatic payment handling:
Client Side (TypeScript)
For non-React applications, usewrapFetchWithPayment:
Server Side (Next.js)
Accept x402 payments in your API endpoints:Server Side (Express)
x402 on Celo
Celo is an ideal network for x402 due to:- Low fees: Gas costs under $0.001 per transaction
- Fast finality: ~1 second block times
- Stablecoin support: Native USDC, USDT, USDm for predictable pricing
- Fee abstraction: Users can pay gas in stablecoins
Supported Payment Tokens on Celo
The thirdweb facilitator supports tokens with ERC-2612 permit or ERC-3009 authorization:| Token | Address | Decimals |
|---|---|---|
| USDC | 0xcebA9300f2b948710d2653dD7B07f33A8B32118C | 6 |
| USDT | 0x48065fbbe25f71c9282ddf5e1cd6d6a887483d5e | 6 |
| USDm | 0x765DE816845861e75A25fCA122bb6898B8B1282a | 18 |
Celo Configuration
Use Cases
AI Agent API Access
Pay-Per-Use AI Inference
Micropayments for Content
Resources
| Resource | Link |
|---|---|
| x402 Official Website | x402.org |
| thirdweb x402 Docs | portal.thirdweb.com/x402 |
| thirdweb Playground | playground.thirdweb.com/x402 |
| GitHub | github.com/coinbase/x402 |
| Whitepaper | x402.org/x402-whitepaper.pdf |
Related
- ERC-8004 - Trust layer for AI agents
- Agent Skills - Modular agent capabilities
- Fee Abstraction - Pay gas with stablecoins on Celo