56. Paid calls
Status: unimplemented — design draft. This chapter is a plan for the owner to edit. It ships no code yet, and paths marked planned do not exist.
Premise
Members can reach everyone. This chapter lets a member charge: an author sets a price, and a call to a priced member is paid in Bitcoin at the moment it is made.
Draft
"Paid usage" in Episode 289 needs a definition. Here it means a call to a member that has a price.
An author puts a price on an operation in the release. When a plan includes that operation, the price is part of the plan, and you see it before the work starts. The call is paid in sats over Lightning.
The payment sits in the request itself. The server answers that payment is required and names the amount. The caller pays and retries with proof. The archive first builds this in Episodes 62 and 63, where an agent pays an endpoint. The Coax tree has the settle and verify steps of the current form. It works the same whether the caller is a person's agent or another plugin.
Small prices need small payments. A call may cost a few sats or less than one. Lightning can carry that, and where a single payment is too small to send, calls are counted and settled in batches.
Many members will be free, and free members are still worth making. They earn credit, and they build the reputation that makes a paid one credible.
Episode 290 describes a second way to pay, for people who don't hold Bitcoin yet: a credits account filled by card, with a fee, and a discount for paying in Bitcoin. That is a plan with open terms, and it is listed below. If we offer it, the balance is service credit: small, and not withdrawable. A card buys credit. It is never a rail an agent pays with.
A price is the author's claim about value. The evidence of chapters 43 to 52 is the buyer's way to check it.
What we build
A plan for what this chapter ships once the draft is approved:
- A price field in a release, shown in the plan before a paid call runs.
- Payment in the request: a payment-required answer, a Lightning payment, and a retry with proof.
- Batched settlement for calls too small to pay one at a time.
It builds on what exists today:
- `coax/lib/x402`
- `coax/lib/lightning/invoice.coax`
- `coax/lib/lightning/pay.coax`
- `coax/lib/nostr/mkt`
- `coax/lib/gateway/rates.coax`
On the protocol (chapter 65):
| Record | Schema | Carriage | Today |
|---|---|---|---|
| Payment required, payment and settlement | openagents.x402.v1 PaymentRequired, PaymentPayload, SettleResponse, kept exactly as x402 defines them (spec 26.4) | HTTP 402 body; a native record in a kind 3188 envelope (NIP-X402) | Spec sketch; no .proto file. coax/lib/x402 has the settle and verify steps |
| A price | openagents.market.v1 Offering (spec 26.2) | Nostr kinds 3192 and 30192 (NIP-MKT) | Spec sketch; no .proto file. coax/lib/nostr/mkt handles the NIP's JSON |
The chapter's check
- Source: the price field in a release,
pay/price-policy.coax, and the payment step in the request, on `coax/lib/x402`. - Trace: a fake service and a fake Lightning wallet with recorded answers, on the controlled clock. The plan shows the price in sats; the call answers 402 with the amount; the wallet pays; the retry carries the preimage, and the call settles. No real money moves.
- Refusal: a retry after the invoice's time plus 60 seconds is refused with
the invoice has expired, and an invoice for another amount withthe invoice's amount is not the terms' amount, as `coax/lib/x402/settle.coax` prints today. - Independent check: BOLT 11's published test vectors, in `coax/tests/lightning/invoice_vectors.coax`, and
shasum -a 256over the fixture preimage giving the payment hash.
Shipped paths: `pay/price-policy.coax`, an #authority file in the Payments context (`pay/`, shipped in #14060 and exercised in `openagents/examples/capability-economy-e2e.coax`).
Planned paths: pay/x402-gateway.coax.
Sources
- Episodes:
- Episode 289, *OpenAgents*: 2:00, paid usage
- Episode 62, *Exploring L402*: payment in an HTTP request
- Episode 63, *Agent Pays L402 Endpoint*: an agent pays an endpoint
- Episode 70, *L402 Plugin Deployment*: deploying a paid plugin
- Episode 97, *User Pays Agent*: a user pays an agent
- Episode 290, *Enter the Verse*: 9:30, credits and a discount for Bitcoin
- Old code at
coder-v1.0.0, crates:x402,pay-host,commercial-accounts,commercial-spend,retail-service - NIPs: NIP-X402, NIP-MKT, NIP-EXT
- Promises covered (audit): P11
Open questions for the owner
- What can an author price: a call, a unit of work, a subscription?
- Do we offer card-funded credits as Episode 290 describes, with a fee and a Bitcoin discount, and what are the numbers?
- Is there a free amount of paid calls for new people, and who funds it?