Governance Polaris β
The governance precompiled contract allows users to interact with Berachainβs on-chain governance system. The governance module enables the submission, voting, and management of proposals, which can be used to make decisions or changes to the blockchain's parameters, features, or other aspects. Users can submit proposals, vote on them, and cancel them if necessary.
Key features of the governance module include:
- Submitting proposals: Users can submit proposals to the governance module, which will be assigned a unique ID. Proposals can include various types of changes or decisions to be made by the community.
- Voting on proposals: Users can vote on proposals by selecting an option and providing optional metadata. Weighted voting is also supported, allowing users to vote on multiple options with different weights.
- Managing proposals: The governance module provides methods to retrieve information about proposals, such as their status, deposits, and tally results. Users can also view the votes associated with a proposal and filter proposals based on their status.
- Parameters: The governance module includes various parameters related to voting, deposits, and tallying, which can be retrieved and potentially updated through proposals.
- Events: The governance module emits events when proposals are submitted, voted on, or canceled, allowing external systems to track and react to governance actions.
By utilizing the Cosmos SDK governance module, users of Berachain can engage in a decentralized decision-making process.
Note: Link to existing contract ABI's can be found on Github here.
Interface of the governance module's precompiled contract
Functions β
submitProposal β
Use the codec to marshal the proposal messages.
Submit a proposal to the governance module.
function submitProposal(MsgSubmitProposal calldata proposal) external returns (uint64);
function submitProposal(MsgSubmitProposal calldata proposal) external returns (uint64);
Parameters
Name | Type | Description |
---|---|---|
proposal | MsgSubmitProposal | The proposal to submit. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint64 | The id of the proposal. |
cancelProposal β
Cancel a proposal.
function cancelProposal(uint64 proposalId) external returns (uint64, uint64);
function cancelProposal(uint64 proposalId) external returns (uint64, uint64);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal to cancel. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint64 | The time and block height the proposal was canceled. |
<none> | uint64 |
vote β
Vote on a proposal.
function vote(uint64 proposalId, int32 option, string memory metadata) external returns (bool);
function vote(uint64 proposalId, int32 option, string memory metadata) external returns (bool);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal to vote on. |
option | int32 | The option to vote on. |
metadata | string | The metadata to attach to the vote. |
voteWeighted β
Vote on a proposal with weights.
function voteWeighted(uint64 proposalId, WeightedVoteOption[] calldata options, string calldata metadata)
external
returns (bool);
function voteWeighted(uint64 proposalId, WeightedVoteOption[] calldata options, string calldata metadata)
external
returns (bool);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal to vote on. |
options | WeightedVoteOption[] | The options to vote on. |
metadata | string | The metadata to attach to the vote. |
getProposal β
Get the proposal with the given id.
function getProposal(uint64 proposalId) external view returns (Proposal memory);
function getProposal(uint64 proposalId) external view returns (Proposal memory);
getProposalDeposits β
Get the deposits of the proposal with the given id.
function getProposalDeposits(uint64 proposalId) external view returns (Cosmos.Coin[] memory);
function getProposalDeposits(uint64 proposalId) external view returns (Cosmos.Coin[] memory);
getProposalDepositsByDepositor β
Get the deposits of the proposal with the given id and depositor.
function getProposalDepositsByDepositor(uint64 proposalId, address depositor)
external
view
returns (Cosmos.Coin[] memory);
function getProposalDepositsByDepositor(uint64 proposalId, address depositor)
external
view
returns (Cosmos.Coin[] memory);
getProposals β
Accepts pagination request (empty == no pagination returned).
Get proposals with a given status.
function getProposals(int32 proposalStatus, Cosmos.PageRequest calldata pagination)
external
view
returns (Proposal[] memory, Cosmos.PageResponse memory);
function getProposals(int32 proposalStatus, Cosmos.PageRequest calldata pagination)
external
view
returns (Proposal[] memory, Cosmos.PageResponse memory);
Parameters
Name | Type | Description |
---|---|---|
proposalStatus | int32 | The status of the proposals to get. |
pagination | Cosmos.PageRequest |
getProposalTallyResult β
Get the proposal tally result for the given id.
function getProposalTallyResult(uint64 proposalId) external view returns (TallyResult memory);
function getProposalTallyResult(uint64 proposalId) external view returns (TallyResult memory);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal to get the tally result for. |
getProposalVotes β
Accepts pagination request.
Get the proposal votes with the given id.
function getProposalVotes(uint64 proposalId, Cosmos.PageRequest calldata pagination)
external
view
returns (Vote[] memory, Cosmos.PageResponse memory);
function getProposalVotes(uint64 proposalId, Cosmos.PageRequest calldata pagination)
external
view
returns (Vote[] memory, Cosmos.PageResponse memory);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal to get the votes for. |
pagination | Cosmos.PageRequest |
getProposalVotesByVoter β
Get the proposal vote information with the given id and voter.
function getProposalVotesByVoter(uint64 proposalId, address voter) external view returns (Vote memory);
function getProposalVotesByVoter(uint64 proposalId, address voter) external view returns (Vote memory);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal to get the vote info for. |
voter | address | The address of the voter to get the vote info for. |
getParams β
Get the governance module parameters.
function getParams() external view returns (Params memory);
function getParams() external view returns (Params memory);
getVotingParams β
Get the governance module voting parameters.
function getVotingParams() external view returns (VotingParams memory);
function getVotingParams() external view returns (VotingParams memory);
getDepositParams β
Get the governance module deposit parameters.
function getDepositParams() external view returns (DepositParams memory);
function getDepositParams() external view returns (DepositParams memory);
getTallyParams β
Get the governance module tally parameters.
function getTallyParams() external view returns (TallyParams memory);
function getTallyParams() external view returns (TallyParams memory);
getConstitution β
Get the constitution of the chain.
function getConstitution() external view returns (string memory);
function getConstitution() external view returns (string memory);
Events β
ProposalSubmitted β
Emitted by the governance precompile when submitProposal
is called.
event ProposalSubmitted(uint64 indexed proposalId, address indexed proposalSender);
event ProposalSubmitted(uint64 indexed proposalId, address indexed proposalSender);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal. |
proposalSender | address | The sender of the submit proposal. |
ProposalDeposit β
Emitted by the governance module when submitProposal
is called.
event ProposalDeposit(uint64 indexed proposalId, Cosmos.Coin[] amount);
event ProposalDeposit(uint64 indexed proposalId, Cosmos.Coin[] amount);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal. |
amount | Cosmos.Coin[] | The amount of the deposit. |
ProposalVoted β
Emitted by the governance precompile when a proposal is voted on.
event ProposalVoted(Vote proposalVote);
event ProposalVoted(Vote proposalVote);
Parameters
Name | Type | Description |
---|---|---|
proposalVote | Vote | The vote that was voted on for a proposal. |
CancelProposal β
Emitted by the governance module when cancelProposal
is called.
event CancelProposal(uint64 indexed proposalId, address indexed sender);
event CancelProposal(uint64 indexed proposalId, address indexed sender);
Parameters
Name | Type | Description |
---|---|---|
proposalId | uint64 | The id of the proposal. |
sender | address | The sender of the cancel proposal. |
Structs β
WeightedVoteOption β
Represents a governance module WeightedVoteOption
.
struct WeightedVoteOption {
int32 voteOption;
string weight;
}
struct WeightedVoteOption {
int32 voteOption;
string weight;
}
Vote β
Represents a governance module Vote
.
struct Vote {
uint64 proposalId;
address voter;
WeightedVoteOption[] options;
string metadata;
}
struct Vote {
uint64 proposalId;
address voter;
WeightedVoteOption[] options;
string metadata;
}
MsgSubmitProposal β
Represents a governance module MsgSubmitProposal
.
struct MsgSubmitProposal {
Cosmos.CodecAny[] messages;
Cosmos.Coin[] initialDeposit;
address proposer;
string metadata;
string title;
string summary;
bool expedited;
}
struct MsgSubmitProposal {
Cosmos.CodecAny[] messages;
Cosmos.Coin[] initialDeposit;
address proposer;
string metadata;
string title;
string summary;
bool expedited;
}
Proposal β
Represents a governance module Proposal
.
struct Proposal {
uint64 id;
Cosmos.CodecAny[] messages;
int32 status;
TallyResult finalTallyResult;
uint64 submitTime;
uint64 depositEndTime;
Cosmos.Coin[] totalDeposit;
uint64 votingStartTime;
uint64 votingEndTime;
string metadata;
string title;
string summary;
address proposer;
}
struct Proposal {
uint64 id;
Cosmos.CodecAny[] messages;
int32 status;
TallyResult finalTallyResult;
uint64 submitTime;
uint64 depositEndTime;
Cosmos.Coin[] totalDeposit;
uint64 votingStartTime;
uint64 votingEndTime;
string metadata;
string title;
string summary;
address proposer;
}
Params β
Represents the governance module's parameters.
struct Params {
Cosmos.Coin[] minDeposit;
uint64 maxDepositPeriod;
uint64 votingPeriod;
string quorum;
string threshold;
string vetoThreshold;
string minInitialDepositRatio;
string proposalCancelRatio;
string proposalCancelDest;
uint64 expeditedVotingPeriod;
string expeditedThreshold;
Cosmos.Coin[] expeditedMinDeposit;
bool burnVoteQuorum;
bool burnProposalDepositPrevote;
bool burnVoteVeto;
}
struct Params {
Cosmos.Coin[] minDeposit;
uint64 maxDepositPeriod;
uint64 votingPeriod;
string quorum;
string threshold;
string vetoThreshold;
string minInitialDepositRatio;
string proposalCancelRatio;
string proposalCancelDest;
uint64 expeditedVotingPeriod;
string expeditedThreshold;
Cosmos.Coin[] expeditedMinDeposit;
bool burnVoteQuorum;
bool burnProposalDepositPrevote;
bool burnVoteVeto;
}
VotingParams β
Represents the governance module's VotingParams
.
struct VotingParams {
uint64 votingPeriod;
}
struct VotingParams {
uint64 votingPeriod;
}
DepositParams β
Represents the governance module's DepositParams
.
struct DepositParams {
Cosmos.Coin[] minDeposit;
uint64 maxDepositPeriod;
}
struct DepositParams {
Cosmos.Coin[] minDeposit;
uint64 maxDepositPeriod;
}
TallyParams β
Represents the governance module's TallyParams
.
struct TallyParams {
string quorum;
string threshold;
string vetoThreshold;
}
struct TallyParams {
string quorum;
string threshold;
string vetoThreshold;
}
TallyResult β
Represents a governance module TallyResult
.
struct TallyResult {
string yesCount;
string abstainCount;
string noCount;
string noWithVetoCount;
}
struct TallyResult {
string yesCount;
string abstainCount;
string noCount;
string noWithVetoCount;
}