Claude Code leaks shows it can autonomously pay for API access using crypto wallets
I've been going through the leaked codebase looking at stuff that isn't getting coverage. The Tamagotchi is fun, but here's the most interesting thing I found.
Claude Code has a /x402 command (also works as /wallet or /pay). It creates a crypto wallet for your agent. When the agent hits an API that wants money, it automatically pays with USDC (a stablecoin worth exactly $1) and retries the request. You don't do anything. The agent doesn't even know it happened.
Here's the simple version of how it works:
- Agent makes a normal HTTP request
- API says "this costs $0.03, pay me"
- Middleware catches this before the agent sees it
- Middleware checks: are we allowed to spend this much?
- If yes, signs the payment and retries
- Agent just gets the data back like nothing happened
The agent never reasons about money. No tokens wasted on "should I pay for this?" The middleware handles it.
The safety system is the part worth paying attention to:
- Off by default. No wallet, no risk. You opt in.
- $0.10 per-request cap. A sketchy API can't charge you $100 in one shot.
- $5.00 per-session cap. Even lots of small payments get capped.
- Network + token lockdown. Only pays USDC, only on the chain you configured. Rejects everything else.
- Full audit trail. Every payment shows up in
/statsalongside your normal token costs.
Both caps are configurable. There's even a testnet mode so you can try it with fake money first.
This isn't a prototype. It's wired into 4 core modules - the command system, the API client, the web fetch tool, and the cost tracker. Same coding style as everything else in the codebase.
For context: x402 is a real protocol from Coinbase. 75M+ transactions by December 2025. Cloudflare and Stripe have adopted it. Anthropic is publicly listed as a participant.
The bigger picture: right now, every API your agent uses needs a human to sign up, get a key, and configure it. This replaces all of that with pay-per-request. Agent hits the endpoint, pays the toll, gets the data, keeps working.
We may have found the real use case for crypto - not humans buying coffee, but agents buying API calls.
Anyone else spot this in the source?
Posted Apr 2, 2026, 10:33 PM UTC