A minimal random number generator that stores a blockhash at deployment. Has a bug: the rand() function always returns 0.
Historical Significance
An early attempt at on-chain randomness from the Frontier era, demonstrating a common pitfall that many early developers encountered: the unavailability of the current block hash within the executing block. This bug pattern was widespread enough to be explicitly documented in later Solidity best practices.
Context
Deployed in February 2016 during the Frontier era, compiled with Solidity v0.1.6. On-chain randomness was a hot topic in early Ethereum development, with developers experimenting with blockhash-based approaches before the limitations were well understood.
Key Facts
Description
A tiny contract (126 bytes runtime) deployed on Feb 4, 2016 that attempts to generate a random value by storing block.blockhash(blockNumber) at deployment time. The rand() function takes min and max parameters but ignores them entirely, simply returning the stored blockhash.
The contract has a notable bug: block.blockhash(block.number) always returns 0 in the EVM because the current block's hash is not yet available. The developer likely intended block.blockhash(block.number - 1) to get the previous block's hash. As a result, rand() always returns 0.
Uses inline state variable initializers instead of a constructor function, which produces unusually compact init code (36 bytes). The same deployer (0x5de92686587b10cD47E03B71f2E2350606fCAf14) deployed over 100 other experimental contracts during the same period.
Source Verified
Exact bytecode match (init + runtime). 36 bytes init, 126 bytes runtime. Uses inline state variable initializers, no constructor.
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)
contract Random {
uint blockNumber = block.number;
bytes32 randomValue = block.blockhash(blockNumber);
function rand(uint256 min, uint256 max) returns (bytes32) {
return randomValue;
}
}