An early coin contract with balance transfers and a delegated-spending approval system.
Historical Significance
A coin with delegated spending, written against the pre-ERC-20 vocabulary of sendCoin and approve. It is the interface question being worked out in the open: how does a contract spend on a holder's behalf, and what does the holder have to do first. ERC-20 settled on the allowance triple, and contracts like this are the alternatives it was chosen over.
Context
Deployed on 29 February 2016. It follows the standardized contract APIs pattern for coins that circulated in early Ethereum.
Key Facts
Description
A coin contract that credits its deployer with an initial balance when it is constructed and lets holders move units to another account with sendCoin. It supports delegated spending through sendCoinFrom together with approve, approveOnce and disapprove, so one account can authorise another address to move its balance up to a limit. Balances are readable with coinBalance and coinBalanceOf, and a CoinSent event is logged on every transfer.
Source Verified
Historian Categories
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)
// Submitted by EthereumHistory (ethereumhistory.com)
contract currency {
struct Account {
uint balance;
mapping ( address => uint) withdrawers;
}
mapping ( address => Account ) accounts;
event CoinSent(address indexed from, uint256 value, address indexed to);
function currency() {
accounts[msg.sender].balance = 1000000;
}
function sendCoin(uint _value, address _to) returns (bool _success) {
if (accounts[msg.sender].balance >= _value && _value < 340282366920938463463374607431768211456) {
accounts[msg.sender].balance -= _value;
accounts[_to].balance += _value;
CoinSent(msg.sender, _value, _to);
_success = true;
}
else _success = false;
}
function sendCoinFrom(address _from, uint _value, address _to) returns (bool _success) {
uint auth = accounts[_from].withdrawers[msg.sender];
if (accounts[_from].balance >= _value && auth >= _value && _value < 340282366920938463463374607431768211456) {
accounts[_from].withdrawers[msg.sender] -= _value;
accounts[_from].balance -= _value;
accounts[_to].balance += _value;
CoinSent(_from, _value, _to);
_success = true;
_success = true;
}
else _success = false;
}
function coinBalance() constant returns (uint _r) {
_r = accounts[msg.sender].balance;
}
function coinBalanceOf(address _addr) constant returns (uint _r) {
_r = accounts[_addr].balance;
}
function approve(address _addr) {
accounts[msg.sender].withdrawers[_addr] = 340282366920938463463374607431768211456;
}
function isApproved(address _proxy) returns (bool _r) {
_r = (accounts[msg.sender].withdrawers[_proxy] > 0);
}
function approveOnce(address _addr, uint256 _maxValue) {
accounts[msg.sender].withdrawers[_addr] += _maxValue;
}
function isApprovedOnceFor(address _target, address _proxy) returns (uint256 _r) {
_r = accounts[_target].withdrawers[_proxy];
}
function disapprove(address _addr) {
accounts[msg.sender].withdrawers[_addr] = 0;
}
}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