SHARENOTEProof of energy
Specs/Paid work
SNP-06draftneeds 01needs 03

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

KindNameHow
1724Orderrumor, NIP-59 gift-wrapped to the provider's kind:10050 inbox
1725Quoterumor, gift-wrapped back: one BOLT11 invoice per order
1731Statusrumor, gift-wrapped back: queued, mining, done or failed
TagMeaning
a31724:<provider>:<service id>
ethe announcement version relied on
gan algorithm the provider announces
zZ-bit of each note
identitythe key the notes credit
bbinding hex, 1 to 1024 bytes; absent for unbound
countnumber of notes, 1 to max
relaywhere the provider also publishes each note; at most 8
expirationuntil 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:

#CheckReason
1required tags once each, well-formedinvalid-tag
2a names a live service of its ownunknown-service
3the announcement lists gunknown-algorithm
4z at most the announced Z-bitz-too-large
5count from 1 to maxcount-out-of-range
6identity is a valid x-only keyinvalid-identity
7b is even-length hex, 1 to 1024 bytesinvalid-binding
8at most 8 wss:// relaysinvalid-relays
9expiration within horizonover-limit
10room for one more orderbusy

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 failed with unpaid. 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

StateMeaning
queuedtaken, paid or free, waiting for hashrate
miningbeing mined; lists notes so far
donecount notes delivered
failedrefused, 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
StepResult
order Oquote: invoice lnbc10n1… (1 sat), expiring in 10 minutes
O resentthe same quote
Alice pays 1 sat; provider matches itqueued
miningmining, note 0, from 1 note 1, done with all three; all pass
status from 1 arrives before note 0a gap: Alice resends O, gets notes 0 and 1
a quote for 2 satover the cap: not paid
an order with count 101failed, count-out-of-range
notes bound to another bindingall fail the checks
one note credited to Bobpasses: a gift
an order expiring in 2 daysfailed, over-limit (horizon 1 day)

Try it

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