Bitcoin for Agentic Payments
The Economy of Machines Paying Machines
thesimplekid
Legacy Rails Break Down for Machines
Why can't an AI agent just use a credit card?
1. Identity & KYC
Fiat networks are tied to human identity. Agents do not have passports, utility bills, or bank accounts to pass KYC protocols and sign up for Stripe.
2. Chargebacks & Finality
Credit cards have chargeback windows. To safely automate API access and atomic swaps across the globe, agents require instant, irreversible finality.
3. Perfect Privacy
When an agent executes thousands of micro-transactions, it leaves a massive, trackable data trail exposing strategy and user data.
The Solution: Bearer Assets & Micropayments
Bitcoin and the Lightning Network act as the native, permissionless currency of AI.
- Permissionless: Any machine can generate a private key and start transacting immediately.
- Micro-scale: Settle transactions fractions of a cent in real-time.
- Final: No chargeback fraud means providers can deliver data to anonymous agents instantly.
HTTP 402: A 30-Year Promise
The 402 Payment Required status code was reserved in the original HTTP spec in the 1990s.
- 1990s: Web pioneers foresaw micropayments, but no native digital cash existed. The code sat unused.
- 2000s-2010s: E-commerce centralized around credit cards, API keys, and subscriptions.
- Today: AI agents need programmatic, stateless payments. The 30-year-old standard finally has its missing piece: Bitcoin.
How It's Being Used Now
Standards like L402 and the Machine Payments Protocol (MPP) bring 402 to life.
MPP Lightning "Charge" Intent
Client Server Lightning Network
| | |
| 1. GET /resource | |
| ---------------------------> | |
| | 2. Create invoice |
| | ---------------------------> |
| | 3. invoice, hash |
| | <--------------------------- |
| 4. 402 Payment Required | |
| (invoice, hash) | |
| <--------------------------- | |
| | |
| 5. Pay invoice | |
| ----------------------------------------------------------> |
| 6. Preimage (HTLC) | |
| <---------------------------------------------------------- |
| | |
| 7. GET /resource | |
| credential: preimage | |
| ---------------------------> | |
| | |
| 8. 200 OK (resource) | |
| <--------------------------- | |
Ecash for Agents (NUT-24)
Ecash (Cashu) tokens are perfect for agents: stateless, instantly verifiable, perfect privacy, and no routing failures.
NUT-24: Cashu HTTP 402
- A server responds with
402 and an X-Cashu header.
- The header defines the amount, unit, and acceptable mints.
- The agent simply resends the request with a valid Cashu token in its own
X-Cashu header.
// Server: We need 10 sats from Mint A or B
402 Payment Required
X-Cashu: {"a": 10, "u": "sat", "m": ["https://mintA.com"]}
// Agent: Here is the token.
GET /api/data
X-Cashu: cashuAeyJ0b2tlbiI6W3sibWl...
The directory of paid APIs for AI agents.
Agents can programmatically search via MCP (Model Context Protocol) to find services on 402index.io, negotiate prices, and pay on the fly.
Real-World Implementations
Open agents negotiating and paying across MPP and xCashu standards dynamically.
- Seamlessly handle 402 challenges.
- Pay for exactly what they use.
- No subscriptions or manual API key management.
A decentralized AI inference router.
- Pay-per-request API for LLM generation.
- Uses Cashu eCash as the API key.
- Drop-in replacement for OpenAI SDKs without vendor lock-in.
The domain registrar built specifically for agents.
- Search, register, and manage via API.
- Pay with Bitcoin Lightning (L402 flow).
- Uses
agent-wallet for autonomous settlement.
Agent Wallet Architecture
How does the agent actually hold funds and sign payments?
The Tech Stack
- NWC (Nostr Wallet Connect): Standardized protocol for apps to command remote Lightning wallets.
- CDK (Cashu Dev Kit): Embeddable Rust/JS/Python libraries to manage ecash directly in the agent's memory.
- agent-wallet: Self-custodial Bitcoin Lightning wallet daemon explicitly built for AI agents.
- mppx SDK: Client libraries to auto-intercept and fulfill MPP HTTP 402 responses.
Agent Implementation (JS)
A simple wrapper to intercept 402s and pay via Cashu NUT-24
async function fetchPaidResource(url, wallet) {
let response = await fetch(url);
if (response.status === 402) {
// 1. Read the payment challenge
const cashuReq = response.headers.get('X-Cashu');
const requestDetails = JSON.parse(cashuReq);
// 2. Agent wallet autonomously mints/selects tokens
const token = await wallet.getTokens(
requestDetails.a,
requestDetails.m
);
// 3. Retry with payment credential
response = await fetch(url, {
headers: { 'X-Cashu': token.serialize() }
});
}
return response.json();
}
The Future is M2M
Arrow Keys to Navigate