Mining Providers
Order notes mined on your behalf over Nostr: a gift-wrapped order, a Lightning quote, checked delivery.
Summary
Not every device can mine. A provider mines Sharenotes for you: you name the identity to credit, the binding and the Z-bit, and you receive the notes. The provider never needs the identity's key.
Providers announce themselves (SNP-03). Any app can place an order over relays. The provider quotes it with a Lightning invoice, mines once paid, and you check every note it delivers. A rig behind NAT can be a provider: nothing needs a public endpoint.
app buildersprovidersphone and browser usersAI agents
Kinds and tags
| Kind | Name | How |
|---|---|---|
| 1724 | Order | rumor, NIP-59 gift-wrapped to the provider's kind:10050 inbox |
| 1725 | Quote | rumor, gift-wrapped back: one BOLT11 invoice per order |
| 1731 | Status | rumor, gift-wrapped back: queued, mining, done or failed |
| Tag | Meaning |
|---|---|
| a | 31724:<provider>:<service id> |
| e | the announcement version relied on |
| g | an algorithm the provider announces |
| z | Z-bit of each note |
| identity | the key the notes credit |
| b | binding hex, 1 to 1024 bytes; absent for unbound |
| count | number of notes, 1 to max |
| relay | where the provider also publishes each note; at most 8 |
| expiration | until when the provider may take the order |
Transport
An order (kind:1724) goes from the customer to the provider. A quote (kind:1725) and statuses (kind:1731) come back. All are NIP-59 gift wraps, one per recipient, sent to the recipient's NIP-17 kind:10050 inbox relays.
The customer is the key that signed the order's seal, the ordering key. It need not be the identity credited. The recipient drops a message whose seal pubkey differs from its rumor pubkey. The customer drops a quote or status not from the provider of one of its orders.
Relays see a wrap addressed to someone, but neither who orders from whom nor what is ordered.
Pricing
The provider's price tag gives the cost of one note of a reference Z-bit. An order of count notes of Z-bit z costs at most:
ceil( amount · count · w(z) / w(price Z-bit) )
with w the SNP-01 weight. A provider must not ask more. The cap is the provider's own announcement as it stands when it issues the quote. Quotes are paid over Lightning, so a cap compares only in sat or msat. Without a price for the algorithm, the price is whatever the invoice asks. A price of 0 means the order is queued at once with no quote.
Order checks and refusals
The provider checks in order and answers the first failure with a failed status and its reason:
| # | Check | Reason |
|---|---|---|
| 1 | required tags once each, well-formed | invalid-tag |
| 2 | a names a live service of its own | unknown-service |
| 3 | the announcement lists g | unknown-algorithm |
| 4 | z at most the announced Z-bit | z-too-large |
| 5 | count from 1 to max | count-out-of-range |
| 6 | identity is a valid x-only key | invalid-identity |
| 7 | b is even-length hex, 1 to 1024 bytes | invalid-binding |
| 8 | at most 8 wss:// relays | invalid-relays |
| 9 | expiration within horizon | over-limit |
| 10 | room for one more order | busy |
An order without one valid expiration, or received already expired, is dropped without answer.
Paying
- The provider issues one quote per order: a BOLT11 invoice with an amount, and an
expiration. The invoice never outlives the quote. Price and terms are fixed at quote time. - The customer pays only if it never paid a quote for this order, the quote is not near or past expiry, the invoice has an amount on the right network, and the amount is within the cap.
- A quote is paid once the provider matches a payment settled by the quote's expiration. It then sends
queued. A payment settled in time counts even if matched late, after a restart. - With no payment settled in time, the order ends
failedwithunpaid. A later payment is never taken. - A resent order before payment gets the same quote. The customer must not pay it twice.
A provider must not mine before payment, unless nothing was due.
Statuses
| State | Meaning |
|---|---|
queued | taken, paid or free, waiting for hashrate |
mining | being mined; lists notes so far |
done | count notes delivered |
failed | refused, unpaid, stopped or unavailable |
Notes are numbered from 0. A status lists consecutive notes from ["from", i] on; absent, from 0. A non-final status may list only new notes. A final status lists every note. Large statuses split into parts with ["part", i, n].
The customer holds h notes. A status with from ≤ h is applied. A status with from > h is a gap: nothing of it is applied, and the customer resends the order. The answer to a resend lists every note.
Checking a delivery
The customer must check every delivered note before relying on it:
- SNP-01 record checks 1 to 5 give
ATTRIBUTED; - its algorithm, identity and binding equal the order's;
- its Z-bit is at least the order's
z; - its
(algorithm, H)was never received before, in any order.
At most count passing notes count. Work is certainly new only when the binding is new. For a reused binding, a provider can deliver notes that already existed. Unbound notes can never be shown fresh.
The provider sees every note first. A note that works as a bearer payment can be spent by the provider. Order those only from a provider you trust, and never with relay.
Worked example
A provider announces ["g","sha256d","24z00"], ["max","100"] and ["price","1","sat","sha256d","16z00"]. Alice's phone orders three 12z00 notes, credited to Alice and bound to a new reaction id.
ceil( 1 · 3 · w(12z00) / w(16z00) ) = ceil( 3 · 2^140 / 2^144 ) = ceil(0.1875) = 1 sat
| Step | Result |
|---|---|
| order O | quote: invoice lnbc10n1… (1 sat), expiring in 10 minutes |
| O resent | the same quote |
| Alice pays 1 sat; provider matches it | queued |
| mining | mining, note 0, from 1 note 1, done with all three; all pass |
status from 1 arrives before note 0 | a gap: Alice resends O, gets notes 0 and 1 |
| a quote for 2 sat | over the cap: not paid |
| an order with count 101 | failed, count-out-of-range |
| notes bound to another binding | all fail the checks |
| one note credited to Bob | passes: a gift |
| an order expiring in 2 days | failed, over-limit (horizon 1 day) |
Try it
Buy work
Order notes from a mining provider when your device can't mine.
Hashrate planner
What your hardware mints per second, and what hashrate public shares imply.
Rendered from soprinter/snps/SNP-06.md. The full text has every rule; this page condenses it.
