Created
April 10, 2019 10:25
-
-
Save Maxcutex/9a9aab6e822fec8fa2453df4253a3e2c to your computer and use it in GitHub Desktop.
Election Project - Voting code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function vote (uint _candidateId) public { | |
// require that they haven't voted before | |
require(!voters[msg.sender]); | |
// require a valid candidate | |
require(_candidateId > 0 && _candidateId <= candidatesCount); | |
// record that voter has voted | |
voters[msg.sender] = true; | |
// update candidate vote Count | |
candidates[_candidateId].voteCount ++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment