Built using FRAME, Substrate and Rust.
- A map of all the accounts that have been registered to vote.
pub type RegisteredAccounts<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, bool>;
- A value that increments with the number of proposals created. It holds the next available id.
pub type ProposalIndex<T: Config> = StorageValue<_, T::ProposalId, ValueQuery>;
- A map of all the proposals.
pub type ProposalPool<T> = StorageMap<_, Blake2_128Concat, T::ProposalId, Proposal<T>>;
- A map of the voting history of every account. It only keeps track for active proposals or if the user hasn't claimed back the tokens after a proposal has ended.
pub type VotingHistory<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, BoundedVec<UserVoteInfo<T>, T::MaxVotes>>;
- A root account registers voters.
- A registered voter makes a proposal.
- Voters vote on the proposal, locking a number of tokens based on their conviction, for a certain lock period.
- Anyone can try to end the vote at any time, but the vote will not be ended until after the lock period has pased.
The Quadratic Voting pallet handles the administration of voting mechanisms using a quadratic approach. There is one pool that the proposals are added into that the voter can choose to vote on. The proposals have a configurable duration that starts from the moment the proposal is created and is counted in block numbers. It has to be manually closed. The voters will vote in approval ("Aye") or rejection ("Nay"), choosing how many votes they want to add to their choice and locking the square of the votes as tokens. The voters have the chance to unlock their tokens after the proposal has been closed.
- Lock Period: A period of time after proposal enactment that the vote cannot be ended and the locked tockens cannot be redeemed.
- Conviction: An indication of a voter's strength of belief in their vote. An increase in conviction indicates that a token holder is willing to lock the square of their votes as tokens.
- Vote: A value that can either be in approval ("Aye") or rejection ("Nay") of a particular referendum.
- Proposal: A submission to the chain that represents an action that a proposer (either an account or an external origin) suggests that the system adopt.
These calls can be made from any externally held account capable of creating a signed extrinsic.
end_vote
- Will end the vote if the time allocation has expired.
These calls can only be made by an account that has been registered into the pool.
make_proposal
- Submits a proposal, represented as a hash.vote
- Votes for a proposal, either the vote is "Aye" to enact the proposal or "Nay" to keep the status quo. The number of votes scales quadratically with the tokens frozen as a deposit.claim_frozen_tokens
The voter can claim the frozen tokens used for a proposal, after the proposal ends.
These calls can only be made by a root account.
register_voters
- Registers an account into a pool of voters. Requires sudo.
- Implement a system to vote on more proposals at once.
- Make a certain majority of voters configurable (51% of registered voters for example).
- The freezing and unfreezing logic is not optimized for storage access.
Before you begin, you need to install the following tools:
Please first check the latest information on getting starting with Substrate dependencies required to build this project here.
To test while developing, without a full build (thus reduce time to results):
cargo t -p pallet-voting
Build the node without launching it, with release
optimizations:
cargo b -r
Build and launch the node, with release
optimizations:
cargo r -r -- --dev
Once the project has been built, the following command can be used to explore all CLI arguments and subcommands:
./target/release/node-template -h
QuadraVoice is an open-source project. We welcome contributions from the community. If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are welcome.
Please first check the latest information on getting starting with Substrate dependencies required to build this project here.
To test while developing, without a full build (thus reduce time to results):
cargo t -p pallet-voting
Build the node without launching it, with release
optimizations:
cargo b -r
Build and launch the node, with release
optimizations:
cargo r -r -- --dev
Once the project has been built, the following command can be used to explore all CLI arguments and subcommands:
./target/release/node-template -h