Native Payments
for the Internet
x402 enables seamless machine-to-machine payments using the HTTP 402 status code. Built for AI agents, APIs, and the autonomous economy.
Built for the Agent Economy
Everything you need for seamless machine-to-machine payments
Automatic Payment Flow
The client SDK intercepts 402 responses, signs EIP-712 payloads, and retries requests automatically. Zero manual intervention required.
Cryptographic Security
Payments are signed with EIP-712 typed data, ensuring tamper-proof transactions verified on-chain.
BNB Smart Chain
Native support for BSC with USDT, USDC, BUSD, and WBNB tokens. More chains coming soon.
Express Middleware
Drop-in middleware for Node.js servers. Protect any route with payment requirements in one line.
TypeScript Native
Full type safety with exported interfaces, Zod validation schemas, and intelligent autocomplete.
Tree-Shakeable
Separate entry points for client and server. Import only what you need to minimize bundle size.
How x402 Works
Simple HTTP-based payment flow using the 402 status code
Request Resource
Client makes HTTP request to a paid API endpoint
GET /api/premium-data HTTP/1.1
Host: api.example.com402 Response
Server returns 402 with payment details
HTTP/1.1 402 Payment Required
X-Payment-Address: 0x...
X-Payment-Amount: 0.001 USDCSign & Pay
Client signs transaction and includes payment proof
GET /api/premium-data HTTP/1.1
X-Payment-Signature: 0x...
X-Payment-TxHash: 0x...Access Granted
Server verifies payment and returns the resource
HTTP/1.1 200 OK
Content-Type: application/json
{ "data": "..." }Live Demo
See the x402 protocol in action. Toggle between client and server implementations.
import { X402Client } from '@wazabiai/x402/client';// Initialize client with your private keyconst client = new X402Client({ privateKey: process.env.PRIVATE_KEY, // Optional callbacks for payment events onPaymentRequired: (requirement) => { console.log('Payment needed:', requirement.amount); }, onPaymentSigned: (payment) => { console.log('Signed by:', payment.signer); }});// Make requests - 402s are handled automatically!const response = await client.fetch( 'https://api.example.com/premium-data');console.log(response.data); // Premium content ✨// HTTP verb shortcutsawait client.get('/api/resource');await client.post('/api/resource', { data: 'value' });await client.put('/api/resource', { update: true });await client.delete('/api/resource');Start building in 60 seconds
Install the SDK and start accepting payments on your API immediately.
npm install @wazabiai/x402 viemimport { X402Client } from '@wazabiai/x402/client'const client = new X402Client({ privateKey })Supported Tokens
Accept payments in popular stablecoins and native tokens on BNB Smart Chain.
USDT
Tether USD
0x55d3...7955USDC
USD Coin
0x8AC7...580dBUSD
Binance USD
0xe9e7...7D56WBNB
Wrapped BNB
0xbb4C...095cLearn More
Explore documentation, source code, and tools to get started.
GitHub Repository
Browse the source code, report issues, and contribute to the project.
View on GitHubNPM Package
Install the SDK from npm and get started in seconds.
View on NPMDocumentation
Comprehensive guides, API references, and examples.
Read DocsBscScan
Explore transactions and verify contracts on BNB Smart Chain.
View ExplorerReady to monetize your API?
Join the future of programmable payments. Start accepting crypto in minutes.