Delegated voting over five proposals, with the chairperson handing out voting rights
Context
Deployed in September 2015 on the Frontier chain, compiled with solc v0.1.1 and the optimiser enabled.
Key Facts
Description
A voting contract in the pre-struct form of the Solidity Ballot example, where each part of a voter's record lives in its own mapping: voterWeight, voted, votes and delegations. The account that deploys it becomes the chairperson and is the only one who may call giveRightToVote. A voter may either vote for one of five proposals or delegate to another address, in which case the contract follows the delegation chain to its end before transferring the weight. winningProposal scans the tallies and returns the leader. The proposal count is fixed at five in the constructor.
Source Verified
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
contract Ballot {
address public chairperson;
uint8 public numProposals;
mapping(address => uint) public voterWeight;
mapping(address => bool) public voted;
mapping(address => uint8) public votes;
mapping(address => address) public delegations;
mapping(uint8 => uint) public voteCounts;
function Ballot() {
chairperson = msg.sender;
numProposals = 5;
}
function giveRightToVote(address voter) {
if (msg.sender != chairperson || voted[voter]) return;
voterWeight[voter] = 1;
}
function delegate(address to) {
address sender = msg.sender;
if (voted[sender]) return;
while (delegations[to] != address(0) && delegations[to] != sender)
to = delegations[to];
if (to == sender) return;
voted[sender] = true;
delegations[sender] = to;
if (voted[to])
voteCounts[votes[to]] += voterWeight[sender];
else
voterWeight[to] += voterWeight[sender];
}
function vote(uint8 toProposal) {
address sender = msg.sender;
if (voted[sender] || toProposal >= numProposals) return;
voted[sender] = true;
votes[sender] = toProposal;
voteCounts[toProposal] += voterWeight[sender];
}
function winningProposal() constant returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0;
for (uint8 prop = 0; prop < numProposals; prop++)
if (voteCounts[prop] > winningVoteCount) {
winningVoteCount = voteCounts[prop];
_winningProposal = prop;
}
}
}External Links
Related contracts
Coin
Same deployerThe Solidity tutorial subcurrency, deployed unaltered
0x6e165a...d9df4eSeptember 25, 2015MessageStore
Same eraA 6-line contract storing a single public string, deployed Day 9 of Ethereum by a prolific early experimenter who shipped 18 contracts in one week.
0xd2eccd...ff3d6bAugust 8, 2015Contract 0xa85146...9bbf06
Same erago-ethereum's built-in hash registrar, mapping a key to a content hash
0xa85146...9bbf06August 10, 2015Ballot
Same eraDelegated voting with a proposal count fixed at deployment
0x3cf26c...b6a8e1August 18, 2015Ballot
Same eraDelegated voting with a proposal count fixed at deployment
0x56ce77...b44745August 18, 2015Ballot
Same eraDelegated voting over five proposals, with the chairperson handing out voting rights
0x640fa6...b57e8aAugust 25, 2015