Code has been added to clipboard!

Managing Solidity Votes

Example
function vote(uint proposal) public {
        Voter storage sender = voters[msg.sender];
        require(sender.weight != 0, "Cannot vote");
        require(!sender.voted, "Has voted.");
        sender.voted = true;
        sender.vote = proposal;
        proposals[proposal].voteCount += sender.weight;
    }