March 2019
Intermediate to advanced
504 pages
17h
English
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() ...