Skip to content

Instantly share code, notes, and snippets.

@atvanguard
Last active November 3, 2018 18:33
Show Gist options
  • Save atvanguard/05aaba1da62503a427021d40f35e62e1 to your computer and use it in GitHub Desktop.
Save atvanguard/05aaba1da62503a427021d40f35e62e1 to your computer and use it in GitHub Desktop.
contract LiquidDemocracy {
enum State {Invalid, Created, Voted, Delegated}
struct Proposal {
string description;
uint numVotes;
}
Proposal[] public proposals;
address[] validVoters;
struct Voter {
uint vote; // index of the proposal voted for in proposals[]
uint delegatedTo; // index of the fellow voter in validVoters[], the vote has been delegated to
uint index; // index of the this voter in validVoters[]
State state;
}
mapping(address => Voter) public voters;
function addVoter(address voter) public {
voters[voter] = Voter(0, 0, validVoters.length, State.Created);
validVoters.push(voter);
}
function newProposal(string description) public {
proposals.push(Proposal(description, 0));
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment