This is a minimal implementation of single-transferable voting (STV), a rank-order voting system aiming to be fairer than the traditional first-past-the-post voting system.
The advantages of STV are manyfold:
- It can be used for both single-winner (instant-runoff) or multi-winner elections,
- It minimizes "wasted" votes, since your vote can be transferred to another candidate you've ranked if your preferred candidate is either eliminated or elected,
- By minimizing wasted votes, it disincentives strategic voting, thus encouraging voters to state their actual preferences,
- In a multi-winner election, the use of a quota in STV ensures that the proportion of winners roughly mirrors the proportion of votes.
For more detailed information see the following wikipedia articles:
- Single transferable vote
- Counting single transferable votes
- Ranked voting
- Instant-runoff voting
- First-past-the-post
This project was built using Foundry.
To run tests, call forge test
.
Gas cost is very high for submitting a vote.
The tiebreaking process in each round of counting involves a three-step procedure.
- Initially, it considers who had the most (or least) first-rank votes in the initial tally.
- Next, it evaluates who had the most (or least) votes in the most recent tally before the current tie.
- Finally, it considers which proposal was submitted first (or last) by the vote's owner.
This last step should be replaced with a random number generator (RNG) function for improved fairness. Additionally, we can use all tallies in chronological order rather than just the first and last tallies.
If for whatever reason, not enough candidates surpass the quota to be elected, the program will not warn you in advance, and will instead close the vote and only return the number of candidates that surpassed the quota. This situation should only occur in when there are very few votes.
Currently, the implementation only supports the Droop quota method for calculating the required votes for a candidate to be elected. Future versions may include alternative quota calculation methods.