Skip to Content
Building Ethereum Dapps
book

Building Ethereum Dapps

by Roberto Infante
March 2019
Intermediate to advanced
504 pages
17h
English
Manning Publications
Content preview from Building Ethereum Dapps

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() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain Development with Hyperledger

Blockchain Development with Hyperledger

Salman A. Baset, Luc Desrosiers, Nitin Gaur, Petr Novotny
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781617295157Publisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link