The go-ethereum wiki tutorial token: ten thousand units to its creator, a sendCoin transfer and a getBalance query.
Historical Significance
The token half of the tutorial that taught the first wave of Ethereum users to write Solidity. It is a token in the barest sense: a mapping from address to number with a function that moves the numbers, which is what the standards of the following year were written to make interoperable.
Context
Ethereum's Frontier network went live on 30 July 2015 and the Contract Tutorial on the go-ethereum wiki, included by reference from the Frontier Guide, was the standard introduction to Solidity. Its three contracts are named mortal, greeter and token.
Key Facts
Description
The token from the Contract Tutorial on the go-ethereum wiki, the third contract of that tutorial after mortal and greeter. Its constructor writes ten thousand units to whoever deploys it, sendCoin(receiver, amount) moves units and returns false rather than reverting if the sender is short, and getBalance(account) reads any balance back.
The balances mapping is not public, so that getter is how a balance gets read. There is no event, no approval mechanism, no metadata and no way to create more units after deployment. The wiki renamed this function between revisions, and the deployed code uses sendCoin.
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 token {
mapping (address => uint) balances;
// Initializes contract with 10 000 tokens to the creator of the contract
function token() {
balances[msg.sender] = 10000;
}
// Very simple trade function
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
return true;
}
// Check balances of any account
function getBalance(address account) returns(uint balance){
return balances[account];
}
}
External Links
Related contracts
token
Same eraAn early ERC-20-like token deployed in Ethereum's first week, built directly from the example in the official Ethereum Frontier Guide documentation.
0x8374f5...46609aAugust 7, 2015token
Same eraA second deployment of the FirstCoin tutorial token by the same creator, 11 blocks after the original — both derived from the official Ethereum Frontier Guide e
0x3b4446...295f52August 7, 2015Contract 0xd958b5...ec4c9f
Same eraEthereum.org tutorial Coin contract deployed on Frontier day 1. Contains a bug: balance(address) ignores its argument and returns msg.sender balance.
0xd958b5...ec4c9fAugust 7, 2015token
Same eraEarly tutorial-derived coin contract compiled with Solidity v0.1.1, deployed 9 days after Ethereum Frontier launch.
0x3c401b...da1634August 8, 2015token
Same eraTutorial-derived coin contract (Solidity v0.1.1), one of multiple token instances deployed by the same address on Aug 8, 2015.
0x33e986...395d13August 8, 2015CoinStub
Same eraCoin tutorial stub — mapping getter + empty function returning default bool.
0x4fb5ac...3b08aeAugust 8, 2015