- Smart Contract
- React
- Truffle
- Ganache
- Metamask
- Roptsten
- Remix
Voting is one of the most popular example to illustrate the potentials of Blockchain and Smart Contracts. Voting is a use case that is well aligned to the unique propositions of Blockchain technology.
According to the Equal Justice Foundation, the 6 principles of voting are as follows.
- Secret Ballot: Your vote is secret. Nobody should be able to link your vote back to your race, gender, age and personal profile.
- One man, one vote: Every voter votes once and the voting system must be able to reconcile the total number of votes to the total number of voters and those who did not vote.
- Voter eligibility: Only eligible voters are allowed to vote.
- Transparency: The vote counting process is fixed, rules are well established,known to voters and withstands public scrutiny.
- Votes accurately recorded and counted: Vote counting is consistent. Rules are cast in stone. Vote counts are audit-able.
- Reliability: Voting system must be accurate and verifiable. Safeguards are in place to prevent frauds, accidents and security breeches.
This application is covers all these principles. It is fully a Web3.0 Application where anyone can create a Poll or Voting and share contract address
with others.
In the ballot contract, only wallet addresses and names are recorded. Every voter is identified by their MetaMask wallet address. Other than the manager who was the person who created the new instance of the ballot contract, no one else can tell who voted yes or no. For the technical folks among us, I meant to say that the votes array is declared private so no one can read the contents of the votes array.
The voters array stores a list of voters who have voted. It ensures that no one can vote the second time. Once a voter votes, his status changes to “voted” and the ballot contract checks to ensure that he does not vote again.
Voter eligibility is determined by assembling a voters’ array of wallet address before voting begins. You need to vote with your MetaMask Wallet whose address matches the one that the manager registers before voting begins.
This is one of the things that Blockchain does extremely well. Every action taken and every record etched on the Blockchain is immutable. On a public Blockchain, collusion is close to impossible as described here.
In the ballot smart contract, the ballot goes through several states, from the point it is created, open for voting to the point where ballot is closed and votes are counted.
There is no single point of failure on a Blockchain as every node in the chain participates in keeping the Blockchain running.
-
Home Page This is the landing page of the application. At the left top corner, you can see a hamburger icon which is used to open menu.
-
Create Ballot This asks for the Ballot name and proposal of voting. Once you fill in the form, you need to deploy your contract. The app will open up your MetaMask.
Once you complete the transaction, you will get toast as well as more fields to fill in.
You need to add multiple choices and also need to add voters. Only added voters can vote. Once choices and voters are filled in,
Start Voting
button gets activated. After adding choices and voters, you can see the screen like this.Once you click on
Start Voting
, it can't be modified. -
Voting Page If you're the creator, you can't vote. You will get option to end vote.
You require a
contract address
to access the voting as well as you need to be added as Voters by the Voting creator. Once you fill in the contract address and click onGet Ballot
, you will get option to vote, if you already haven't voted.Once you vote, you can't revert and vote again. You can still come and see how many have voted.
Manager can see how many have voted and end the voting at any time.
-
Result Page If voting's ended, you can go to result page and see the result. You need to pass contract address.
You need to click on
Get Result
to get the final result.