How to Set Up an x402 Wallet for Your AI Agent
A complete guide to giving your AI agent a wallet that can pay for APIs autonomously. Compare Coinbase Agentic Wallet, raw private keys, and Circle Wallets.
Your AI agent needs to pay for things. Email verification, IP lookups, web scraping, LLM inference — the agentic economy runs on micropayments. x402 is the protocol that makes this work, but first your agent needs a wallet.
This guide covers the three main approaches, when to use each, and how to get started in under 10 minutes.
The Three Options
| Option | Best For | Custody | Setup Time |
|---|---|---|---|
| Coinbase Agentic Wallet | Most agents | Coinbase (non-custodial) | 2 minutes |
| Raw Private Key | Custom integrations | Self-custody | 5 minutes |
| Circle Programmable Wallet | Enterprise / compliance | Circle | 15 minutes |
Option 1: Coinbase Agentic Wallet (Recommended)
This is the fastest path. Coinbase built Agentic Wallet specifically for AI agents — it handles key management, spending limits, and x402 payments out of the box.
Why Agentic Wallet?
- No private key management: Keys stay in Coinbase infrastructure
- Built-in spending limits: Cap per-session and per-transaction
- Gasless transactions: No ETH needed, just USDC
- x402 native: Automatic payment signing for any x402 API
- OFAC compliance: Transfers are screened automatically
Setup (2 minutes)
Install the CLI, authenticate, and check your wallet:
npm install -g @coinbase/agentic-wallet
npx awal auth
npx awal status
That's it. Your agent now has a wallet on Base.
Funding Your Wallet
Get your wallet address with npx awal address, then send USDC on Base to that address.
For testing, use Base Sepolia testnet and get free test USDC from a faucet.
Using with Your Agent
If you're using an agent framework with MCP support (Claude, OpenClaw, etc.), install the skills:
npx skills add coinbase/agentic-wallet-skills
Your agent can now call pay-for-service, send, trade, and other wallet operations as tools.
Option 2: Raw Private Key
If you need full control or are integrating with a custom runtime, you can manage the wallet yourself.
When to Use This
- Building a custom agent runtime
- Need to sign transactions in-process (no CLI calls)
- Want to use a hardware wallet or HSM
- Testing/development
Setup (5 minutes)
- Create a wallet using MetaMask, Coinbase Wallet, or generate programmatically
- Fund with USDC on Base
- Implement the x402 client flow: request, get 402, sign payment, retry with proof
Security Warning
Never commit private keys to source control. Use environment variables, secrets managers (1Password, AWS Secrets Manager), or hardware wallets.
Option 3: Circle Programmable Wallets
Circle offers enterprise-grade wallet infrastructure with compliance features. Best for regulated industries or high-value use cases.
When to Use This
- Need SOC2 / compliance certifications
- Managing many agent wallets at scale
- Want web2-style APIs (no blockchain knowledge required)
- Enterprise support requirements
Which Should You Choose?
Starting out? Use Coinbase Agentic Wallet.
- 2-minute setup, no key management, works with most agent frameworks
Building custom infrastructure? Use raw private keys.
- Full control, works anywhere, more responsibility for security
Enterprise with compliance needs? Use Circle.
- SOC2 certified, enterprise support, higher setup cost
Funding Your Agent
Once your wallet is set up, you need USDC on Base:
From Coinbase: Buy USDC, withdraw to your agent's wallet, select Base network
From Any Exchange: Most exchanges now support Base. Send USDC and select Base network.
Bridge from Ethereum: Use bridge.base.org to bridge USDC from mainnet to Base
For Testing: Use Base Sepolia testnet with faucet USDC
Making Your First x402 Payment
Once funded, try AgentUtil:
npx awal pay https://api.agentutil.dev/v1/tools/dns.lookup/tasks \
--body '{"domain": "example.com"}'
The CLI handles the full 402 flow automatically.
Best Practices
- Use Spending Limits:
npx awal config set maxPerTransaction 0.10 - Monitor Spending:
npx awal history - Use Separate Wallets: Don't use your personal wallet
- Start on Testnet: Test before using real money
Summary
| Step | Action |
|---|---|
| 1 | Install: npm install -g @coinbase/agentic-wallet |
| 2 | Auth: npx awal auth |
| 3 | Fund: Send USDC on Base to your wallet |
| 4 | Use: npx awal pay <url> or add skills to your agent |
Your agent is now ready to pay for APIs autonomously.
Resources
Questions? Email silas@agentutil.dev