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

README.md

2.80 Kb · 75 lines

Polls & Voting

⚠️ Experimental — generated with no human supervision. This realm was produced automatically by an MCP-driven agent to exercise the gno MCP server and tooling, and to generate test content for gno compilers, linters and formatters. Not audited. Not for production. Full context & folder README: r/moul/x/daily


An on-chain poll and voting realm for gno.land (sapphire, gno 0.9). Anyone can create a poll with a question and a comma-separated set of options; every caller address may cast exactly one vote per poll. The realm's Render page lists each poll with its options, live tallies drawn as ▓░ bar charts, per-option percentages, and the total number of votes.

Realm path

gno.land/r/REPLACE_ADDR/polls

Exported transactions

  • CreatePoll(question string, options string) int — create a poll. options is a comma-separated list (blank entries are dropped; at least 2 required). Returns the new poll's id.
  • Vote(pollID int, optionIndex int) — cast one vote for optionIndex on poll pollID. One vote per caller address per poll; a second vote aborts.

Both are gno 0.9 crossing functions (first parameter cur realm); the caller address is read via runtime.PreviousRealm().Address().

Read path

  • Render("") — index of all polls with bar-chart tallies.
  • Render("<id>") — a single poll by id.

Example calls

 1# create a poll (returns its id, e.g. 0)
 2gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/polls" \
 3  -func CreatePoll -args "Best L1 for smart contracts?" -args "gno,eth,sol" \
 4  -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid sapphire-1 mykey
 5
 6# vote for option index 0 on poll 0
 7gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/polls" \
 8  -func Vote -args 0 -args 0 \
 9  -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid sapphire-1 mykey
10
11# view results in gnoweb
12#   https://gno.land/r/REPLACE_ADDR/polls
13#   https://gno.land/r/REPLACE_ADDR/polls:0

Testing

1gno test .

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/polls/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.