Skip to content

Latest commit

 

History

History
172 lines (115 loc) · 2.86 KB

index.md

File metadata and controls

172 lines (115 loc) · 2.86 KB

Solidity API

Voting

winningProposalID

uint256 winningProposalID

the id of the proposal which obtained the maximal number of votes

Voter

struct Voter {
  bool isRegistered;
  bool hasVoted;
  uint256 votedProposalId;
}

Proposal

struct Proposal {
  string description;
  uint256 voteCount;
}

WorkflowStatus

enum WorkflowStatus {
  RegisteringVoters,
  ProposalsRegistrationStarted,
  ProposalsRegistrationEnded,
  VotingSessionStarted,
  VotingSessionEnded,
  VotesTallied
}

workflowStatus

enum Voting.WorkflowStatus workflowStatus

proposalsArray

struct Voting.Proposal[] proposalsArray

voters

mapping(address => struct Voting.Voter) voters

VoterRegistered

event VoterRegistered(address voterAddress)

WorkflowStatusChange

event WorkflowStatusChange(enum Voting.WorkflowStatus previousStatus, enum Voting.WorkflowStatus newStatus)

ProposalRegistered

event ProposalRegistered(uint256 proposalId)

Voted

event Voted(address voter, uint256 proposalId)

onlyVoters

modifier onlyVoters()

getVoter

function getVoter(address _addr) external view returns (struct Voting.Voter)

Get a voter from its address.

getOneProposal

function getOneProposal(uint256 _id) external view returns (struct Voting.Proposal)

Get a proposal from its id.

addVoter

function addVoter(address _addr) external

Allow an address to participate to the vote.

addProposal

function addProposal(string _desc) external

Proposals must have a non empty description and be submitted in the ProposalsRegistrationStarted status.

setVote

function setVote(uint256 _id) external

Vote for a proposition with its id. Require to be in the status VotingSessionStarted and can be done only once by voter.

startProposalsRegistering

function startProposalsRegistering() external

update the workflow status from RegisteringVoters to ProposalsRegistrationStarted

endProposalsRegistering

function endProposalsRegistering() external

update the workflow status from ProposalsRegistrationStarted to ProposalsRegistrationEnded

startVotingSession

function startVotingSession() external

update the workflow status from ProposalsRegistrationEnded to VotingSessionStarted

endVotingSession

function endVotingSession() external

update the workflow status from VotingSessionStarted to VotingSessionEnded

tallyVotes

function tallyVotes() external

update the winningProposalID with the most voted proposition and update the workflow status from VotingSessionEnded to VotesTallied