💡 Inspiration: The "Unbanked" AI Agents
AI agents are the fastest-growing consumers of API services — yet they can't pay for anything. Every API call requires a human to sign up, add a credit card, and manage billing. Agents have no bank accounts, no identity, and no financial autonomy.
We asked: What if HTTP already had a payment protocol — and Bitcoin Lightning could power it?
It does. HTTP status code 402 Payment Required has been reserved since 1997. Bitcoin Lightning settles in ~50ms for fractions of a cent. We built the bridge.
🤖 What it does
Daemon is a two-sided payment protocol for the Machine Economy:
- For API Providers: One command (
npx @daemon/l402-proxy) wraps any existing API with pay-per-call micropayments. No Stripe, no user accounts, no billing logic. - For AI Agents: A drop-in SDK (Python/TypeScript) that automatically detects
402 Payment Required, pays a Lightning invoice, and retries — all in a single function call.
The protocol: L402 = HTTP 402 + Macaroon tokens + Lightning invoices.
⚙️ How we built it
- L402 Gateway (Node.js/Express): Macaroon minting, invoice generation, 6 security middlewares (Circuit Breakers, Replay Protection, Rate Limiting, Budget Rails, Allowlist, Root Key Rotation).
- L402 Proxy: A reverse proxy that adds L402 to any upstream API with zero code changes.
- Agent SDKs: Python and TypeScript clients with automatic 402 handling.
- Integrations: ElizaOS Plugin (agent framework), MCP SDK (Model Context Protocol).
- Infrastructure: LND for Lightning settlement, Redis for distributed state, Docker Compose for one-click deployment.
🚧 Challenges we ran into
- Lightning in HTTP: Fitting an asynchronous Lightning payment into a synchronous HTTP request/response cycle required careful state management with preimage storage and polling.
- Macaroon Security: Building a cryptographic token system where each token is bound to a specific payment hash, with automatic root key rotation and replay protection.
- Making it zero-config: Packaging LND + Gateway + Redis into a single
docker-compose upthat works on first run, while supporting both mock mode (demo) and real LND (production).
🏆 Accomplishments that we're proud of
- HTTP 402 is real: We made the 27-year-old HTTP status code actually work — pay a Lightning invoice, get your data.
- Production security: 6 layers of defense, not a hackathon toy.
- Both sides covered: Proxy for API providers + SDK for agents = complete two-sided protocol.
🚀 What's next for Daemon
- Mainnet Launch: Moving from mock/regtest to Bitcoin Mainnet with real LND channels.
- Dynamic Pricing: Agents negotiate prices based on demand, latency, and quality.
- API Discovery: A registry of L402-enabled endpoints for agents to find and pay autonomously.
Built With
- bitcoin
- docker
- elizaos
- express.js
- grpc
- l402
- lightningnetwork
- lnd
- macaroons
- mcp
- next.js
- node.js
- python
- react
- redis
- typescript
Log in or sign up for Devpost to join the conversation.