Advanced PLCR Voting Checkpoint

Introduced in

3.1.0

Contract name

AdvancedPLCRVotingCheckpoint.sol

Module Type

Checkpoint Module

Compatible Protocol Version

^3.0.0

How it works

This module is useful for the corporate voting where the issuer or board members can propose an agenda to get the opinion of the investors over it. Issuer/ADMIN personnel can create a ballot which consists a proposal title and choices on which investors/participant can vote on it, once the voting period ends result can be calculated on the basis of the vote given by the participants. This module uses a partial confidentiality vote mechanism where participant votes will be encrypted until the voting period ends and reveal phase begins, this mechanism will avoid the vote biasness and lead the fair voting for a given proposal.

This module supports two types of ballots namely - Statutory - This type of ballot will only consist of a single proposal. Cumulative - This type of ballot will consist of one or more proposals.

There are two types of the proposal supported by the module namely -

  • Nay/Yay type proposal.

  • Multiple choices proposal.

Key functionalities (as defined in the Smart Contract)

Initialization

This module is initialized with no parameters. That means during the creation of this contract there’s no need to call any type of configure() function.

Using the module

Layout for voting lifecycle

UseCase: Issuer wants to create a cumulative ballot with 3 proposals. We have 4 ways to create a cumulative ballot -

  1. createCustomCumulativeBallotWithExemption()

  2. createCustomCumulativeBallot()

  3. createCumulativeBallot()

  4. createCumulativeBallotWithExemption()

An issuer can choose anyone as per the need, for simplicity, we are going to use createCumulativeBallot() function with parameter values as follows -

The above function will create a ballot and all investors on the current checkpoint will only be eligible participants (If global exemption list has no addresses) to vote for the created ballot. As _startTime is now then commit phase will be started until _startTime + _commitDuration.

Let’s say we have 3 voters Alice, Bob & Charlie on the current checkpoint and all three are eligible to vote.

Alice call commitVote()

If Alice balance at the current checkpoint is 100 then Alice vote power will be 100 * no of proposals in a ballot i.e 300 (100 * 3). web3.soliditySha3(100,0,0,0,150,0,0,0,50,0,salt) where salt will be a random string used to increase the anonymity. And the sum of weight should be equal to 300.

Similarly, Bob will call commitVote() while Charlie forgot to commit its vote. Commit duration gets passed and reveal phase get started automatically.

Alice call revealVote()

If everything validates transaction will pass through and Alice vote will be counted in the result calculation.

Charlie call revealVote()

This transaction will fail as charlie did not commit his vote in the commit phase. After the end of the reveal phase, anyone can call getBallotResults() to get the result of the voting.

Creation of Ballot

A ballot can be created with 4 ways and this module is supporting 2 types of ballots i.e statutory & cumulative. It means issuer/Admin personnel has total 8 functions to create the ballot as per the desired functionality.

Create a statutory ballot

A simple way of creating a ballot which will take current checkpoint Id of the security token automatically and allowed single proposal in a given ballot.

Restrictions applied -

  • Ballots array length should be less than to the MAX_LIMIT of ballots allowed.

  • The name should not be empty.

  • Proposal title should not be empty.

  • Commit and reveal duration should be greater than 0.

  • Sufficient usage fee is allowed by the ST to successfully create a ballot.

Note - If _noOfChoices is 0 then smart contract will assume that proposal is Nay/yay type proposal and it will have 3 choices.

Create a custom statutory ballot

The only difference between createStatutoryBallot() and this function is that Issuer has to provide the checkpoint Id (should be less than or equal to current checkpoint Id) at which ballot will be created beside this it works similar to createStatutoryBallot().

Note - Similar restrictions applied as above

Create statutory ballot with exemption

Additional list of exemption addresses will be passed in this function rest it works same as createStatutoryBallot().

Note - Similar restrictions applied as above.

Create custom statutory ballot with exemption

Additional list of exemption addresses will be passed in this function rest it works same as createCustomStatutoryBallot().

Note - Similar restrictions applied as above.

Create a cumulative ballot

This function will allow creating multiple proposal in a ballot.

Restrictions applied -

  • Ballots array length should be less than to the MAX_LIMIT of ballots allowed.

  • Name should not be empty.

  • Proposal title should not be empty.

  • Commit and reveal duration should be greater than 0.

  • Sufficient usage fee is allowed by the ST to successfully create a ballot.

  • Length of _details and _noOfChoices should be equal.

Note- We are not storing the _choices, _proposalTitles in the contract storage, These variables will only be emitted in an event for off-chain use.

Create Custom cumulative ballot

The only difference between createCumulativeBallot() and this function is Issuer has to provide the checkpoint Id (should be less than or equal to current checkpoint Id) at which ballot will be created beside this it works similar to createCumulativeBallot().

Note - Restrictions are same as above.

Create cumulative ballot with exemption

Additional list of exemption addresses will be passed in this function rest it works the same as createCumulativeBallot().

Note - Similar restrictions applied as above

Create custom cumulative ballot with exemption

Additional list of exemption addresses will be passed in this function rest it works the same as createCustomCumulativeBallot().

Note - Similar restrictions applied as above

Commit vote

commitVote() function is used to commit the vote of the investor.

Restrictions applied

  • Given ballot Id should be less than ballots array length.

  • _secretVote should not be 0x0.

  • Ballot stage should be commit stage.

  • msg.sender should be allowed voter.

  • msg.sender should not vote already.

  • Ballot should not be cancelled ballot.

  • msg.sender balance at the ballot checkpoint should be greater than 0.

Reveal Vote

revealVote() function is used to reveal the vote of an investor.

Restrictions applied

  • Given ballot Id should be less than ballots array length.

  • Ballot stage should be reveal stage.

  • Ballot should not be cancelled ballot.

  • msg.sender should participate in the commit phase.

  • _choices length should be equal to total choice count of all proposals of a ballot.

  • Stored secret vote should be equal to the dynamically created secret vote by the input values.

  • Total choices weight should be less than or equal to the vote power of the voter.

Cancel Ballot

This function is used to turn off the ballot.

Restrictions applied

  • Given ballot Id should be less than ballots array length.

  • Should not be already ended ballot.

  • The ballot should not be already cancelled.

Change Exemptions List

In this module, the exemption list exists on the two-level i.e local and global. Local-level applies to a given ballot while global level exemption list applies to all ballots.

Change ballot exemption list

This function is used to change the ballot exemption list on the local level.

Restrictions applied

  • Ballot stage should be PREP.

  • _exemptedAddress should not be 0x0.

  • _exempt value should not be same as already stored value.

Change ballot exemption list multi

This function is the batch version of the changeBallotExemptionVotersList()

Note - It has similar restrictions as above.

Change default exemption voters list

This function will work on the global level

Restrictions applied

  • Any ballot should not be in the running stage (or not in commit & reveal phase).

  • _voter should not be empty.

Change default exemption voters list multi

Batch version of the changeDefaultExemptedVotersList().

Note - It has similar restrictions as above.

Getters

Get checkpoint data

Retrieves the list of investors and their balances.

Get pending investors to vote

Retrieves the list of investors who remain to vote for a given ballot id.

Get committed vote count for a given ballot id

Returns the committed vote count for a given ballot id.

Get allowed voters of a given ballot

It returns allowed voters for a given ballot

Get all ballots data

Returns all ballot data (Should be called offchain).

Get exempted voters as per the given ballot id -

Get the list of pending ballots

Provide the list of the ballot in which given address is eligible for a vote

Get the ballot stage

It returns the current ballot stage of given ballot id.

Get vote token count

Get the voting power for a voter in terms of the token.

Get ballot results

It will return the result of a given ballotId.

Get ballot details

It returns the details of the ballot.

Get the ballots array length

Returns the length of ballot array.

Function to check whether the voter is allowed or not

Last updated

Was this helpful?