Solidity - Voting with a Smart Contract Part 1
If you see news from around you, you'll see ads that you can vote with cryptocurrency.
To be used in voting , It should be easy for everyone to understand.
Can it be easily implemented?
As Korean election day is approaching, I have created a smart contract to vote.
https://ropsten.etherscan.io/address/0x6443e0136b122f2307db969d1adc939d3b14a57f#code
First, we elect two virtual candidates.
setCandidate(0,"Kim","Keep The Rule!");
setCandidate(1,"Lee","Be Free!");
Ms.Kim is a candidate who places importance on rules, Mr.Lee is a candidate who likes freedom.
for (uint i=0; i< 50; i++) {
uint8 randomNumber = random(i);
if(randomNumber > 0){
setVote(1, 1000 + i);
}else
{
setVote(0, 1000 + i);
}
}
I tried to vote for 50 times with random function and visualize the data.
https://www.dunkpay.com/vote-test/
When i use a random function, i can see that they get vote rating evenly.
After that, I thought about the case with the absent voters that did not like the two candidates.
setCandidate(2,"N/A","I HATE DHEM.");
Run the Smart Contract to add it.
I will take a new vote now to see if it works..
Press the button at the bottom to execute the contract.
setVote(2, 1111);
https://ropsten.etherscan.io/tx/0x509fff804b98a6db51af9709aeba1b4eb0fcf676a62c04d019deb6af80a912a1
After the voting contract has been executed, you can confirm that the voting data has been properly reflected in the 50th column.
I hope that this contract will actually be introduced so that candidates who do not make commitments can be excluded in real world.
Can I use it in the presidential election? Unfortunately, Solidity only accepts uploads less than 2 gigabytes per contract address. (There is room for improvement.)
In this example, it is possible that duplicate voting is allowed and that the voter's information is open to everyone and is an incomplete voting contract.
As always, I will try to improve the problem next time ~
Please vote for:
Congratulations @bitcoinyo! You received a personal award!
Click here to view your Board of Honor
Congratulations @bitcoinyo! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!