AGENTUTIL
DocsGetting Started

Set Up a Wallet

Give your AI agent a wallet for autonomous x402 payments.

Why a Wallet?

x402 payments require signing. Your agent needs a wallet with:

  • USDC on Base — the payment token
  • A private key — to sign payment proofs

Option 1: Coinbase AgentKit (Recommended)

Coinbase built AgentKit specifically for AI agents.

npm install @coinbase/agentkit
import { CdpClient } from "@coinbase/cdp-sdk"; const cdp = new CdpClient(); const wallet = await cdp.evm.createWallet(); console.log("Address:", wallet.address); // Fund this address with USDC on Base

Why AgentKit:

  • No private key management
  • Built-in spending limits
  • Gasless transactions
  • x402 native support

→ AgentKit integration guide

Option 2: Raw Private Key

For custom integrations or full control.

Generate a Wallet

# Using cast (Foundry) cast wallet new # Or Node.js node -e " const { Wallet } = require('ethers'); const w = Wallet.createRandom(); console.log('Address:', w.address); console.log('Private Key:', w.privateKey); "

Store Securely

Never commit private keys to git. Use:

  • Environment variables
  • 1Password / secrets manager
  • Hardware wallet (advanced)
export AGENT_PRIVATE_KEY="0x..."

Use in Your Agent

import { Wallet } from "ethers"; const wallet = new Wallet(process.env.AGENT_PRIVATE_KEY); // Sign x402 payments with this wallet

Fund Your Wallet

Send USDC on Base to your agent's address.

From Coinbase

  1. Open Coinbase app
  2. Select USDC → Send
  3. Enter your agent's address
  4. Select Base network (not Ethereum!)
  5. Send $5-10 to start

From Any Exchange

Most exchanges support Base withdrawals. Select "Base" or "Base Mainnet" when withdrawing USDC.

For Testing

Use Base Sepolia (testnet) with fake USDC:

  • Get test ETH from Alchemy faucet
  • Test USDC contract: 0x036CbD53842c5426634e7929541eC2318f3dCF7e

Check Your Balance

# Using cast cast call 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \ "balanceOf(address)" YOUR_ADDRESS \ --rpc-url https://mainnet.base.org

Or check basescan.org with your address.

Security Tips

  1. Start small — $10-20 is plenty for testing
  2. Use spending limits — cap per-transaction amounts
  3. Separate wallets — each agent gets its own wallet
  4. Monitor spending — check transaction history regularly

→ Spending controls guide

Next Steps