# 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](https://github.com/moul/gno-contracts/blob/main/r/moul/x/daily/README.md)
---
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
```sh
# create a poll (returns its id, e.g. 0)
gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/polls" \
-func CreatePoll -args "Best L1 for smart contracts?" -args "gno,eth,sol" \
-gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid sapphire-1 mykey
# vote for option index 0 on poll 0
gnokey maketx call -pkgpath "gno.land/r/REPLACE_ADDR/polls" \
-func Vote -args 0 -args 0 \
-gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid sapphire-1 mykey
# view results in gnoweb
# https://gno.land/r/REPLACE_ADDR/polls
# https://gno.land/r/REPLACE_ADDR/polls:0
```
## Testing
```sh
gno test .
```
<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->
---
Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
**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](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).
<!-- END GNOCONTRACTS FOOTER -->
CreatePoll(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, question string, options string) int
PollCount() int
Render(path string) string
Vote(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, pollID int, optionIndex int)
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.