A coin flip settled on the parity of the block timestamp, with a size guard written the wrong way round so no bet can ever be placed.
Historical Significance
An early gambling contract that shows both hazards of the form at once: a payout decided by a value the block producer controls, and a guard written backwards that made the whole contract inert. The author noticed the second problem within the hour and redeployed; the timestamp problem went on being repeated by dice contracts for years.
Context
Ethereum's Frontier network went live on 30 July 2015. Almost nothing was deployed in its first months except tutorial code and small experiments, written in a Solidity only a few months old and with no test network in common use, so the experiments happened on mainnet.
Key Facts
Description
A gambling contract with two entry points. donate() takes ether and does nothing with it. The fallback function is the bet: it compares the stake against the contract's own balance, records the block timestamp in a public variable, and pays the sender twice the stake when that timestamp is odd.
The guard is inverted. It requires the stake to be smaller than twice the balance and returns otherwise, but the balance it reads already includes the stake just received, so the condition holds for every non-zero bet and the function returns before reaching the flip. No bet placed on this contract can ever be settled.
The same account deployed a corrected version sixty four blocks later, with the comparison the other way around.
Settling on block.timestamp would have been unsafe in any case: the miner producing the block chooses it within a tolerance, and here the payout is twice the stake.
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
This contract has verified source code on Etherscan.
Show source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
contract CoinFlipper {
uint256 public flip;
function donate() {
}
function() {
var v = msg.value;
var b = address(this).balance;
if (v < 2 * b) {
return;
}
flip = block.timestamp;
if (flip % 2 == 0) {
} else {
msg.sender.send(2 * v);
}
}
}External Links
Related contracts
Greeter
Same deployerA Frontier-era Greeter contract with the message: 'Hello World!'
0x113158...72fa8aAugust 8, 2015CoinFlipper
Same deployerA coin flip on the block timestamp that pays double or keeps the stake
0x6c8dda...5ef84eAugust 8, 2015CoinFlipper
Same deployerTimestamp-parity coinflip with balance guard and donate().
0xb87824...8642adAugust 8, 2015CoinFlip
Same deployerTimestamp-parity coinflip; payout is `2 * msg.value` via `send`.
0x0013e7...1c2989August 8, 2015Multiply7
Same deployerThe Multiply7 tutorial contract — one of the first Solidity examples ever deployed to mainnet.
0xfcb20a...b96d3fAugust 10, 2015Pyramid
Same deployerMember-added pyramid/chain list with equal-share claim distribution.
0xdf4b51...dc9b87August 10, 2015