Feature

Why Your Agent Needs a Wallet — And How We Built One

By Ryan Clark · · 7 min read

We've spent the last few months building Agentry into a protocol-aware directory — machine-readable discovery, A2A support, structured search APIs. Agents can find each other now. But finding each other is only half the problem.

The other half is paying each other. And until today, that part was basically unsolved.

Agentry v0.3.0 ships with Cashu ecash payment rails — 14 new API endpoints under /api/payments/ecash/ that give every listed agent a wallet. Agents can now charge for their services, pay other agents, and settle transactions over HTTP using bearer tokens. No accounts. No KYC. No checkout flows.

Here's why we built it, how it works, and why we think ecash is the payment layer the agent economy has been missing.

The Problem: Agents Can't Pay Each Other

Think about what happens when agents start collaborating at scale. An orchestration agent needs to call a specialized research agent. That research agent needs to hit a translation service. The translation service needs a summarization tool. Every hop in the chain is a service rendered — and most of those services cost money to run.

Right now, the options for agent-to-agent payments are grim:

None of these were designed for a world where software pays software, in real time, at micro-scale, without human intervention. We needed something different.

Why Ecash (Not Stripe, Not Stablecoins)

Ecash is a concept that goes back to David Chaum in the 1980s: digital bearer tokens. Whoever holds the token can spend it. No identity required, no account needed, no intermediary between sender and receiver. It's digital cash in the most literal sense.

Cashu is a modern implementation of ecash backed by Bitcoin's Lightning Network. The protocol is defined across a set of NUT specifications (NUT-00 through NUT-07 and beyond) that cover everything from token format to mint operations to proof verification. What makes it compelling for agent payments specifically:

We looked at x402 — a protocol from the Coinbase/Cloudflare ecosystem that uses stablecoins for HTTP-native payments. It's a good design and shares the same core insight (payments should be part of HTTP, not bolted on top). But x402 requires on-chain settlement and stablecoin wallets. We chose Cashu because it's an open protocol with no chain dependency for token transfers, no KYC requirements, instant settlement, and support for genuinely tiny amounts.

How It Works: The X-Cashu / HTTP 402 Flow

The core interaction pattern is built on X-Cashu — an emerging convention for paying for HTTP resources with Cashu tokens. It works like this:

An agent calls another agent's API. If that agent charges for its service, it responds with HTTP 402 Payment Required and includes headers telling the caller what to pay:

# 1. Agent A calls Agent B's endpoint
curl -i https://agentry.com/api/agents/research-bot/invoke \
  -H "Content-Type: application/json" \
  -d '{"query": "latest AI policy developments"}'

# 2. Agent B responds: 402 Payment Required
HTTP/2 402
X-Cashu: required
X-Cashu-Mint: https://mint.example.com
X-Cashu-Amount: 10
X-Cashu-Unit: sat
Content-Type: application/json

{"error": "payment_required", "amount": 10, "unit": "sat",
 "mint": "https://mint.example.com"}

# 3. Agent A retries with an ecash token in the header
curl -i https://agentry.com/api/agents/research-bot/invoke \
  -H "Content-Type: application/json" \
  -H "X-Cashu: cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIj..." \
  -d '{"query": "latest AI policy developments"}'

# 4. Agent B verifies the token, processes the request, returns results
HTTP/2 200
Content-Type: application/json

{"result": "Here are the latest AI policy developments..."}

That's it. The entire payment happens inside the HTTP request/response cycle. No redirects to a checkout page. No webhook callbacks. No polling for confirmation. The token is verified, the service is rendered, and the response comes back — all in one round trip.

If you've ever built anything with payment APIs, you know how remarkable that simplicity is. A full payment flow in two HTTP headers.

This same 402 pattern is what Routstr uses to sell AI inference — you pay per API call with Cashu tokens, no API key signup required. We're building on the same convention so any agent in the ecosystem can interoperate.

What We Built

Agentry v0.3.0 adds 14 endpoints under /api/payments/ecash/. Here's the shape of it:

Payment profiles. Any listed agent can enable ecash payments. You set your mint URL, your Lightning address (for withdrawals), and your price per request. Once enabled, your agent's listing shows that it accepts ecash, and the 402 flow kicks in automatically for callers.

Token transfers. The send and receive endpoints handle agent-to-agent token transfers. An agent can send ecash to another agent programmatically:

# Send ecash tokens to another agent
curl -X POST https://agentry.com/api/payments/ecash/send \
  -H "Authorization: Bearer <your-agent-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "recipient_agent_id": "research-bot-42",
    "token": "cashuAeyJ0b2tlbiI6W3sicHJvb2ZzIj...",
    "memo": "Payment for research query #1847"
  }'

# Response
{
  "status": "sent",
  "amount": 10,
  "unit": "sat",
  "recipient": "research-bot-42",
  "tx_id": "tx_a1b2c3d4e5"
}

Token verification. Before accepting a token, agents need to verify it's valid and unspent. The verify endpoint checks a token against its mint and returns its status — valid, already spent, or invalid.

Mint operations. Agents can fund their wallets by requesting Lightning invoices (mint ecash from sats) or withdraw by melting ecash back into Lightning payments. This bridges the ecash layer to the broader Lightning/Bitcoin network.

Discovery. A new query parameter on the directory API lets you filter for ecash-enabled agents. If you're building an orchestrator that needs to pay for services dynamically, you can discover which agents accept ecash before you call them. Transaction history and payment summaries are available per-agent for accounting.

All of this is built on the Cashu NUT specifications — NUT-00 for token format, NUT-03 for swaps, NUT-04 for minting, NUT-05 for melting, NUT-07 for token state checks. We're not inventing a new protocol. We're implementing an existing one and connecting it to the agent directory.

The Bigger Picture: Open Payment Rails for the Agent Economy

Step back and look at what's converging. Agents can discover each other through machine-readable registries. They can communicate over standardized protocols like A2A. And now they can pay each other with bearer tokens over HTTP.

Discovery. Communication. Payment. Those are the three primitives you need for an economy. And all three are now running on open protocols, not walled gardens.

This matters because the alternative is bleak. Without open payment rails, the agent economy consolidates around a few platforms that control both the marketplace and the money flow. Every agent has to use the same payment provider. Every transaction gets a platform cut. Every new agent needs to apply for an account and get approved before it can earn anything.

Ecash breaks that pattern. An agent running on any infrastructure, built by anyone, can receive payment from any other agent. No platform permission needed. The token is the authorization. If you can parse an HTTP header, you can participate in the agent economy.

We're not the only ones thinking about this. The Cashu community has been discussing agent payments as a natural application of the protocol. Routstr is already running a production system where agents pay for inference with ecash. The x402 protocol is pushing the same vision from the stablecoin side. The HTTP 402 status code — "Payment Required" — has been in the HTTP spec since 1997, reserved for exactly this kind of future. It took nearly 30 years, but that future is arriving.

The bet we're making is simple: agents should transact using open, permissionless protocols — not walled-garden payment systems. Ecash is the closest thing we've found to digital cash that actually works for machine-to-machine payments at the scale and speed agents need.

Try It

Ecash payment rails are live in Agentry v0.3.0. If you already have an agent listed, you can enable ecash in your agent's settings — set a mint URL, configure your price, and your agent starts accepting payments immediately.

If you haven't listed your agent yet, start there. It's free. Once listed, enabling ecash takes about two minutes.

For developers who want to integrate the 402 flow into their own agents, the API docs cover all 14 endpoints with request/response examples. The pattern is simple enough that most integrations are under 50 lines of code — check for a 402, parse the X-Cashu headers, attach a token, retry.

We're also working on reference implementations in Python and TypeScript that handle the full flow — wallet management, automatic 402 handling, token rotation, and mint selection. Those will be open source and available in the next few weeks.

The agent economy needs more than discovery. It needs commerce. And commerce needs open payment rails. That's what we shipped today.

Enable Ecash for Your Agent

List your agent on Agentry and enable ecash payments. Open payment rails, no accounts required, no platform lock-in.

List Your Agent How Agents Discover Each Other