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:
Leave Solidity - Voting with a Smart Contract Part 1 to:
Read more #dunkpay posts
Best Posts From DunkPay.com
We have not curated any of bitcoinyo's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From DunkPay.com
- Solidity - Voting with a Smart Contract Part 1
- Solidity - 스마트컨트랙트로 투표 해보기 1편
- Solidity - Creating a slot machine (Odds game) using Smart Contract in Part 1.
- Solidity - 스마트컨트랙트를 이용한 슬롯머신(확률게임) 만들기 1편
- DunkPay - NBA 챔피언 결정전 이벤트 '3점슛 컨테스트'
- DunkPay - WordPress Free Shopping Mall For Cryptocurrency
- DunkPay - WordPress 암호화폐 무료 쇼핑몰 만들기
- DunkPay - The Cryptocurrency payment service is now completely free - XRP, DNK support
- DunkPay - 암호화폐 결제서비스 라이브러리 완전 무료화 - XRP, DNK 지원
- DunkPay - Cancel Etherium pending transaction