├── ABI ├── Token.abi └── Token.minified.abi ├── README.md └── Token.sol /ABI/Token.abi: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "constant": true, 4 | "inputs": [], 5 | "name": "name", 6 | "outputs": [ 7 | { 8 | "name": "_name", 9 | "type": "string" 10 | } 11 | ], 12 | "payable": false, 13 | "stateMutability": "view", 14 | "type": "function" 15 | }, 16 | { 17 | "constant": true, 18 | "inputs": [], 19 | "name": "totalSupply", 20 | "outputs": [ 21 | { 22 | "name": "_totalSupply", 23 | "type": "uint256" 24 | } 25 | ], 26 | "payable": false, 27 | "stateMutability": "view", 28 | "type": "function" 29 | }, 30 | { 31 | "constant": true, 32 | "inputs": [], 33 | "name": "decimals", 34 | "outputs": [ 35 | { 36 | "name": "_decimals", 37 | "type": "uint8" 38 | } 39 | ], 40 | "payable": false, 41 | "stateMutability": "view", 42 | "type": "function" 43 | }, 44 | { 45 | "constant": true, 46 | "inputs": [], 47 | "name": "MAX_UINT256", 48 | "outputs": [ 49 | { 50 | "name": "", 51 | "type": "uint256" 52 | } 53 | ], 54 | "payable": false, 55 | "stateMutability": "view", 56 | "type": "function" 57 | }, 58 | { 59 | "constant": true, 60 | "inputs": [ 61 | { 62 | "name": "_owner", 63 | "type": "address" 64 | } 65 | ], 66 | "name": "balanceOf", 67 | "outputs": [ 68 | { 69 | "name": "balance", 70 | "type": "uint256" 71 | } 72 | ], 73 | "payable": false, 74 | "stateMutability": "view", 75 | "type": "function" 76 | }, 77 | { 78 | "constant": true, 79 | "inputs": [], 80 | "name": "symbol", 81 | "outputs": [ 82 | { 83 | "name": "_symbol", 84 | "type": "string" 85 | } 86 | ], 87 | "payable": false, 88 | "stateMutability": "view", 89 | "type": "function" 90 | }, 91 | { 92 | "constant": false, 93 | "inputs": [ 94 | { 95 | "name": "_to", 96 | "type": "address" 97 | }, 98 | { 99 | "name": "_value", 100 | "type": "uint256" 101 | } 102 | ], 103 | "name": "transfer", 104 | "outputs": [ 105 | { 106 | "name": "success", 107 | "type": "bool" 108 | } 109 | ], 110 | "payable": false, 111 | "stateMutability": "nonpayable", 112 | "type": "function" 113 | }, 114 | { 115 | "constant": false, 116 | "inputs": [ 117 | { 118 | "name": "_to", 119 | "type": "address" 120 | }, 121 | { 122 | "name": "_value", 123 | "type": "uint256" 124 | }, 125 | { 126 | "name": "_data", 127 | "type": "bytes" 128 | } 129 | ], 130 | "name": "transfer", 131 | "outputs": [ 132 | { 133 | "name": "success", 134 | "type": "bool" 135 | } 136 | ], 137 | "payable": false, 138 | "stateMutability": "nonpayable", 139 | "type": "function" 140 | }, 141 | { 142 | "constant": false, 143 | "inputs": [ 144 | { 145 | "name": "_to", 146 | "type": "address" 147 | }, 148 | { 149 | "name": "_value", 150 | "type": "uint256" 151 | }, 152 | { 153 | "name": "_data", 154 | "type": "bytes" 155 | }, 156 | { 157 | "name": "_custom_fallback", 158 | "type": "string" 159 | } 160 | ], 161 | "name": "transfer", 162 | "outputs": [ 163 | { 164 | "name": "success", 165 | "type": "bool" 166 | } 167 | ], 168 | "payable": false, 169 | "stateMutability": "nonpayable", 170 | "type": "function" 171 | }, 172 | { 173 | "inputs": [], 174 | "payable": false, 175 | "stateMutability": "nonpayable", 176 | "type": "constructor" 177 | }, 178 | { 179 | "anonymous": false, 180 | "inputs": [ 181 | { 182 | "indexed": true, 183 | "name": "_from", 184 | "type": "address" 185 | }, 186 | { 187 | "indexed": true, 188 | "name": "_to", 189 | "type": "address" 190 | }, 191 | { 192 | "indexed": false, 193 | "name": "_value", 194 | "type": "uint256" 195 | }, 196 | { 197 | "indexed": false, 198 | "name": "_data", 199 | "type": "bytes" 200 | } 201 | ], 202 | "name": "Transfer", 203 | "type": "event" 204 | } 205 | ] 206 | -------------------------------------------------------------------------------- /ABI/Token.minified.abi: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"_name","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"_totalSupply","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"_decimals","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"MAX_UINT256","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"_symbol","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"},{"name":"_custom_fallback","type":"string"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"},{"indexed":false,"name":"_data","type":"bytes"}],"name":"Transfer","type":"event"}] 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ERC223 standard token for crowdsale. 2 | 3 | Compiled with `0.4.19+commit.c4cbbb05.Emscripten.clang` + optimization. 4 | 5 | Deployed at [0xED346776072b8bCDF50c904a7eAAa4BB13D8Fb59](https://gastracker.io/addr/0xED346776072b8bCDF50c904a7eAAa4BB13D8Fb59) 6 | 7 | Initial balance of 3,000,000 tokens is initialized at [0xdc8fE10C5e872e25Ac24dE310e60D88E4b7a22a1](https://gastracker.io/contract/0xdc8fE10C5e872e25Ac24dE310e60D88E4b7a22a1) address. 8 | -------------------------------------------------------------------------------- /Token.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.9; 2 | 3 | /* https://github.com/LykkeCity/EthereumApiDotNetCore/blob/master/src/ContractBuilder/contracts/token/SafeMath.sol */ 4 | contract SafeMath { 5 | uint256 constant public MAX_UINT256 = 6 | 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; 7 | 8 | function safeAdd(uint256 x, uint256 y) constant internal returns (uint256 z) { 9 | if (x > MAX_UINT256 - y) throw; 10 | return x + y; 11 | } 12 | 13 | function safeSub(uint256 x, uint256 y) constant internal returns (uint256 z) { 14 | if (x < y) throw; 15 | return x - y; 16 | } 17 | 18 | function safeMul(uint256 x, uint256 y) constant internal returns (uint256 z) { 19 | if (y == 0) return 0; 20 | if (x > MAX_UINT256 / y) throw; 21 | return x * y; 22 | } 23 | } 24 | 25 | contract ContractReceiver { 26 | function tokenFallback(address _from, uint _value, bytes _data); 27 | } 28 | 29 | contract ERC223Token is SafeMath { 30 | 31 | event Transfer(address indexed _from, address indexed _to, uint256 _value, bytes _data); 32 | 33 | mapping(address => uint) balances; 34 | 35 | string public name = "Token"; 36 | string public symbol = "TKN"; 37 | uint8 public decimals = 18; 38 | uint256 public totalSupply; 39 | 40 | function ERC223Token() 41 | { 42 | balances[0xdc8fE10C5e872e25Ac24dE310e60D88E4b7a22a1] = 3000000 * (10 ** decimals); 43 | totalSupply = balances[0xdc8fE10C5e872e25Ac24dE310e60D88E4b7a22a1]; 44 | } 45 | 46 | 47 | // Function to access name of token . 48 | function name() constant returns (string _name) { 49 | return name; 50 | } 51 | // Function to access symbol of token . 52 | function symbol() constant returns (string _symbol) { 53 | return symbol; 54 | } 55 | // Function to access decimals of token . 56 | function decimals() constant returns (uint8 _decimals) { 57 | return decimals; 58 | } 59 | // Function to access total supply of tokens . 60 | function totalSupply() constant returns (uint256 _totalSupply) { 61 | return totalSupply; 62 | } 63 | 64 | 65 | // Function that is called when a user or another contract wants to transfer funds . 66 | function transfer(address _to, uint _value, bytes _data, string _custom_fallback) returns (bool success) { 67 | 68 | if(isContract(_to)) { 69 | if (balanceOf(msg.sender) < _value) throw; 70 | balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); 71 | balances[_to] = safeAdd(balanceOf(_to), _value); 72 | assert(_to.call.value(0)(bytes4(sha3(_custom_fallback)), msg.sender, _value, _data)); 73 | Transfer(msg.sender, _to, _value, _data); 74 | return true; 75 | } 76 | else { 77 | return transferToAddress(_to, _value, _data); 78 | } 79 | } 80 | 81 | 82 | // Function that is called when a user or another contract wants to transfer funds . 83 | function transfer(address _to, uint _value, bytes _data) returns (bool success) { 84 | 85 | if(isContract(_to)) { 86 | return transferToContract(_to, _value, _data); 87 | } 88 | else { 89 | return transferToAddress(_to, _value, _data); 90 | } 91 | } 92 | 93 | // Standard function transfer similar to ERC20 transfer with no _data . 94 | // Added due to backwards compatibility reasons . 95 | function transfer(address _to, uint _value) returns (bool success) { 96 | 97 | //standard function transfer similar to ERC20 transfer with no _data 98 | //added due to backwards compatibility reasons 99 | bytes memory empty; 100 | if(isContract(_to)) { 101 | return transferToContract(_to, _value, empty); 102 | } 103 | else { 104 | return transferToAddress(_to, _value, empty); 105 | } 106 | } 107 | 108 | //assemble the given address bytecode. If bytecode exists then the _addr is a contract. 109 | function isContract(address _addr) private returns (bool is_contract) { 110 | uint length; 111 | assembly { 112 | //retrieve the size of the code on target address, this needs assembly 113 | length := extcodesize(_addr) 114 | } 115 | return (length>0); 116 | } 117 | 118 | //function that is called when transaction target is an address 119 | function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) { 120 | if (balanceOf(msg.sender) < _value) throw; 121 | balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); 122 | balances[_to] = safeAdd(balanceOf(_to), _value); 123 | Transfer(msg.sender, _to, _value, _data); 124 | return true; 125 | } 126 | 127 | //function that is called when transaction target is a contract 128 | function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) { 129 | if (balanceOf(msg.sender) < _value) throw; 130 | balances[msg.sender] = safeSub(balanceOf(msg.sender), _value); 131 | balances[_to] = safeAdd(balanceOf(_to), _value); 132 | ContractReceiver receiver = ContractReceiver(_to); 133 | receiver.tokenFallback(msg.sender, _value, _data); 134 | Transfer(msg.sender, _to, _value, _data); 135 | return true; 136 | } 137 | 138 | 139 | function balanceOf(address _owner) constant returns (uint balance) { 140 | return balances[_owner]; 141 | } 142 | } 143 | --------------------------------------------------------------------------------