A token built to the pre-ERC-20 Standardized Contract APIs, with sendCoin and coinBalanceOf in place of transfer and balanceOf.
Historical Significance
Written before ERC-20 was proposed, when the shared vocabulary for tokens was the wiki page on Standardized Contract APIs. The names it uses, sendCoin and coinBalanceOf, are the ones that transfer and balanceOf replaced, and the approve mechanism here predates the allowance triple that became the standard. It shows what a token interface looked like while the question was still open.
Context
Ethereum's Frontier network went live on 30 July 2015. The chain carried almost no applications in its first months: what was deployed was mostly tutorial code, token experiments and registries, written in a Solidity that was itself only a few months old and compiled from the geth console.
Key Facts
Description
A fixed supply token written against the Standardized Contract APIs that the ethereum wiki carried before ERC-20 existed. Its interface is sendCoin(value, to), sendCoinFrom(from, value, to), coinBalance() and coinBalanceOf(address), and the transfer event is named CoinTransfer. The whole supply is created to the deployer in the constructor and can never be increased.
Delegation works differently from the allowance mapping that ERC-20 later settled on. approve grants an address blanket permission to move the approver's balance, approveOnce grants a single transfer up to a stated value and clears itself when used, and unapprove revokes both. A standing approval takes precedence over a one-time one.
Transfers return false rather than reverting when the balance is short, so a caller that ignores the return value can believe a failed transfer succeeded.
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)
/*Most, basic default, standardised Token contract.
Allows the creation of a token with a finite issued amount to the creator.
This can't be changed.
Based on standardised APIs & slightly extended. https://github.com/ethereum/wiki/wiki/Standardized_Contract_APIs
adds AddressApproval & AddressApprovalOnce events
approve & approveOnce works on premise that approved always takes precedence.
adds unapprove to basic coin interface.*/
contract Coin {
function sendCoin(uint _value, address _to) returns (bool _success) {}
function sendCoinFrom(address _from, uint _value, address _to) returns (bool _success) {}
function coinBalance() constant returns (uint _r) {}
function coinBalanceOf(address _addr) constant returns (uint _r) {}
function approve(address _addr) {}
function approveOnce(address _addr, uint256 _maxValue) {}
function unapprove(address _addr) {}
function isApproved(address _proxy) constant returns (bool _r) {}
function isApprovedFor(address _target, address _proxy) constant returns (bool _r) {}
}
contract Standard_Token is Coin {
function Standard_Token(uint _initialAmount) {
balances[msg.sender] = _initialAmount;
}
event CoinTransfer(address indexed from, address indexed to, uint256 value);
event AddressApproval(address indexed from, address indexed to, bool result);
event AddressApprovalOnce(address indexed from, address indexed to, uint256 value);
function sendCoin(uint _value, address _to) returns (bool _success) {
if (balances[msg.sender] >= _value) {
balances[msg.sender] -= _value;
balances[_to] += _value;
CoinTransfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function sendCoinFrom(address _from, uint _value, address _to) returns (bool _success) {
if (balances[_from] >= _value) {
bool transfer = false;
if(approved[_from][msg.sender]) {
transfer = true;
} else {
if(_value < approved_once[_from][msg.sender]) {
transfer = true;
approved_once[_from][msg.sender] = 0; //reset
}
}
if(transfer == true) {
balances[_from] -= _value;
balances[_to] += _value;
CoinTransfer(_from, _to, _value);
return true;
} else { return false; }
}
}
function coinBalance() constant returns (uint _r) {
return balances[msg.sender];
}
function coinBalanceOf(address _addr) constant returns (uint _r) {
return balances[_addr];
}
function approve(address _addr) {
approved[msg.sender][_addr] = true;
AddressApproval(msg.sender, _addr, true);
}
function approveOnce(address _addr, uint256 _maxValue) {
approved_once[msg.sender][_addr] = _maxValue;
AddressApprovalOnce(msg.sender, _addr, _maxValue);
}
function unapprove(address _addr) {
approved[msg.sender][_addr] = false;
approved_once[msg.sender][_addr] = 0;
AddressApproval(msg.sender, _addr, false);
AddressApprovalOnce(msg.sender, _addr, 0);
}
function isApproved(address _proxy) constant returns (bool _r) {
if(approved[msg.sender][_proxy] == true || approved_once[msg.sender][_proxy] > 0) {
return true;
}
}
function isApprovedFor(address _target, address _proxy) constant returns (bool _r) {
if(approved[_target][_proxy] == true || approved_once[_target][_proxy] > 0) {
return true;
}
}
mapping (address => uint) public balances;
mapping (address => mapping (address => bool)) public approved;
mapping (address => mapping (address => uint256)) public approved_once;
}
External Links
Related contracts
Standard_Token_Factory
Same deployerA factory for pre-ERC-20 standard tokens: one call deploys a token with a chosen supply and records it under the caller's address.
0x91d050...54ba99August 13, 2015Token
Same deployerA minimal ERC20 token with allowances: balanceOf, allowance, totalSupply, transfer, approve, transferFrom, with Transfer/Approval events. Guards balance, allowa
0x37dca3...38f00dJanuary 28, 2016Verify Token
Same deployerA ConsenSys HumanStandardToken deployed as Verify Token, symbol VTX, with 3 decimals and a fixed supply credited to its deployer.
0x584761...ea4afaJune 24, 2016Test Simon Bucks
Same deployerA ConsenSys HumanStandardToken deployed as Test Simon Bucks, symbol SBX, with 2 decimals and a fixed supply credited to its deployer.
0x42d1e2...8d55ecJuly 17, 2016token
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, 2015