Skip to main content

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 with 402 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 minutes

1. Install the MCP server

The installer will prompt you to select your MCP client and configure it automatically.

2. Restart your client

Close and reopen your MCP client to load the wallet tools.

3. Sign into your wallet

Ask your agent:
This opens a browser window for authentication:
  • 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:
  1. Click Fund
  2. Follow the Coinbase Onramp flow to add USDC
  3. Return to your agent
Or:
  1. Click Receive
  2. Copy your wallet address
  3. Send USDC on Base to that address
How much to fund? At 0.005/request,0.005/request, 1 USDC covers 200 scrapes. Start with $5 for 1,000 requests.
In the wallet UI:
  1. Click the spending limit tracker
  2. Set Max per call: e.g., $0.05
  3. Set Max per session: e.g., $5.00
  4. Save
Your agent respects these limits but can’t change them — only you can.

6. Make your first paid request

Ask your agent:
Or search for X1-BaaS in the Bazaar:

Agentic Wallet CLI

Best for: Agents that can run shell commands, CI pipelines, terminal-based workflows. Setup time: ~2 minutes

1. Install and authenticate

2. Get your wallet address

Send USDC on Base to this 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 minutes

Prerequisites

  1. Create a free account at portal.cdp.coinbase.com
  2. Generate an API key and wallet secret
  3. 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 the scrape 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:
Or use the interactive MCP picker:

Setting up x402 payments

Hermes Agent can use the Agentic Wallet MCP for x402 payments:
Select “Other” when prompted for your client, then add the MCP server to your Hermes config:
Alternatively, use the CLI path with npx awal (see Agentic Wallet CLI above).

Using the scrape tool

Once configured, ask Hermes to scrape a page:
Hermes will discover the MCP tools and use them automatically.

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:
  1. Agent requests /v1/scrape with no payment
  2. Server responds 402 Payment Required with price and payment options
  3. Agent signs a USDC permit and retries with X-PAYMENT header
  4. 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:
  1. Completed email verification
  2. Restarted your MCP client after installation
  3. 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

  1. Set spending limits — Always configure max per-call and per-session limits in the wallet UI
  2. Use separate wallets — Don’t reuse your main crypto wallet for agent payments
  3. Monitor usage — Check your wallet balance and transaction history regularly
  4. Start small — Fund with $5-10 USDC initially, increase as needed
  5. Use testnet first — Test your integration on Base Sepolia before mainnet

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.