Skip to content

Governance Polaris ​

Git Source

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.

solidity
function submitProposal(MsgSubmitProposal calldata proposal) external returns (uint64);
function submitProposal(MsgSubmitProposal calldata proposal) external returns (uint64);

Parameters

NameTypeDescription
proposalMsgSubmitProposalThe proposal to submit.

Returns

NameTypeDescription
<none>uint64The id of the proposal.

cancelProposal ​

Cancel a proposal.

solidity
function cancelProposal(uint64 proposalId) external returns (uint64, uint64);
function cancelProposal(uint64 proposalId) external returns (uint64, uint64);

Parameters

NameTypeDescription
proposalIduint64The id of the proposal to cancel.

Returns

NameTypeDescription
<none>uint64The time and block height the proposal was canceled.
<none>uint64

vote ​

Vote on a proposal.

solidity
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

NameTypeDescription
proposalIduint64The id of the proposal to vote on.
optionint32The option to vote on.
metadatastringThe metadata to attach to the vote.

voteWeighted ​

Vote on a proposal with weights.

solidity
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

NameTypeDescription
proposalIduint64The id of the proposal to vote on.
optionsWeightedVoteOption[]The options to vote on.
metadatastringThe metadata to attach to the vote.

getProposal ​

Get the proposal with the given id.

solidity
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.

solidity
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.

solidity
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.

solidity
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

NameTypeDescription
proposalStatusint32The status of the proposals to get.
paginationCosmos.PageRequest

getProposalTallyResult ​

Get the proposal tally result for the given id.

solidity
function getProposalTallyResult(uint64 proposalId) external view returns (TallyResult memory);
function getProposalTallyResult(uint64 proposalId) external view returns (TallyResult memory);

Parameters

NameTypeDescription
proposalIduint64The id of the proposal to get the tally result for.

getProposalVotes ​

Accepts pagination request.

Get the proposal votes with the given id.

solidity
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

NameTypeDescription
proposalIduint64The id of the proposal to get the votes for.
paginationCosmos.PageRequest

getProposalVotesByVoter ​

Get the proposal vote information with the given id and voter.

solidity
function getProposalVotesByVoter(uint64 proposalId, address voter) external view returns (Vote memory);
function getProposalVotesByVoter(uint64 proposalId, address voter) external view returns (Vote memory);

Parameters

NameTypeDescription
proposalIduint64The id of the proposal to get the vote info for.
voteraddressThe address of the voter to get the vote info for.

getParams ​

Get the governance module parameters.

solidity
function getParams() external view returns (Params memory);
function getParams() external view returns (Params memory);

getVotingParams ​

Get the governance module voting parameters.

solidity
function getVotingParams() external view returns (VotingParams memory);
function getVotingParams() external view returns (VotingParams memory);

getDepositParams ​

Get the governance module deposit parameters.

solidity
function getDepositParams() external view returns (DepositParams memory);
function getDepositParams() external view returns (DepositParams memory);

getTallyParams ​

Get the governance module tally parameters.

solidity
function getTallyParams() external view returns (TallyParams memory);
function getTallyParams() external view returns (TallyParams memory);

getConstitution ​

Get the constitution of the chain.

solidity
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.

solidity
event ProposalSubmitted(uint64 indexed proposalId, address indexed proposalSender);
event ProposalSubmitted(uint64 indexed proposalId, address indexed proposalSender);

Parameters

NameTypeDescription
proposalIduint64The id of the proposal.
proposalSenderaddressThe sender of the submit proposal.

ProposalDeposit ​

Emitted by the governance module when submitProposal is called.

solidity
event ProposalDeposit(uint64 indexed proposalId, Cosmos.Coin[] amount);
event ProposalDeposit(uint64 indexed proposalId, Cosmos.Coin[] amount);

Parameters

NameTypeDescription
proposalIduint64The id of the proposal.
amountCosmos.Coin[]The amount of the deposit.

ProposalVoted ​

Emitted by the governance precompile when a proposal is voted on.

solidity
event ProposalVoted(Vote proposalVote);
event ProposalVoted(Vote proposalVote);

Parameters

NameTypeDescription
proposalVoteVoteThe vote that was voted on for a proposal.

CancelProposal ​

Emitted by the governance module when cancelProposal is called.

solidity
event CancelProposal(uint64 indexed proposalId, address indexed sender);
event CancelProposal(uint64 indexed proposalId, address indexed sender);

Parameters

NameTypeDescription
proposalIduint64The id of the proposal.
senderaddressThe sender of the cancel proposal.

Structs ​

WeightedVoteOption ​

Represents a governance module WeightedVoteOption.

solidity
struct WeightedVoteOption {
    int32 voteOption;
    string weight;
}
struct WeightedVoteOption {
    int32 voteOption;
    string weight;
}

Vote ​

Represents a governance module Vote.

solidity
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.

solidity
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.

solidity
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.

solidity
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.

solidity
struct VotingParams {
    uint64 votingPeriod;
}
struct VotingParams {
    uint64 votingPeriod;
}

DepositParams ​

Represents the governance module's DepositParams.

solidity
struct DepositParams {
    Cosmos.Coin[] minDeposit;
    uint64 maxDepositPeriod;
}
struct DepositParams {
    Cosmos.Coin[] minDeposit;
    uint64 maxDepositPeriod;
}

TallyParams ​

Represents the governance module's TallyParams.

solidity
struct TallyParams {
    string quorum;
    string threshold;
    string vetoThreshold;
}
struct TallyParams {
    string quorum;
    string threshold;
    string vetoThreshold;
}

TallyResult ​

Represents a governance module TallyResult.

solidity
struct TallyResult {
    string yesCount;
    string abstainCount;
    string noCount;
    string noWithVetoCount;
}
struct TallyResult {
    string yesCount;
    string abstainCount;
    string noCount;
    string noWithVetoCount;
}