The 2015 tutorial token renamed to MyToken, leaving its initialiser as a public function any account can call to set its own balance.
Historical Significance
A copy of the tutorial token broken by a one-word edit: the contract was renamed and the initialiser was not, so what should have been a constructor became a public function. In 2015 the constructor was just the function sharing the contract's name, which made this a mistake anyone renaming a contract could make silently.
Context
Ethereum's Frontier network went live on 30 July 2015. The tutorial token of that period predates ERC-20: balances are read through coinBalanceOf, transfers are sent with sendCoin, and the event announcing one is called CoinTransfer.
Key Facts
Description
The token from the 2015 ethereum.org tutorial, in the form that predates ERC-20. It keeps one public mapping of balances, hands the whole supply to whoever creates it, and moves units with sendCoin(receiver, amount), which checks the sender's balance, returns false rather than reverting when it is short, and announces a successful move with a CoinTransfer event.
There is no approval, no allowance, no decimals, no name and no symbol. The supply is set once and cannot be added to.
The contract carries a defect that survives in the deployed code. Its initialiser is named token, but the contract is not, so it is not a constructor: it never ran at deployment, and it is a public function that any account can call at any time to write itself whatever balance it likes. Nothing about the supply is fixed and nothing restricts who sets it.
The default it writes when called with zero is 90,000,000 units, in place of the 1,000,000,000 the published tutorial used.
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 MyToken {
mapping (address => uint) public coinBalanceOf;
event CoinTransfer(address sender, address receiver, uint amount);
function token(uint supply) {
if (supply == 0) supply = 90000000;
coinBalanceOf[msg.sender] = supply;
}
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (coinBalanceOf[msg.sender] < amount) {
return false;
}
coinBalanceOf[msg.sender] -= amount;
coinBalanceOf[receiver] += amount;
CoinTransfer(msg.sender, receiver, amount);
return true;
}
}External Links
Related contracts
CrowdSale
Same deployerThe July 2015 ethereum.org crowdsale tutorial, with a fallback that reverts on every contribution.
0x2ba9d1...af0d85October 22, 2015Multiply7
Same deployerThe hello-world of Solidity: multiply(x) returns x*7. The ethereum.org tutorial contract. 120 copies deployed Sep 2015 through Feb 2016.
0xfc3c99...90d3d6October 24, 2015test
Same deployerThe multiply contract that opens the go-ethereum Contract Tutorial, deployed with the author's own multiplier of 10 in place of 7.
0x515179...07a2d1October 24, 2015Contract 0x2273df...27ef78
Same deployerA copy of the coin contract from the Frontier Guide where the contract was renamed but its constructor was not, leaving the supply function callable by anyone.
0x2273df...27ef78October 24, 2015Contract 0xb00de1...a6a7f9
Same deployerA copy of the coin contract from the Frontier Guide where the contract was renamed but its constructor was not, leaving the supply function callable by anyone.
0xb00de1...a6a7f9October 24, 2015Contract 0x2ad2be...696e00
Same deployerA copy of the coin contract from the Frontier Guide where the contract was renamed but its constructor was not, leaving the supply function callable by anyone.
0x2ad2be...696e00October 24, 2015