AgentPay
Letting AI agents transact natively with Bitcoin.
Created on 2nd October 2026
•
AgentPay
Letting AI agents transact natively with Bitcoin.
The problem AgentPay solves
The Problem
AI agents can't open bank accounts or get credit cards, which stops them from paying for the APIs and compute they need to work autonomously. At the same time, giving an AI model your personal credit card is dangerous a single prompt loop can drain thousands of dollars.
How AgentPay Solves It
AgentPay gives AI agents native Bitcoin Lightning wallets with strict spending guardrails:
- Pay-per-request: Agents pay satoshis to unlock paywalled APIs in milliseconds via L402 no credit cards, no signups, no monthly subscriptions.
- Hard budget caps: You give your agent a capped key (e.g., 500 sats). Once that budget is spent, the gateway instantly cuts it off, making runaway bills impossible.
- Non-custodial (Nostr NWC): Connect your own Lightning wallet (Alby, Mutiny) over decentralized Nostr relays. You never hand over your private keys.
What People Use It For
- On-demand research: AI agents paying per query for paywalled news, academic papers, and live financial feeds.
- Micro-compute: Coding agents paying only for the exact seconds of GPU or server time they use.
- Machine-to-machine commerce: Two autonomous agents buying and selling services directly from each other without human middlemen.
Challenges I ran into
1. The bolt11 Bech32 Decoder Crash
- The Hurdle: When testing micro-transactions on Voltage Mutinynet, our backend crashed with
Unknown coin bech32 prefix. The standardbolt11library only recognizes mainnet (lnbc) and testnet (lntb), whereas Mutinynet uses custom prefixes liketbs. - The Fix: We wrote a custom invoice pre-parser that extracts the human-readable part (HRP) and passes custom witness/prefix rules into the decoder dynamically, allowing seamless decoding across both testnet and mainnet.
2. L402 Settlement Race Condition
- The Hurdle: Immediately after an AI agent paid an invoice, the merchant server would sometimes return a false
401 Unauthorizedbecause the Lightning node was still briefly in a transitional state (receiving). - The Fix: We implemented two safeguards: a 3-second retry loop for transient node states, and direct cryptographic proof: verifying that
SHA256(preimage) === payment_hashalongside the macaroon signature for instant verification.
3. Asynchronous Nostr Relay Latency (NIP-47)
- The Hurdle: Nostr Wallet Connect publishes encrypted events to public Nostr relays and waits for a signed wallet response. Slow relays caused 4–6 second delays, risking LLM tool-calling timeouts.
- The Fix: We pooled reliable low-latency relays and cached active wallet connections in memory, bringing MCP payment responses down to under 1.5 seconds.
Tracks Applied (2)
Machine Money
Bitshala
Freedom Stack
Bitshala
Technologies used
Cheer Project
Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.
Discussion
Builders also viewed
See more projects on Devfolio
