Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

fairdrop source realm

Constants 1

const RealmPath, PackagePath, PhaseOpen, PhaseReveal, PhaseDrawable, PhaseDrawn, PhaseCancelled, MaxSlots, MaxWeightCap, MinWindowSeconds, MaxWindowSeconds, MaxTitleLen, MaxPrizeLen

 1const (
 2	// RealmPath is this realm's own path and must equal the module line in
 3	// gnomod.toml (scripts/check.sh verifies that). It is part of every seal's
 4	// domain, so a seal made for this board cannot be replayed against another.
 5	RealmPath = "gno.land/r/g1k6cl2huxpps9fxls8tqyxknvl7fgq9hua3f2yt/fairdrop"
 6
 7	// PackagePath is the reusable engine this realm imports.
 8	PackagePath = "gno.land/p/g1k6cl2huxpps9fxls8tqyxknvl7fgq9hua3f2yt/fairness"
 9
10	PhaseOpen      = "open"      // entries are being sealed
11	PhaseReveal    = "reveal"    // entries closed, secrets being revealed
12	PhaseDrawable  = "drawable"  // reveal window over, waiting for Draw
13	PhaseDrawn     = "drawn"     // winners recorded
14	PhaseCancelled = "cancelled" // voided by the organizer before entries closed
15
16	// MaxSlots caps winners per event so a draw stays cheap to compute.
17	MaxSlots = 100
18	// MaxWeightCap caps organizer-granted ticket weight per address.
19	MaxWeightCap = 100
20	// MinWindowSeconds is the shortest window an event may open or reveal for.
21	MinWindowSeconds = 30
22	// MaxWindowSeconds is the longest window (30 days).
23	MaxWindowSeconds = 30 * 24 * 60 * 60
24
25	MaxTitleLen = 80
26	MaxPrizeLen = 240
27)
source

Functions 10

func Cancel

crossing Action
1func Cancel(cur realm, eventID uint64)
source

Cancel voids a draw before entries close. After close the entries are committed and only the draw can settle them.

func Create

crossing Action
1func Create(cur realm, title string, prize string, slots int, maxWeight int, regSeconds int, revealSeconds int) uint64
source

Create opens a draw and returns its id. The organizer pays nothing: FairDrop never holds funds, it only records the draw.

func Draw

crossing Action
1func Draw(cur realm, eventID uint64)
source

Draw records the winners. It is permissionless on purpose: once the reveal window is over the result is already determined by public data, so anyone — entrant, organizer or passer-by — may pay the gas to write it down.

func Proof

Action
1func Proof(id uint64) string
source

Proof returns the draw's verifiable inputs as a JSON object, so an off-chain checker can recompute the seed and the winners from chain state without trusting this realm's pages. Every value is an address, a hex digest or a printable-ASCII secret, so the JSON needs no escaping.

func Register

crossing Action
1func Register(cur realm, eventID uint64, commit string, weight int)
source

Register seals a ticket: commit is the hex SHA-256 of the entrant's secret bound to their address, this event and their weight. Weight must be 1 unless the organizer vouched for more.

func Render

1func Render(path string) string
source

Render dispatches gnoweb paths:

Example
1""                      board home: open and past draws
2"event/<id>"            one draw, with the actions it accepts right now
3"event/<id>/verify"     the seed's inputs and how to recompute it
4"event/<id>/receipt/<rank>"
5"create"                how to open a draw

func Reveal

crossing Action
1func Reveal(cur realm, eventID uint64, secret string)
source

Reveal opens a seal. It is accepted only inside the reveal window and only when the secret re-hashes to the seal already on chain.

func Vouch

crossing Action
1func Vouch(cur realm, eventID uint64, who string, weight int)
source

Vouch grants an address extra ticket weight before it seals its ticket. One ticket per address is the floor; a vouch is how an organizer recognises a member who should carry more weight (a role holder, an allowlisted guest). Weight cannot be granted after the address has sealed, because the sealed digest commits to the weight.

Types 2

type Event

struct
 1type Event struct {
 2	ID           uint64
 3	Creator      address
 4	Title        string
 5	Prize        string
 6	Slots        int
 7	MaxWeight    uint64
 8	OpensAt      int64
 9	ClosesAt     int64
10	RevealEndsAt int64
11
12	// Roster holds the sealed tickets in canonical (ascending address) order;
13	// fairness.Insert maintains that order and refuses a second ticket per
14	// address. Secrets are filled in by Reveal and are public by design — they
15	// are what makes the seed checkable.
16	Roster []fairness.Ticket
17
18	// vouches are organizer-granted ticket weights, address string -> weight.
19	// A voucher must land before that address seals its ticket.
20	vouches map[string]uint64
21
22	Seed        string
23	DrawnAt     int64
24	DrawnHeight int64
25	Cancelled   bool
26}
source

Event is one draw.

Methods on Event

func AcceptedLeaves

method on Event
1func (e *Event) AcceptedLeaves() []string
source

AcceptedLeaves returns the seed inputs in fold order, for verification.

func Domain

method on Event
1func (e *Event) Domain() string
source

Domain is this event's seal domain. It is stamped into every seal, so a seal cannot be moved between events, and into the seed, so a seed cannot either.

func Entries

method on Event
1func (e *Event) Entries() int
source

Entries returns the number of sealed tickets.

func IDString

method on Event
1func (e *Event) IDString() string
source

IDString renders the event id.

func Phase

method on Event
1func (e *Event) Phase(now int64) string
source

Phase returns the lifecycle phase at the given unix time.

func Revealed

method on Event
1func (e *Event) Revealed() int
source

Revealed returns how many sealed tickets have been revealed.

func Winners

method on Event
1func (e *Event) Winners() []Winner
source

Winners returns the recorded winners in rank order.

type Winner

struct
1type Winner struct {
2	Rank    int
3	Entrant string
4	Weight  uint64
5	Commit  string
6	Secret  string
7}
source

Winner is one recorded winner, resolved from the roster at render time.

Dependencies

Source Files 3