SHARENOTEProof of energy
Specs/Paid work
SNP-04draftneeds 01

Work Offer

An issuer asks for work toward a fixed template; workers answer with notes; contributions are public.

Summary

An issuer publishes a work offer: the algorithm, a template, the minimum Z-bit, and optionally a reward and a close time. Workers answer with Sharenotes bound to it, so the work done for the offer is public and tied to a template that can never change.

An offer can also reward notes bound to an existing event, or to events of a given kind that reference it. Then the same work counts there too, for example likes on a post.

issuersworkersminersauditors

Kinds and tags

KindNameHow
1726Offersigned, regular event: it can never change
1723Noteworkers answer with SNP-01 notes bound to the offer
TagMeaning
gthe algorithm; exactly one
zthe minimum Z-bit accepted; exactly one
rewardamount and unit to split among workers; optional
methodlightning or onchain; with reward only
closesunix seconds; notes seen before it count for the reward
targetreward work bound to this event id instead
viareward work bound to events of this kind that reference the target
relaywhere workers publish and auditors read; 1 to 8

The offer

An offer is a signed kind:1726 regular event. Its content is the template: an opaque description the notes commit to through the offer id. The work is never computed over it, and its format is the application's.

  • z is a canonical Z-bit, 1 ≤ z ≤ 255, two-digit cc ≤ 99.
  • reward is a positive integer in the smallest unit; the unit name is the issuer's.
  • closes: the issuer counts only notes it first saw on its relays strictly before that second. A note's created_at is not evidence.
  • via needs target; one tag per kind, at most 65535.
  • 1 to 8 relay tags, so every worker can publish to, and every auditor read, all of them.

An offer that breaks a count or form rule is invalid and ignored. Workers find offers with {"kinds":[1726], "#g":["<algorithm>"]}.

Answering an offer

A worker mines SNP-01 notes credited to itself and publishes each to the offer's relays. The binding is a single id:

Offer hasbinding
neither target nor viathe offer's id
targetthe target's id
target and viathe id of a via-kind event that has an e tag to the target and is signed by the note's identity

A note answers the offer when it verifies ATTRIBUTED, its algorithm equals g, its binding is the one rewarded, and its target is at most the z target.

A note bound to the offer's id is newer than the offer and tied to its exact template. A note proves only that work was committed to its binding. Nothing here checks that the template's task was performed.

Events of a via kind

For an offer with via, the worker first signs an event of one of those kinds, then binds its notes to that event's id. The event must:

  • have a valid NIP-01 id and sig;
  • be signed by the same key as the notes' identity, so work counts only through an action that person signed;
  • carry an e tag equal to the offer's target.

What the event means is its own spec's business. The note has one binding and counts once: for the event, under that event's own spec, and toward the offer. For example, an offer with target = a post and via = 7 counts work behind reactions to that post.

Contributions

A worker's contribution is the total weight of its notes that answer the offer, each (algorithm, H) once. Anyone computes it from the union of the offer's relays:

Offer hasQuery on each relay
neither{"kinds":[1723], "#b":[<offer id>]}
target{"kinds":[1723], "#b":[<target id>]}
target and via{"kinds":[<via>], "#e":[<target id>]}, then {"kinds":[1723], "#b":[<event ids>]}

For the reward, the issuer counts only notes it first saw at or after it published the offer, and before closes. Later notes still count toward public contributions.

Splitting the reward

With a reward, the issuer splits it by SNP-01 §Splitting a reward. Each distinct identity is one recipient, weighted by the contribution over the notes the issuer counted. With no counted notes, nothing is split.

The issuer's counted set can differ from what an observer sees. This spec makes contributions auditable, not payouts; SNP-05 receipts close that gap. How the issuer pays is outside this spec, though method says which SNP-03 Pay destinations it uses.

Trust points: the reward is a promise with no escrow; the issuer is trusted for closes and for what it counted; a listed relay can withhold notes, so workers publish to every relay and keep their own records.

Worked example

An offer has ["reward", "1000", "sat"]. Two workers answer it:

WorkerNotesContributionShare of 1000
Alice8z00, 9z002^8 + 2^9 = 768, reads 9z58429
Bob10z002^10 = 1024, reads 10z00571

W = 1792. The floors are 1000 · 768 / 1792 = 428.57 → 428 and 1000 · 1024 / 1792 = 571.43 → 571. That leaves one unit. Alice's remainder is larger, so she gets it: 429 and 571, exactly 1000.

Try it

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