SHARENOTEProof of energy
Specs/Applications
SNP-09draftneeds 01needs 02

Access Paid in Work

An HTTP API or MCP server charges per call in work: a 402 with a Z-bit price, paid with bound notes.

Summary

A service, an HTTP API or an MCP server, charges for a call in work instead of with an account or an API key. It states a price as a Z-bit. The caller pays with Sharenotes bound to the service's origin and current epoch.

Notes can be mined ahead of time, by the caller or a provider, so paying is instant. Each note is spendable once, at one origin, for two of the service's epochs.

API buildersMCP server authorsAI agentscallers

Kinds and tags

KindNameHow
27235HTTP Auth (NIP-98)keyed mode only: sent in the Sharenote-Auth header, signed by the notes' identity

Overview

StepWhoDoes
1. Priceserviceanswers an unpaid call with 402 Payment Required and its price
2. Minecaller or providermines notes bound to the service, ahead of time
3. Paycallerrepeats the call with notes worth at least the price
4. Serveservicechecks the notes, records them as spent, serves

Notes go straight to the service in a header. They need not be published to relays. Without keyed, a note is a bearer payment: whoever presents it first spends it. So never publish an unkeyed note before spending it.

The price header

A 402 carries Sharenote-Price: one price per accepted algorithm, separated by ,; fields key=value separated by ;.

FieldRequiredValue
gyesan accepted algorithm
zyesthe price, a Z-bit
epochyesthe epoch to mine for, below 2^32
untilyesunix time the epoch ends
periodyesepoch length in seconds, at least 1
maxyesmost notes per call, at least 16
sizenolargest record in bytes, default 256; at least 2048 for an -aux price
keyedno1: calls must carry a caller proof
sessionnoseconds of access one payment buys

Service fields are identical in every price. Refusals carry Sharenote-Error: count, size, proof, binding, algorithm, duplicate, spent, amount, caller or session.

Paying

A payment note's binding is exactly 36 bytes:

binding = SHA-256(origin) ‖ epoch (4 bytes, big-endian)

The origin is serialized as in RFC 6454: lowercase scheme and host, default port omitted, for example https://api.example. Only https URLs with a domain-name host are payable; the host is normalized to an IDNA A-label. The caller takes the origin from the URL that returned the 402, never from the response. The service uses its configured public origin, never the Host header.

The caller sends its notes in one Sharenote header: lowercase hex records separated by ,, all in one algorithm. Their values add by SNP-01, compared by weight.

Service checks

Checks run in order and stop at the first failure. Checks 1 to 9 hash no work.

#CheckRefusal
1at most max notescount
2each at most 2 · size hex characterssize
3lowercase hex; SNP-01 record checks 1 to 4proof
4binding is SHA-256(origin) and the current or previous epochbinding
5one algorithm, and it is pricedalgorithm
6no record twice in the callduplicate
7none in the spent-set (keyed by SHA-256 of the record)spent
8total weight ≥ w(T(z))amount
9if keyed: one identity and a valid Sharenote-Authcaller
10each note's work passes, heaviest firstproof

On success the service records all notes as spent atomically, then serves. A forged payment costs the service one work hash. Overpayment is not refunded.

Epochs, keyed mode and sessions

Epochs. Epoch e runs from E0 + e · period to until = E0 + (e+1) · period. A service accepts notes for its current and previous epoch only, so its spent-set covers two epochs. The epoch never decreases. After losing spent entries, a service refuses payments until its epoch reaches h + 2. All acceptors at one origin share one spent-set.

Keyed mode. With keyed=1, all notes share one identity and the call carries Sharenote-Auth: a base64 NIP-98 kind:27235 event signed by that identity, whose u is the origin plus the request target and which has one ["sharenote", <SHA-256 of the records>] tag. Copied notes become useless.

Sessions. With session=<seconds>, a payment returns Sharenote-Session: <token>, which covers every charged call for that long. The token is a bearer secret.

MCP

Over HTTP, an MCP server uses the same headers. The 402 body is a JSON-RPC error, and the client retries the same request with Sharenote.

Over stdio, the server runs on the caller's machine, so it forwards notes to a backend that runs the service checks for its own HTTPS origin. The client binds notes to the backend origin in its own configuration, never one the server reports. Without a configured origin, or on a mismatch, it must not pay.

{"code": 402, "message": "Payment Required",
 "data": {"origin": "https://api.example",
          "prices": [{"g": "sha256d", "z": "20z00", "epoch": 7,
                      "until": 1731003600, "period": 3600, "max": 16}]}}

The client retries with params._meta.sharenote, an array of hex records. Keyed mode and sessions are HTTP-only.

Worked example

A service at https://api.example charges 12z00 in sha256d, epoch 7, not keyed:

Sharenote-Price: g=sha256d;z=12z00;epoch=7;until=1731003600;period=3600;max=16

Its payment binding is SHA-256("https://api.example") ‖ 00000007:

e91cdb47052c095bd090354d5fe4d27c857def7e585248d963ca1d895232f667 00000007

Alice's provider has mined three notes credited to her with that binding, without her key: one 12z00 and two 11z00.

CallAnswer
no payment402, the price
the 12z00 noteserved
the same note again402, spent, no work hash
both 11z00 notes (2^11 + 2^11 = 2^12)served
a fresh 11z00 alone402, amount
the same note twice in one header402, duplicate
a note mined for another origin402, binding
a note for epoch 7, once the epoch is 9402, binding

Try it

Rendered from soprinter/snps/SNP-09.md. The full text has every rule; this page condenses it.