Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 source realm

Package lottery is an idiomatic gno.land port of the classic Solidity Lottery contract. Players Enter the current rou...

Readme View source

Lottery

⚠️ Experimental — generated with no human supervision by the daily MCP pipeline (Solidity→Gno port). Not audited. See r/moul/x/daily.


An idiomatic gno.land port of the classic Solidity Lottery contract.

Players Enter the current round (one entry per address per round — a second entry panics). Once a round has at least two entrants, anyone may DrawWinner, which picks a winner deterministically from the block height (ChainHeight() % len(entrants) over the deterministically-sorted entrant set), records it in the winners history, and opens a fresh round. Solidity's block.number-based pseudo-randomness maps to runtime.ChainHeight(), and msg.sender maps to unsafe.PreviousRealm().Address(). Render shows the open round, its entrants, and the table of past winners.

Example calls

# Two different accounts join round 1
gnokey maketx call -pkgpath gno.land/r/moul/x/daily/lottery/v0 -func Enter ...   # from alice
gnokey maketx call -pkgpath gno.land/r/moul/x/daily/lottery/v0 -func Enter ...   # from bob

# Anyone draws the winner and opens round 2
gnokey maketx call -pkgpath gno.land/r/moul/x/daily/lottery/v0 -func DrawWinner ...

Read-only helpers: CurrentRound(), NumEntrants(), HasEntered(addr).


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/r/moul/x/daily/lottery/v0 dependency graph

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

Package lottery is an idiomatic gno.land port of the classic Solidity Lottery contract. Players Enter the current round (one entry per address per round). Once a round has at least two entrants, anyone may DrawWinner: a winner is picked deterministically from the block height (ChainHeight() % len(entrants), over the deterministically-sorted entrant set), recorded in the winners history, and a fresh round is opened.

There is no real randomness on-chain, so "random" selection is derived from the block height — the same source Solidity ports use via block.number.

Functions 5

func Enter

crossing Action
1func Enter(cur realm)
source

Enter adds the caller to the current round's entrants. Each address may only enter a given round once; a duplicate entry panics.

func HasEntered

Action
1func HasEntered(addr address) bool
source

HasEntered reports whether addr is in the current round.

func NumEntrants

Action
1func NumEntrants() int
source

NumEntrants returns how many players have entered the current round.

func Render

1func Render(path string) string
source

Render shows the current round, its entrants, and the winners history.

Imports 6

Source Files 3