A teaching contract that records its creator's ether balance at the moment of deployment and keeps it, so the snapshot can be compared with the live value.
Historical Significance
A contract written to make one property of the EVM visible: a constructor runs once, and anything it copies into storage is frozen at that block while the world it was copied from moves on. Confusing a stored snapshot with a live reading is the root of a whole class of later bugs, from stale prices to balances cached across an external call, and this is that distinction isolated into a contract that does nothing else.
Context
Deployed in March 2016 from a collection of annotated example contracts, in the period when learning Solidity meant reading somebody's commented walkthrough on GitHub and deploying the examples to mainnet to watch them run.
Key Facts
Description
A small demonstration contract. Its constructor stores the account that deployed it and reads that account's ether balance at that instant into storage. getCreatorBalance() returns the stored snapshot, and the contract also exposes its own address through getContractAddress().
The point is the difference between the two readings: the stored number is what the creator held when the contract was made and never changes, while reading creator.balance now would give whatever they hold today. The source says so in a comment.
It holds no funds, has no owner beyond the recorded address, and nothing can be written to it after deployment.
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)
/*
Another very basic contract. It demonstrates that a contract can retrieve and store the
balance of its creator address. Note that the creatorbalance value captured in the constructor is a snapshot in time.
Later on, creator.balance will reflect whatever it is now.
*/
contract creatorBalanceChecker {
address creator;
uint creatorbalance; // TIP: uint is an alias for uint256. Ditto int and int256.
function creatorBalanceChecker() public
{
creator = msg.sender; // msg is a global variable
creatorbalance = creator.balance;
}
function getContractAddress() constant returns (address)
{
return this;
}
function getCreatorBalance() constant returns (uint) // Will return the creator's balance AT THE TIME THIS CONTRACT WAS CREATED
{
return creatorbalance;
}
function getCreatorDotBalance() constant returns (uint) // Will return creator's balance NOW
{
return creator.balance;
}
/**********
Standard kill() function to recover funds
**********/
function kill()
{
if (msg.sender == creator)
suicide(creator); // kills this contract and sends remaining funds back to creator
}
}
External Links
Related contracts
Greeter
Same eraA HelloWorld greeter deployed at block 51,909 on 8 August 2015, one of a run of contracts from the same account that week.
0x412fda...7267edAugust 8, 2015Greeter
Same eraA Greeter with the message 'Ethereum will change the world smarter' - deployed Aug 8, 2015 by a developer connected to the Tokyo Smart Contract meetup.
0xda0c1c...7a68ebAugust 8, 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, 2015Greeter
Same eraThe go-ethereum Contract Tutorial greeter, deployed with the greeting: Hello World!
0x506f4b...466983August 8, 2015Contract 0xd4eae4...a2c77a
Same eraThe ethereum.org crowdsale tutorial, deployed on the ninth day of the public chain, with the funding goal, deadline and price fixed at construction.
0xd4eae4...a2c77aAugust 8, 2015Greeter
Same eraA Frontier-era Greeter contract with the message: 'Hello World!'
0x113158...72fa8aAugust 8, 2015