AgentPay

Letting AI agents transact natively with Bitcoin.

Visit Repo
AgentPay banner

About

## The problem it 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 we 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 standard `bolt11` library only recognizes mainnet (`lnbc`) and testnet (`lntb`), whereas Mutinynet uses custom prefixes like `tbs`. * **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 Unauthorized` because 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_hash` alongside 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.

Screenshots

AgentPay screenshot 1AgentPay screenshot 2AgentPay screenshot 3AgentPay screenshot 4AgentPay screenshot 5

Team

From the public Devfolio project page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

Not checked yet.

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.

AgentPay-x402

Autonomous AI agent that discovers, pays for, and uses APIs with real crypto micropayments