x402 Payments
Accept USDC cryptocurrency payments using the x402 protocol on Base network.Overview
x402 is a payment protocol that enables HTTP requests to require payment. Agents can pay for API access programmatically.Setup
Environment Variables
Supported Networks
| Network | Chain ID | Status |
|---|---|---|
| Base Mainnet | 8453 | ✅ |
| Base Sepolia | 84532 | ✅ (Testnet) |
Creating Paid Endpoints
Step 1: Import x402
Step 2: Define Payment Requirements
Step 3: Check for Payment
Agent Payment Flow
Agents can make paid API calls:Pricing Examples
| Action | Price |
|---|---|
| Basic API call | $0.001 |
| AI generation | $0.01 |
| File upload | $0.05 |
| Video generation | $1.00 |
Wallet Setup
Users need a wallet with USDC on Base:- Install MetaMask or Coinbase Wallet
- Bridge funds to Base network
- Get USDC on Base
Troubleshooting
Payment failed
Payment failed
- Ensure wallet has sufficient USDC on Base
- Check network is correct (Base, not Ethereum)
- Verify payTo address is correct
402 response
402 response
- Include x-payments header in request
- Use x402 SDK for automatic payment handling