Skip to content

Add on-chain holder governance poll so creators can collect weighted votes from their community #520

Description

@Chucks1093

Summary

Creators need a way to ask their community a question and get a verifiable on-chain result. A governance poll lets a creator post a question with up to four options. Key holders vote, weighted by their liquid key balance at the time of voting. The result is readable from the contract so anyone can verify the outcome without trusting the creator or the client.

Scope

  • Add create_poll(creator_id, question: String, options: Vec<String>, duration_ledgers: u32) -> u32 callable only by the creator
    • Returns a poll_id
    • Maximum 4 options, minimum 2
    • question max 280 characters
    • Each option max 100 characters
    • Poll expires at current_ledger + duration_ledgers
  • Add cast_vote(creator_id, poll_id, option_index: u32) callable by any key holder
    • Vote weight equals the caller's liquid key balance at the time of voting
    • Each wallet can vote once per poll — subsequent vote calls update the vote (change of mind allowed before expiry)
    • Reverts with PollExpired after expiry
    • Reverts with NotAHolder if liquid balance is zero
  • Add get_poll_result(creator_id, poll_id) -> PollResult view returning: { question, options, vote_counts: Vec<u32>, total_weight, expired }

Acceptance Criteria

  • Poll created by creator, rejects non-creator caller
  • Holder can vote; weight equals liquid balance
  • Changing vote before expiry updates the tally correctly
  • Vote after expiry reverts with PollExpired
  • Non-holder vote reverts with NotAHolder
  • get_poll_result returns correct weighted vote counts
  • Invalid option index reverts at vote time

ETA: 24 hours


Coordinate on Telegram

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions