Skip to content

Instantly share code, notes, and snippets.

@Maxcutex
Created April 10, 2019 10:25
Show Gist options
  • Save Maxcutex/9a9aab6e822fec8fa2453df4253a3e2c to your computer and use it in GitHub Desktop.
Save Maxcutex/9a9aab6e822fec8fa2453df4253a3e2c to your computer and use it in GitHub Desktop.
Election Project - Voting code
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