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 qvote is a quadratic-voting poll board, a Gno take on the classic Solidity "Ballot" voting contract with one ...

Readme View source

Quadratic Voting

⚠️ Experimental — generated with no human supervision by the daily MCP pipeline to exercise gno tooling. Not audited. See r/moul/x/daily.


A Gno port of the classic Solidity 'Ballot' voting contract, but swapping one-address-one-vote for quadratic voting: every address gets a fixed 100-credit budget per poll, and stacking N votes on one option costs N^2 credits, so spreading conviction is cheap but dominating one option gets steep fast. Create a poll with CreatePoll, spend (or refund) credits with Vote(pollID, optionIdx, delta), and the creator ends it with ClosePoll. Render shows the poll board, per-poll results, and any voter's standing.

Built for sapphire (gno 0.9). Live demo (agent address): https://sapphire.testnets.gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/qvote


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/qvote/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 qvote is a quadratic-voting poll board, a Gno take on the classic Solidity "Ballot" voting contract with one twist borrowed from mechanism design instead of one-address-one-vote: every voter gets a fixed voice- credit budget per poll, and piling votes onto a single option costs the square of how many votes they stack there. Buying your 1st vote on an option costs 1 credit, the 2nd costs 3 more (4 total), the 3rd costs 5 more (9 total) -- so spreading conviction across options is cheap, but dominating one option gets expensive fast. Votes can also be pulled back for a matching credit refund.

Constants 1

const InitialCredits

1const InitialCredits int64 = 100
source

InitialCredits is the fixed voice-credit budget every address gets to spend on each poll (shared across all of that poll's options).

Functions 4

func ClosePoll

crossing Action
1func ClosePoll(cur realm, pollID string) string
source

ClosePoll ends voting on a poll. Only its creator may close it.

func CreatePoll

crossing Action
1func CreatePoll(cur realm, question string, optionsCSV string) string
source

CreatePoll opens a new poll with the given question and comma-separated options (at least 2, at most 8), returning its ID.

func Render

1func Render(path string) string
source

Render shows the poll board at "", one poll's results at "<pollID>", or one voter's standing in a poll at "<pollID>/<addr>".

func Vote

crossing Action
1func Vote(cur realm, pollID string, optionIdx int, delta int64) string
source

Vote adjusts the caller's votes on one option of a poll by delta (positive to buy more, negative to sell some back for a credit refund). The credit cost of holding N votes on an option is N*N, taken from the caller's fixed per-poll budget of InitialCredits.

Imports 5

Source Files 3