A factory library that deploys tokens backed one for one by ether held in the token
Historical Significance
An ether backed token issued by a factory rather than written by hand, with the created token's ABI published on chain beside the factory that makes it.
Context
Deployed in the Homestead era, a year before wrapped ether became a standard building block.
Key Facts
Description
CreatorTokenEther is one of the factory libraries in Airalab's DAO toolkit. Its create function deploys a TokenEther, a token whose supply is its own ether balance: sending ether to refill mints the sender an equal token balance, and withdraw burns tokens and returns the ether. Two further functions make it self describing on chain: version returns the toolkit release it was built from, and interface returns the full ABI of the token it creates as a JSON string. Deployed on 18 August 2016 by 0x4af013afbadb22d8a88c92d68fc96b033b9ebb8a and recovered from airalab/core.
DAO Fork Era
The controversial fork to recover funds from The DAO hack.
Bytecode Overview
Verified Source Available
This contract has verified source code on Etherscan.
Show source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
/**
* @title The root contract
* @dev This contract is used as base of all contracts,
* e.g. it change default behaviour of fallback function
*/
contract Object {
/**
* @dev Default fallback behaviour will throw sended ethers
*/
function() { throw; }
}
/**
* @title Contract for object that have an owner
*/
contract Owned is Object {
/**
* Contract owner address
*/
address public owner;
/**
* @dev Store owner on creation
*/
function Owned() { owner = msg.sender; }
/**
* @dev Delegate contract to another person
* @param _owner is another person address
*/
function delegate(address _owner) onlyOwner
{ owner = _owner; }
/**
* @dev Owner check modifier
*/
modifier onlyOwner { if (msg.sender != owner) throw; _ }
}
/**
* @title Token contract represents any asset in digital economy
*/
contract Token is Owned {
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
/* Short description of token */
string public name;
string public symbol;
/* Total count of tokens exist */
uint public totalSupply;
/* Fixed point position */
uint8 public decimals;
/* Token approvement system */
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
/**
* @return available balance of `sender` account (self balance)
*/
function getBalance() constant returns (uint)
{ return balanceOf[msg.sender]; }
/**
* @dev This method returns non zero result when sender is approved by
* argument address and target address have non zero self balance
* @param _address target address
* @return available for `sender` balance of given address
*/
function getBalance(address _address) constant returns (uint) {
return allowance[_address][msg.sender]
> balanceOf[_address] ? balanceOf[_address]
: allowance[_address][msg.sender];
}
/* Token constructor */
function Token(string _name, string _symbol, uint8 _decimals, uint _count) {
name = _name;
symbol = _symbol;
decimals = _decimals;
totalSupply = _count;
balanceOf[msg.sender] = _count;
}
/**
* @dev Transfer self tokens to given address
* @param _to destination address
* @param _value amount of token values to send
* @notice `_value` tokens will be sended to `_to`
* @return `true` when transfer done
*/
function transfer(address _to, uint _value) returns (bool) {
if (balanceOf[msg.sender] >= _value) {
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
return false;
}
/**
* @dev Transfer with approvement mechainsm
* @param _from source address, `_value` tokens shold be approved for `sender`
* @param _to destination address
* @param _value amount of token values to send
* @notice from `_from` will be sended `_value` tokens to `_to`
* @return `true` when transfer is done
*/
function transferFrom(address _from, address _to, uint _value) returns (bool) {
var avail = allowance[_from][msg.sender]
> balanceOf[_from] ? balanceOf[_from]
: allowance[_from][msg.sender];
if (avail >= _value) {
allowance[_from][msg.sender] -= _value;
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
Transfer(_from, _to, _value);
return true;
}
return false;
}
/**
* @dev Give to target address ability for self token manipulation without sending
* @param _address target address
* @param _value amount of token values for approving
*/
function approve(address _address, uint _value) {
allowance[msg.sender][_address] += _value;
Approval(msg.sender, _address, _value);
}
/**
* @dev Reset count of tokens approved for given address
* @param _address target address
*/
function unapprove(address _address)
{ allowance[msg.sender][_address] = 0; }
}
/**
* @title Ethereum crypto currency extention for Token contract
*/
contract TokenEther is Token {
function TokenEther(string _name, string _symbol)
Token(_name, _symbol, 18, 0)
{}
/**
* @dev This is the way to withdraw money from token
* @param _value how many tokens withdraw from balance
*/
function withdraw(uint _value) {
if (balanceOf[msg.sender] >= _value) {
balanceOf[msg.sender] -= _value;
totalSupply -= _value;
if(!msg.sender.send(_value)) throw;
}
}
/**
* @dev This is the way to refill your token balance by ethers
*/
function refill() {
balanceOf[msg.sender] += msg.value;
totalSupply += msg.value;
}
/**
* @dev This method is called when money sended to contract address,
* a synonym for refill()
*/
function () {
balanceOf[msg.sender] += msg.value;
totalSupply += msg.value;
}
}
library CreatorTokenEther {
function create(string _name, string _symbol) returns (TokenEther)
{ return new TokenEther(_name, _symbol); }
function version() constant returns (string)
{ return "v0.4.9 (47c069a9)"; }
function interface() constant returns (string)
{ return '[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"withdraw","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},{"constant":false,"inputs":[],"name":"refill","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"delegate","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"_address","type":"address"}],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_address","type":"address"}],"name":"unapprove","outputs":[],"type":"function"},{"inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}]'; }
}
External Links
Related contracts
AddressList
Same deployerA doubly linked list of addresses, deployed as a shared library
0xb0af78...dff94bAugust 18, 2016Contract 0x7e62ca...86e943
Same deployerAn address to address map with iteration, deployed as a shared library
0x7e62ca...86e943August 18, 2016CreatorTokenEmission
Same deployerA factory library that deploys mintable and burnable tokens, and hands back their ABI
0x63bfd6...63231eAugust 18, 2016AddressList
Same deployerA doubly linked list of addresses, deployed as a shared library
0xb51afd...224574August 25, 2016Contract 0xed6216...c0bce9
Same deployerAn address to address map with iteration, deployed as a shared library
0xed6216...c0bce9August 25, 2016CreatorVoting51
Same deployerA factory library that deploys simple majority voting contracts
0x6e98df...86df55August 25, 2016