Skip to content

Governance calls reference

quan8 edited this page Jan 14, 2021 · 2 revisions

Governance contract calls reference

Place a vote

To make a proposal vote, the following parameters will be needed.

Parameters:

  1. Address of a voter which receives the delegation. If sender is a self-voter, then sender address should be used
  2. Proposal ID (number)
  3. An array of choices. Number of choices must be equal to the number of options. Index of a choice in the array corresponds to an index of option. Example: [0, 3, 4] represents "0 for option 0, 3 for option 1, 4 for option 2"

Make a vote from a self-voter:

gov.vote(voter, proposalID, choices, {from: voter});

Make a vote from a delegator:

gov.vote(delegatedTo, proposalID, choices, {from: voter});

Check out voting model for additional details.

Checks

  • Voter has a non-zero weight
  • Vote with a tuple {voter, delegatedTo, proposalID} must not already exist
  • Proposal isn't finalized
  • Proposal voting has started
  • Number of choices specified is equal to the number of options
  • Every opinion is smaller than a number of opinion scales for the proposal

Cancel a vote

To cancel a proposal vote, following parameters are required.

Parameters:

  1. Address of a voter to receive the delegation. If sender is a self-voter, then sender address should be used
  2. Proposal ID (number)

Cancel a vote from a self-voter:

gov.cancelVote(voter, proposalID, {from: voter});

Cancel a vote from a delegator:

gov.vote(delegatedTo, proposalID, {from: voter});

Checks

  • Vote with a tuple {voter, delegatedTo, proposalID} must exist
  • Proposal isn't finalized

Create a proposal

Create a proposal using a proposal contract.

User should deploy a proposal contract before calling the following method.

gov.createProposal(proposalContractAddress, {from: sender, value: proposalCreationFee});

After the call, proposal ID may be retrieved by calling gov.lastProposalID(). There might be multiple proposals deployed at the same time, thus double-check the proposal ID by comparing its parameters: gov.proposalParams(id).

On proposal submission, a fee of 100 FTMs is required. 50% of the proposal fee is burnt, 40% will be rewarded to a task handler, 10% will be rewarded to a task eraser.

Checks

  • Proposal parameters and proposal contract passed the verification
  • Proposal creation fee is equal to gov.proposalFee()

Cancel a proposal

One can cancel a proposal if it has no votes yet.

Cancellation call doesn't refund proposal fee.

Cancellation must be called by the proposal contract. Look up proposal cancellation interface of your proposal contract.

Checks

  • Proposal exists
  • Proposal isn't finalized
  • Proposal has no votes
  • Caller is the proposal contract