Delegated voting over five proposals, with the chairperson handing out voting rights
Context
Deployed in August 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 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;
}
}
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 giveRightToVote(address voter) {
if (msg.sender != chairperson || voted[voter]) return;
voterWeight[voter] = 1;
}
}External Links
Related contracts
Multiply7
Same deployerThe canonical Solidity 'multiply by 7' tutorial contract from the Frontier documentation.
0xa18d71...418761August 10, 2015exchange
Same deployerThe exchange example from the ethereum dapp-bin standardized contract APIs, whose deleteOrder lets anyone cancel anyone else's order.
0xb34555...5f06b4September 8, 2015currency
Same deployerAn early Frontier-era token contract implementing a pre-ERC-20 interface, deployed on September 8, 2015 by an address associated with the ENS name collectibletr
0x8494f7...634fd3September 8, 2015MyToken
Same deployerA MyToken template deployment by collectibletrust.eth on November 3, 2015, linking the same deployer responsible for the pre-ERC-20 currency contract from Septe
0x5f100e...12a9e0November 3, 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, 2015