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

qvote/v0 package

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.

Functions

ClosePoll

func ClosePoll(cur realm, pollID string) string

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

Param

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/qvote/v0" -func "ClosePoll" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/qvote/v0" -func "ClosePoll" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

CreatePoll

func CreatePoll(cur realm, question string, optionsCSV string) string

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

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/qvote/v0" -func "CreatePoll" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/qvote/v0" -func "CreatePoll" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx
  

Render

func Render(path string) string

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

Param

Command

gnokey query vm/qeval -remote "http://127.0.0.1:26657" -data "gno.land/r/moul/x/daily/qvote/v0.Render()"

Result

Vote

func Vote(cur realm, pollID string, optionIdx int, delta int64) string

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.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/qvote/v0" -func "Vote" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/daily/qvote/v0" -func "Vote" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx