Manage a USDC wallet for AI agents on Base, supporting balance checks and secure x402 payments with configurable network and key settings.
# ๐ฆ Agent Wallet Skill
USDC wallet for AI agents on Base with x402 payment protocol support.
## โ ๏ธ Security
This skill interacts with real blockchain assets. Every precaution is taken.
| Rule | Status |
|------|--------|
| Private key from env var only | โ
`WALLET_PRIVATE_KEY` / `.env` |
| Private key never logged | โ
Zero logging of key material |
| Payments need explicit --confirm | โ
Double security gate |
| Address separate from key | โ
`WALLET_ADDRESS` for read-only mode |
## Phase 1 โ Read-Only (Zero Dependencies)
```bash
export WALLET_ADDRESS=0x...
export WALLET_NETWORK=base-sepolia
node wallet.mjs balance
```
## Phase 2 โ x402 Payments (Requires viem)
```bash
npm install viem
export WALLET_PRIVATE_KEY=0x... # your wallet key (keep secret!)
export WALLET_ADDRESS=0x... # derived from key, or set manually
export WALLET_NETWORK=base-sepolia # or "base" for mainnet
node wallet.mjs pay <url> --confirm
```
## CLI Reference
| Command | Requires | Description |
|---------|----------|-------------|
| `balance` | WALLET_ADDRESS | Check USDC + ETH balance |
| `status` | WALLET_ADDRESS | Show wallet config (safe) |
| `pay <url>` | + PRIVATE_KEY + --confirm | Pay x402 resource |
## Architecture
```
agent-wallet/
โโโ SKILL.md โ Usage docs
โโโ package.json โ Zero deps (viem optional for Phase 2)
โโโ .env.example โ Config template
โโโ wallet.mjs โ CLI entry point
โโโ lib/
โโโ core.mjs โ Core wallet (native fetch RPC, no deps)
โโโ crypto.mjs โ EIP-3009 signing (viem-powered)
โโโ x402-client.mjs โ x402 payment protocol client
```
## Networks
| Network | Chain ID | RPC | Explorer |
|---------|----------|-----|----------|
| Base | 8453 | mainnet.base.org | basescan.org |
| Base Sepolia | 84532 | sepolia.base.org | sepolia.basescan.org |
## Integration (for agents/skills)
```javascript
import { getWallet, getBalances } from './lib/core.mjs';
// Read-only โ safe
const wallet = await getWallet();
const { eth, usdc } = await getBalances(wallet);
// Payments (requires viem)
const { payX402 } = await import('./lib/x402-client.mjs');
const result = await payX402(url, privateKey, { confirm: true });
```
## License MIT-0
don't have the plugin yet? install it then click "run inline in claude" again.