x402 Wallet Setup
x402 lets AI agents pay per request with USDC on Base — no accounts, no sign-up, no monthly commitment. This guide walks you through setting up a wallet for your agent.Already have an x402 wallet? Skip to Making your first paid request.
What is x402?
x402 is an open payment standard built on HTTP. When your agent requests a protected resource, the server responds with402 Payment Required and a price. Your agent signs a USDC payment and retries — the whole flow happens in the request/response cycle, no separate checkout.
Choose your setup path
Pick the path that matches your agent platform:Agentic Wallet MCP
For Claude Desktop, Claude Code, Cursor, Codex CLI, Gemini CLI, or any MCP client. Easiest path.
Agentic Wallet CLI
For agents that can run shell commands but don’t speak MCP. Fastest setup.
CDP SDK
For custom Python or TypeScript agents. Most control.
OpenClaw
For OpenClaw agents with existing x402 support.
Agentic Wallet MCP
Best for: Claude Desktop, Claude Code, Cursor, Codex CLI, Gemini CLI, and any MCP-compatible client. Setup time: ~5 minutes1. Install the MCP server
2. Restart your client
Close and reopen your MCP client to load the wallet tools.3. Sign into your wallet
Ask your agent:- New users: Enter your email → verify your email → wallet created
- Returning users: Enter your email → verify your email → you’re in
4. Fund your wallet
In the wallet UI:- Click Fund
- Follow the Coinbase Onramp flow to add USDC
- Return to your agent
- Click Receive
- Copy your wallet address
- Send USDC on Base to that address
5. Set spending limits (recommended)
In the wallet UI:- Click the spending limit tracker
- Set Max per call: e.g., $0.05
- Set Max per session: e.g., $5.00
- Save
6. Make your first paid request
Ask your agent:Agentic Wallet CLI
Best for: Agents that can run shell commands, CI pipelines, terminal-based workflows. Setup time: ~2 minutes1. Install and authenticate
2. Get your wallet address
3. Check your balance
4. Make a paid request
CLI Reference
CDP SDK
Best for: Custom Python or TypeScript agents, applications with their own payment logic. Setup time: ~15 minutesPrerequisites
- Create a free account at portal.cdp.coinbase.com
- Generate an API key and wallet secret
- Set environment variables:
TypeScript
Python
Fund the wallet
The wallet address is printed when you run the client. Send USDC on Base to that address. For testing, use Base Sepolia testnet and the CDP Faucet.OpenClaw
OpenClaw agents with x402 support can use X1-BaaS directly. The MCP server handles payment automatically.MCP Configuration
Add to your OpenClaw MCP configuration:Using the scrape tool
Once configured, your agent can call thescrape tool directly. If x402 payment is required, the agent will handle the payment flow automatically (if it has an x402 wallet configured).
Hermes Agent
Hermes Agent by Nous Research supports MCP servers natively via~/.hermes/config.yaml.
MCP Configuration
Add to~/.hermes/config.yaml:
Setting up x402 payments
Hermes Agent can use the Agentic Wallet MCP for x402 payments:npx awal (see Agentic Wallet CLI above).
Using the scrape tool
Once configured, ask Hermes to scrape a page:Making your first paid request
Once your wallet is set up and funded:Via MCP (any client)
Via curl
Via the BaaS API directly
The x402 flow is automatic when using the CDP SDK or Agentic Wallet:- Agent requests
/v1/scrapewith no payment - Server responds
402 Payment Requiredwith price and payment options - Agent signs a USDC permit and retries with
X-PAYMENTheader - Server verifies payment, scrapes the page, returns clean Markdown
You’re only charged on success. Payment is verified before the scrape and settled only after a successful result. Timeouts and connection failures never charge you.
Troubleshooting
”402 Payment Required” on every request
Your wallet doesn’t have enough USDC. Check your balance:- MCP: Ask “What’s my wallet balance?”
- CLI:
npx awal balance - SDK: Check the wallet address and verify on BaseScan
”Authentication failed” after setting up wallet
Your payment may have expired. x402 payments have a time window — if your agent takes too long between signing and sending, the payment expires. This is normal; just retry.Wallet not showing up
Make sure you:- Completed email verification
- Restarted your MCP client after installation
- Asked your agent to “Show me my wallet” (this triggers the auth flow)
Can I use testnet?
Yes. For development:- CDP SDK: Pass
environment: "development"to use Base Sepolia - Get test USDC from the CDP Faucet
- X1-BaaS testnet endpoint:
https://api-testnet.tazpal.com(coming soon)
Security Best Practices
- Set spending limits — Always configure max per-call and per-session limits in the wallet UI
- Use separate wallets — Don’t reuse your main crypto wallet for agent payments
- Monitor usage — Check your wallet balance and transaction history regularly
- Start small — Fund with $5-10 USDC initially, increase as needed
- Use testnet first — Test your integration on Base Sepolia before mainnet
What to read next
Authentication
API keys vs x402 — choose the right path for your use case.
Scrape endpoint
Full API reference for the scrape endpoint.
x402 Protocol
Learn how x402 payments work under the hood.
Agentic Wallet Docs
Official Coinbase Agentic Wallet documentation.