Join GitHub today
ERC: Token Changer #228
Standard functions for contracts offering token change services of standard ERC20 tokens.
This ERC proposes a set of standard APIs for contracts providing change services between different ERC20 tokens.
The APIs can be used for:
Those functions will allow dapps and wallets to utilize token-changing contracts across multiple interface/dapps. Token changing contracts function as automatic money-changers / market-markers, solving the ‘double coincidence of wants’ problem for token exchange.
function changeableTokenCount() public constant returns (uint16 count)
Gets the number of changeable tokens supported by the contract.
function changeableToken(uint16 _tokenIndex) public constant returns (address tokenAddress)
Given a changeable token index, gets the changeable token contract address.
function getReturn(address _fromToken, address _toToken, uint256 _amount) public constant returns (uint256 amount)
Returns the currently expected return for changing a specific
function change(address _fromToken, address _toToken, uint256 _amount, uint256 _minReturn) public returns (uint256 amount)
The change will only take place if the returned amount of the
NOTE: Sufficient allowance needs to be set for the
Triggered when the list of changeable tokens is modified.
event Change(address indexed _fromToken, address indexed _toToken, address indexed _changer, uint256 _amount, uint256 _return);
Triggered when a change between two tokens takes place.
This is a simple standard which works well for different exchange rate calculation methods and fee structures.
The token changer functions may be integrated with an ERC20 functions, in which case, the contract may be listed as one of the changeable tokens.
Copyright and related rights waived via CC0.