Governance Module (x/gov)
Overview
Thex/gov module enables Cosmos SDK-based blockchains to support an on-chain governance system where token holders can vote on proposals using a 1 token = 1 vote basis.
Purpose: Provide a democratic mechanism for protocol upgrades, parameter changes, and community decisions without requiring hard forks.
Key Features
- Proposal Submission: Users submit proposals with deposits
- Deposit Period: Collect minimum deposit to enter voting
- Voting: Token holders vote on active proposals
- Vote Inheritance: Delegators inherit validator votes
- Deposit Refunds: Refund or burn deposits based on proposal outcome
- Expedited Proposals: Fast-track proposals with higher thresholds
Concepts
Proposal Lifecycle
- Submission: Proposal submitted with initial deposit
- Deposit Period: Collect
MinDepositfrom community - Voting Period: Bonded token holders vote
- Execution: Passed proposals execute automatically
Proposal Types
Proposals contain executable messages:Vote Options
- Yes: Approve the proposal
- No: Reject the proposal
- NoWithVeto: Reject and penalize (burns deposits)
- Abstain: Acknowledge but remain neutral
Weighted Voting
Split voting power across multiple options:Expedited Proposals
- Shorter Voting Period: Reduced from 2 weeks to days
- Higher Threshold: 66.7% instead of 50%
- Auto-Convert: Falls back to regular if fails
State
Proposals
Storage:0x00 | proposalID -> ProtocolBuffer(Proposal)
Votes
Storage:0x01 | proposalID | voterAddr -> ProtocolBuffer(Vote)
Deposits
Storage:0x02 | proposalID | depositorAddr -> ProtocolBuffer(Deposit)
Parameters
Messages
MsgSubmitProposal
Submit a new governance proposal:MsgDeposit
Deposit tokens on a proposal:MsgVote
Vote on an active proposal:MsgVoteWeighted
Vote with split options:Tallying
Quorum
Minimum percentage of voting power that must vote:Threshold
MinimumYes votes (excluding Abstain):
Veto
MaximumNoWithVeto votes:
Proposal Passes If:
- Quorum is reached
Yes / (Yes + No + NoWithVeto)> ThresholdNoWithVeto / (Yes + No + NoWithVeto + Abstain)< VetoThreshold
Queries
Query Proposal
Query Proposals
Query Vote
Query Votes
Query Deposit
Query Deposits
Query Tally
Query Parameters
gRPC Endpoints
Proposal
Proposals
Vote
TallyResult
Events
Proposal Events
| Type | Attribute Key | Attribute Value |
|---|---|---|
| submit_proposal | proposal_id | |
| submit_proposal | proposal_type | |
| proposal_deposit | proposal_id | |
| proposal_deposit | amount |
Vote Events
| Type | Attribute Key | Attribute Value |
|---|---|---|
| proposal_vote | proposal_id | |
| proposal_vote | option |
Code Examples
Submit Proposal
Vote on Proposal
Weighted Vote
Query Tally
Custom Vote Calculation
Implement custom voting logic:CLI Commands Reference
| Command | Description |
|---|---|
simd query gov proposal [id] | Query proposal details |
simd query gov proposals | Query all proposals |
simd query gov vote [id] [voter] | Query vote |
simd query gov votes [id] | Query all votes |
simd query gov deposit [id] [depositor] | Query deposit |
simd query gov deposits [id] | Query all deposits |
simd query gov tally [id] | Query tally results |
simd query gov params | Query governance parameters |
simd tx gov submit-proposal | Submit proposal |
simd tx gov deposit [id] [amount] | Deposit on proposal |
simd tx gov vote [id] [option] | Vote on proposal |
simd tx gov weighted-vote [id] [options] | Weighted vote |