Appendix D. impleVoting contract
Listing D.1. SimpleVoting.sol: full voting contract
pragma solidity ^0.4.22; contract SimpleVoting { struct Voter { bool isRegistered; bool hasVoted; uint votedProposalId; } struct Proposal { string description; uint voteCount; } enum WorkflowStatus { RegisteringVoters, ProposalsRegistrationStarted, ProposalsRegistrationEnded, VotingSessionStarted, VotingSessionEnded, VotesTallied } WorkflowStatus public workflowStatus; address public administrator; mapping(address => Voter) public voters; Proposal[] public proposals; uint private winningProposalId; modifier onlyAdministrator() { require(msg.sender == administrator, "the caller of this function must be the administrator"); _; } modifier onlyRegisteredVoter() ...
Get Building Ethereum Dapps now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.