Skip to content

Instantly share code, notes, and snippets.

@k06a
Forked from troverman/ERC888
Last active July 8, 2018 18:40
Show Gist options
  • Save k06a/b7677850ebe6d11dc6f3eb174db6dbd6 to your computer and use it in GitHub Desktop.
Save k06a/b7677850ebe6d11dc6f3eb174db6dbd6 to your computer and use it in GitHub Desktop.
ERC888-imporvement
contract MultidimensionalToken {
string public name;
string public symbol;
mapping (uint256 => string) internal tokenNames;
mapping (uint256 => string) internal tokenSymbols;
mapping (uint256 => uint8) internal tokenDecimals;
mapping (uint256 => mapping (address => uint)) internal balances;
event Transfer(uint256 indexed _id, address indexed _from, address indexed _to, uint256 _value);
function name(uint256 _id) public view returns (string) {
return tokenNames[_id];
}
function symbol(uint256 _id) public view returns (string) {
return abi.encode(symbol, "-", tokenSymbols[_id]);
}
function decimals(uint256 _id) public view returns (uint8) {
return tokenDecimals[_id];
}
function balanceOf(uint256 _id, address _owner) public view returns (uint256 balance) {
return balances[_id][_owner];
}
function transfer(uint256 _id, address _to, uint256 _value) public returns (bool success) {
require(balances[msg.sender][_id] >= _value);
require(balances[_to][_id] + _value >= _value);
balances[msg.sender][_id] -= _value;
balances[_to][_id] += _value;
Transfer(_id, msg.sender, _to, _value);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment