const HardMaxOptions, HardMaxElectorate, HardMaxBallots, HardMaxTextBytes
Hard bounds that no configuration may exceed.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package ballots is the Remix Lab public-ballot block: single-choice polls with fixed options, an electorate captured ...
Package ballots is the Remix Lab public-ballot block: single-choice polls with fixed options, an electorate captured at opening, one vote per eligible address, integer quorum and deterministic tie handling.
Lifecycle: Create (draft) -> Open (options, rules and electorate freeze; the deadline starts) -> Finalize (any caller, once the deadline passed). A draft can be cancelled, which removes it. Early closure of an open ballot is not supported. Deadlines are only evaluated when a transaction or read happens; nothing closes a ballot automatically.
MaxBallots bounds ballots that are not finalized (drafts and open ballots), so finalized history never blocks new ballots. Public ballots bound neither voters nor votes; each voter pays for their own vote's storage and nothing iterates over votes.
Like every Remix Lab block, a *Box must stay in an unexported host-realm variable. The host authenticates callers and passes their address; the Box never trusts an address it did not receive from the host.
Box holds a bounded set of ballots.
Active returns the number of drafts and open ballots.
Ballot implements core.BallotReader.
CancelDraft removes a ballot that was never opened. The host must have authorized the actor.
Config returns the box configuration.
Count returns the number of ballots, finalized ones included.
1func (b *Box) Create(creator address, title string, options []string, duration int64) (uint64, error)Create adds a draft ballot. Options are copied. creator must be the authenticated caller.
Creator returns the address that created ballot id.
Eligible reports whether voter belongs to an open ballot's electorate. It ignores the deadline and whether voter has already voted.
Finalize commits the result once the deadline has passed. Any caller may finalize; the outcome depends only on rules fixed at opening.
HasVoted reports whether voter has cast a ballot (including abstention).
InElectorate reports whether voter belongs to the ballot's frozen electorate (always true for public ballots once open).
List returns up to limit ballots, newest first.
OpenPublic opens a draft ballot to any address. Percentage quorum needs a known electorate, so public ballots require QuorumPercent == 0.
OpenWithElectorate opens a draft ballot restricted to voters. The list is copied; later membership changes do not affect this ballot.
Vote records voter's choice. voter must be the authenticated caller. Votes are final.
1type Config struct {
2 MaxBallots int // drafts plus open ballots at any one time
3 MaxOptions int
4 MaxElectorate int
5 QuorumPercent int // 0..100, of the captured electorate
6 AllowAbstain bool // voters may cast an explicit abstention
7 MinDuration int64 // seconds
8 MaxDuration int64 // seconds
9 MaxTitleBytes int
10 MaxOptionBytes int
11}Config is fixed at construction. Each ballot copies the rules it depends on when it is created, so they never change underneath an open ballot.