diff --git a/build/contracts/ICOToken.json b/build/contracts/ICOToken.json index 68f421d..1bf2c2e 100644 --- a/build/contracts/ICOToken.json +++ b/build/contracts/ICOToken.json @@ -93,23 +93,43 @@ "payable": false, "stateMutability": "view", "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" } ], - "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_initialSupply\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"standard\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"project:/contracts/ICOToken.sol\":\"ICOToken\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"project:/contracts/ICOToken.sol\":{\"keccak256\":\"0x0cef4aba03312adb29b631bd158af913e430b5be7e67b206d777525f8cc1ee00\",\"urls\":[\"bzz-raw://9c4e66ced1a806123de656a42143110d540c656284764fce6f2558b785c39c1e\",\"dweb:/ipfs/QmfLTpoo5zcSDCgqPoTkHSLyfvkrnPLSpEPeARTNGbpTku\"]}},\"version\":1}", - "bytecode": "0x60806040526040518060400160405280600981526020017f49434f20546f6b656e00000000000000000000000000000000000000000000008152506000908051906020019061004f929190610135565b506040518060400160405280600381526020017f49434f00000000000000000000000000000000000000000000000000000000008152506001908051906020019061009b929190610135565b506040518060400160405280600481526020017f76322e3000000000000000000000000000000000000000000000000000000000815250600290805190602001906100e7929190610135565b503480156100f457600080fd5b506040516106713803806106718339818101604052602081101561011757600080fd5b810190808051906020019092919050505080600381905550506101da565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017657805160ff19168380011785556101a4565b828001600101855582156101a4579182015b828111156101a3578251825591602001919060010190610188565b5b5090506101b191906101b5565b5090565b6101d791905b808211156101d35760008160009055506001016101bb565b5090565b90565b610488806101e96000396000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806306fdde031461005c57806318160ddd146100df5780635a3b7e42146100fd57806370a082311461018057806395d89b41146101d8575b600080fd5b61006461025b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100a4578082015181840152602081019050610089565b50505050905090810190601f1680156100d15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e76102f9565b6040518082815260200191505060405180910390f35b6101056102ff565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014557808201518184015260208101905061012a565b50505050905090810190601f1680156101725780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c26004803603602081101561019657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061039d565b6040518082815260200191505060405180910390f35b6101e06103b5565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610220578082015181840152602081019050610205565b50505050905090810190601f16801561024d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102f15780601f106102c6576101008083540402835291602001916102f1565b820191906000526020600020905b8154815290600101906020018083116102d457829003601f168201915b505050505081565b60035481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103955780601f1061036a57610100808354040283529160200191610395565b820191906000526020600020905b81548152906001019060200180831161037857829003601f168201915b505050505081565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561044b5780601f106104205761010080835404028352916020019161044b565b820191906000526020600020905b81548152906001019060200180831161042e57829003601f168201915b50505050508156fea265627a7a72315820b1b632a2893eb8c009684a5c8be8d25b91107fd94016c3073de1abc5e253fa9f64736f6c63430005100032", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100575760003560e01c806306fdde031461005c57806318160ddd146100df5780635a3b7e42146100fd57806370a082311461018057806395d89b41146101d8575b600080fd5b61006461025b565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100a4578082015181840152602081019050610089565b50505050905090810190601f1680156100d15780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e76102f9565b6040518082815260200191505060405180910390f35b6101056102ff565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014557808201518184015260208101905061012a565b50505050905090810190601f1680156101725780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101c26004803603602081101561019657600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061039d565b6040518082815260200191505060405180910390f35b6101e06103b5565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610220578082015181840152602081019050610205565b50505050905090810190601f16801561024d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102f15780601f106102c6576101008083540402835291602001916102f1565b820191906000526020600020905b8154815290600101906020018083116102d457829003601f168201915b505050505081565b60035481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103955780601f1061036a57610100808354040283529160200191610395565b820191906000526020600020905b81548152906001019060200180831161037857829003601f168201915b505050505081565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561044b5780601f106104205761010080835404028352916020019161044b565b820191906000526020600020905b81548152906001019060200180831161042e57829003601f168201915b50505050508156fea265627a7a72315820b1b632a2893eb8c009684a5c8be8d25b91107fd94016c3073de1abc5e253fa9f64736f6c63430005100032", - "sourceMap": "34:413:0:-;;;146:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;183:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;216:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;332:113;8:9:-1;5:2;;;30:1;27;20:12;5:2;332:113:0;;;;;;;;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;332:113:0;;;;;;;;;;;;;;;;395:14;381:11;:28;;;;332:113;34:413;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", - "deployedSourceMap": "34:413:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:413:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;146:33;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;146:33:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;252:26;;;:::i;:::-;;;;;;;;;;;;;;;;;;;216:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;216:32:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;283:44;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;283:44:0;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;183:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;183:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;146:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;252:26::-;;;;:::o;216:32::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;283:44::-;;;;;;;;;;;;;;;;;:::o;183:29::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o", - "source": "pragma solidity >=0.4.22 <0.9.0;\n\ncontract ICOToken {\n // Constructor\n // Set the total number of tokens\n // Read the total number of tokens\n string public name = \"ICO Token\";\n string public symbol = \"ICO\";\n string public standard = \"v2.0\";\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n constructor(uint256 _initialSupply) public {\n totalSupply = _initialSupply;\n // allocate initial supply\n }\n}", + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_initialSupply\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"standard\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"project:/contracts/ICOToken.sol\":\"ICOToken\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"project:/contracts/ICOToken.sol\":{\"keccak256\":\"0x8d81a627d22dec52b9535a38d9b4ac62634ac86987d154cf93c4ae85b70cdcaa\",\"urls\":[\"bzz-raw://3ce9b14c02b73aac4e96b68f8256905d4adfb74b8aab06d972c5a0b296cc0eca\",\"dweb:/ipfs/QmPdvBvcwJakCm4Q77USZikZzPmuz5thxySzi8bAiS3yjF\"]}},\"version\":1}", + "bytecode": "0x60806040526040518060400160405280600981526020017f49434f20546f6b656e00000000000000000000000000000000000000000000008152506000908051906020019061004f929190610179565b506040518060400160405280600381526020017f49434f00000000000000000000000000000000000000000000000000000000008152506001908051906020019061009b929190610179565b506040518060400160405280600481526020017f76312e3000000000000000000000000000000000000000000000000000000000815250600290805190602001906100e7929190610179565b503480156100f457600080fd5b506040516107123803806107128339818101604052602081101561011757600080fd5b810190808051906020019092919050505080600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806003819055505061021e565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101ba57805160ff19168380011785556101e8565b828001600101855582156101e8579182015b828111156101e75782518255916020019190600101906101cc565b5b5090506101f591906101f9565b5090565b61021b91905b808211156102175760008160009055506001016101ff565b5090565b90565b6104e58061022d6000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c806306fdde031461006757806318160ddd146100ea5780635a3b7e421461010857806370a082311461018b57806395d89b41146101e3578063a9059cbb14610266575b600080fd5b61006f6102b4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100af578082015181840152602081019050610094565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100f2610352565b6040518082815260200191505060405180910390f35b610110610358565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610150578082015181840152602081019050610135565b50505050905090810190601f16801561017d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101cd600480360360208110156101a157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103f6565b6040518082815260200191505060405180910390f35b6101eb61040e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561022b578082015181840152602081019050610210565b50505050905090810190601f1680156102585780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102b26004803603604081101561027c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ac565b005b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561034a5780601f1061031f5761010080835404028352916020019161034a565b820191906000526020600020905b81548152906001019060200180831161032d57829003601f168201915b505050505081565b60035481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103ee5780601f106103c3576101008083540402835291602001916103ee565b820191906000526020600020905b8154815290600101906020018083116103d157829003601f168201915b505050505081565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104a45780601f10610479576101008083540402835291602001916104a4565b820191906000526020600020905b81548152906001019060200180831161048757829003601f168201915b505050505081565b505056fea265627a7a72315820db1636e668c814a84dcdc5672de93b5ccadf4f73654bdd075585661f2fe7398f64736f6c63430005100032", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c806306fdde031461006757806318160ddd146100ea5780635a3b7e421461010857806370a082311461018b57806395d89b41146101e3578063a9059cbb14610266575b600080fd5b61006f6102b4565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100af578082015181840152602081019050610094565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100f2610352565b6040518082815260200191505060405180910390f35b610110610358565b6040518080602001828103825283818151815260200191508051906020019080838360005b83811015610150578082015181840152602081019050610135565b50505050905090810190601f16801561017d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101cd600480360360208110156101a157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506103f6565b6040518082815260200191505060405180910390f35b6101eb61040e565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561022b578082015181840152602081019050610210565b50505050905090810190601f1680156102585780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102b26004803603604081101561027c57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104ac565b005b60008054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561034a5780601f1061031f5761010080835404028352916020019161034a565b820191906000526020600020905b81548152906001019060200180831161032d57829003601f168201915b505050505081565b60035481565b60028054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103ee5780601f106103c3576101008083540402835291602001916103ee565b820191906000526020600020905b8154815290600101906020018083116103d157829003601f168201915b505050505081565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104a45780601f10610479576101008083540402835291602001916104a4565b820191906000526020600020905b81548152906001019060200180831161048757829003601f168201915b505050505081565b505056fea265627a7a72315820db1636e668c814a84dcdc5672de93b5ccadf4f73654bdd075585661f2fe7398f64736f6c63430005100032", + "sourceMap": "34:498:0:-;;;146:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;183:29;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;216:32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;332:126;8:9:-1;5:2;;;30:1;27;20:12;5:2;332:126:0;;;;;;;;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;332:126:0;;;;;;;;;;;;;;;;405:14;381:9;:21;391:10;381:21;;;;;;;;;;;;;;;:38;;;;439:14;425:11;:28;;;;332:126;34:498;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "34:498:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:498:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;146:33;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;146:33:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;252:26;;;:::i;:::-;;;;;;;;;;;;;;;;;;;216:32;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;216:32:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;283:44;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;283:44:0;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;183:29;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;23:1:-1;8:100;33:3;30:1;27:10;8:100;;;99:1;94:3;90:11;84:18;80:1;75:3;71:11;64:39;52:2;49:1;45:10;40:15;;8:100;;;12:14;183:29:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;462:68;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;462:68:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;146:33;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;252:26::-;;;;:::o;216:32::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;283:44::-;;;;;;;;;;;;;;;;;:::o;183:29::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;462:68::-;;;:::o", + "source": "pragma solidity >=0.4.22 <0.9.0;\n\ncontract ICOToken {\n // Constructor\n // Set the total number of tokens\n // Read the total number of tokens\n string public name = \"ICO Token\";\n string public symbol = \"ICO\";\n string public standard = \"v1.0\";\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n constructor(uint256 _initialSupply) public {\n balanceOf[msg.sender] = _initialSupply;\n totalSupply = _initialSupply;\n }\n\n function transfer(address _recipient, uint256 _amount) public {\n\n }\n}", "sourcePath": "/Users/leticiachoo/Desktop/erc-20-coin/contracts/ICOToken.sol", "ast": { "absolutePath": "project:/contracts/ICOToken.sol", "exportedSymbols": { "ICOToken": [ - 27 + 42 ] }, - "id": 28, + "id": 43, "nodeType": "SourceUnit", "nodes": [ { @@ -132,9 +152,9 @@ "contractKind": "contract", "documentation": null, "fullyImplemented": true, - "id": 27, + "id": 42, "linearizedBaseContracts": [ - 27 + 42 ], "name": "ICOToken", "nodeType": "ContractDefinition", @@ -144,7 +164,7 @@ "id": 4, "name": "name", "nodeType": "VariableDeclaration", - "scope": 27, + "scope": 42, "src": "146:33:0", "stateVariable": true, "storageLocation": "default", @@ -187,7 +207,7 @@ "id": 7, "name": "symbol", "nodeType": "VariableDeclaration", - "scope": 27, + "scope": 42, "src": "183:29:0", "stateVariable": true, "storageLocation": "default", @@ -230,7 +250,7 @@ "id": 10, "name": "standard", "nodeType": "VariableDeclaration", - "scope": 27, + "scope": 42, "src": "216:32:0", "stateVariable": true, "storageLocation": "default", @@ -250,7 +270,7 @@ }, "value": { "argumentTypes": null, - "hexValue": "76322e30", + "hexValue": "76312e30", "id": 9, "isConstant": false, "isLValue": false, @@ -261,10 +281,10 @@ "src": "242:6:0", "subdenomination": null, "typeDescriptions": { - "typeIdentifier": "t_stringliteral_788832e0f5e32208f551800bc3a63b40d5bad73f5d370941626293943c47e054", - "typeString": "literal_string \"v2.0\"" + "typeIdentifier": "t_stringliteral_e8245ed8f93ccf147bc8972ab6d5f8278ed994d647700daaa5b7ebde9370aa6f", + "typeString": "literal_string \"v1.0\"" }, - "value": "v2.0" + "value": "v1.0" }, "visibility": "public" }, @@ -273,7 +293,7 @@ "id": 12, "name": "totalSupply", "nodeType": "VariableDeclaration", - "scope": 27, + "scope": 42, "src": "252:26:0", "stateVariable": true, "storageLocation": "default", @@ -299,7 +319,7 @@ "id": 16, "name": "balanceOf", "nodeType": "VariableDeclaration", - "scope": 27, + "scope": 42, "src": "283:44:0", "stateVariable": true, "storageLocation": "default", @@ -341,26 +361,115 @@ }, { "body": { - "id": 25, + "id": 32, "nodeType": "Block", - "src": "375:70:0", + "src": "375:83:0", "statements": [ { "expression": { "argumentTypes": null, - "id": 23, + "id": 26, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, - "id": 21, + "baseExpression": { + "argumentTypes": null, + "id": 21, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 16, + "src": "381:9:0", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 24, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 22, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 57, + "src": "391:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 23, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "391:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "381:21:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 25, + "name": "_initialSupply", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 18, + "src": "405:14:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "381:38:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 27, + "nodeType": "ExpressionStatement", + "src": "381:38:0" + }, + { + "expression": { + "argumentTypes": null, + "id": 30, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 28, "name": "totalSupply", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 12, - "src": "381:11:0", + "src": "425:11:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" @@ -370,31 +479,31 @@ "operator": "=", "rightHandSide": { "argumentTypes": null, - "id": 22, + "id": 29, "name": "_initialSupply", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 18, - "src": "395:14:0", + "src": "439:14:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "src": "381:28:0", + "src": "425:28:0", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, - "id": 24, + "id": 31, "nodeType": "ExpressionStatement", - "src": "381:28:0" + "src": "425:28:0" } ] }, "documentation": null, - "id": 26, + "id": 33, "implemented": true, "kind": "constructor", "modifiers": [], @@ -409,7 +518,7 @@ "id": 18, "name": "_initialSupply", "nodeType": "VariableDeclaration", - "scope": 26, + "scope": 33, "src": "344:22:0", "stateVariable": false, "storageLocation": "default", @@ -439,25 +548,111 @@ "parameters": [], "src": "375:0:0" }, - "scope": 27, - "src": "332:113:0", + "scope": 42, + "src": "332:126:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 40, + "nodeType": "Block", + "src": "524:6:0", + "statements": [] + }, + "documentation": null, + "id": 41, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "transfer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 38, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 35, + "name": "_recipient", + "nodeType": "VariableDeclaration", + "scope": 41, + "src": "480:18:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 34, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "480:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 37, + "name": "_amount", + "nodeType": "VariableDeclaration", + "scope": 41, + "src": "500:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 36, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "500:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "479:37:0" + }, + "returnParameters": { + "id": 39, + "nodeType": "ParameterList", + "parameters": [], + "src": "524:0:0" + }, + "scope": 42, + "src": "462:68:0", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" } ], - "scope": 28, - "src": "34:413:0" + "scope": 43, + "src": "34:498:0" } ], - "src": "0:447:0" + "src": "0:532:0" }, "legacyAST": { "attributes": { "absolutePath": "project:/contracts/ICOToken.sol", "exportedSymbols": { "ICOToken": [ - 27 + 42 ] } }, @@ -490,17 +685,17 @@ "documentation": null, "fullyImplemented": true, "linearizedBaseContracts": [ - 27 + 42 ], "name": "ICOToken", - "scope": 28 + "scope": 43 }, "children": [ { "attributes": { "constant": false, "name": "name", - "scope": 27, + "scope": 42, "stateVariable": true, "storageLocation": "default", "type": "string", @@ -542,7 +737,7 @@ "attributes": { "constant": false, "name": "symbol", - "scope": 27, + "scope": 42, "stateVariable": true, "storageLocation": "default", "type": "string", @@ -584,7 +779,7 @@ "attributes": { "constant": false, "name": "standard", - "scope": 27, + "scope": 42, "stateVariable": true, "storageLocation": "default", "type": "string", @@ -603,15 +798,15 @@ { "attributes": { "argumentTypes": null, - "hexvalue": "76322e30", + "hexvalue": "76312e30", "isConstant": false, "isLValue": false, "isPure": true, "lValueRequested": false, "subdenomination": null, "token": "string", - "type": "literal_string \"v2.0\"", - "value": "v2.0" + "type": "literal_string \"v1.0\"", + "value": "v1.0" }, "id": 9, "name": "Literal", @@ -626,7 +821,7 @@ "attributes": { "constant": false, "name": "totalSupply", - "scope": 27, + "scope": 42, "stateVariable": true, "storageLocation": "default", "type": "uint256", @@ -652,7 +847,7 @@ "attributes": { "constant": false, "name": "balanceOf", - "scope": 27, + "scope": 42, "stateVariable": true, "storageLocation": "default", "type": "mapping(address => uint256)", @@ -703,7 +898,7 @@ null ], "name": "", - "scope": 27, + "scope": 42, "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" @@ -715,7 +910,7 @@ "attributes": { "constant": false, "name": "_initialSupply", - "scope": 26, + "scope": 33, "stateVariable": false, "storageLocation": "default", "type": "uint256", @@ -755,6 +950,103 @@ }, { "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 16, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 21, + "name": "Identifier", + "src": "381:9:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "sender", + "referencedDeclaration": null, + "type": "address payable" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 57, + "type": "msg", + "value": "msg" + }, + "id": 22, + "name": "Identifier", + "src": "391:3:0" + } + ], + "id": 23, + "name": "MemberAccess", + "src": "391:10:0" + } + ], + "id": 24, + "name": "IndexAccess", + "src": "381:21:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 18, + "type": "uint256", + "value": "_initialSupply" + }, + "id": 25, + "name": "Identifier", + "src": "405:14:0" + } + ], + "id": 26, + "name": "Assignment", + "src": "381:38:0" + } + ], + "id": 27, + "name": "ExpressionStatement", + "src": "381:38:0" + }, { "children": [ { @@ -778,9 +1070,9 @@ "type": "uint256", "value": "totalSupply" }, - "id": 21, + "id": 28, "name": "Identifier", - "src": "381:11:0" + "src": "425:11:0" }, { "attributes": { @@ -792,39 +1084,142 @@ "type": "uint256", "value": "_initialSupply" }, - "id": 22, + "id": 29, "name": "Identifier", - "src": "395:14:0" + "src": "439:14:0" } ], - "id": 23, + "id": 30, "name": "Assignment", - "src": "381:28:0" + "src": "425:28:0" } ], - "id": 24, + "id": 31, "name": "ExpressionStatement", - "src": "381:28:0" + "src": "425:28:0" + } + ], + "id": 32, + "name": "Block", + "src": "375:83:0" + } + ], + "id": 33, + "name": "FunctionDefinition", + "src": "332:126:0" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "modifiers": [ + null + ], + "name": "transfer", + "scope": 42, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "_recipient", + "scope": 41, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 34, + "name": "ElementaryTypeName", + "src": "480:7:0" + } + ], + "id": 35, + "name": "VariableDeclaration", + "src": "480:18:0" + }, + { + "attributes": { + "constant": false, + "name": "_amount", + "scope": 41, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 36, + "name": "ElementaryTypeName", + "src": "500:7:0" + } + ], + "id": 37, + "name": "VariableDeclaration", + "src": "500:15:0" } ], - "id": 25, + "id": 38, + "name": "ParameterList", + "src": "479:37:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 39, + "name": "ParameterList", + "src": "524:0:0" + }, + { + "attributes": { + "statements": [ + null + ] + }, + "children": [], + "id": 40, "name": "Block", - "src": "375:70:0" + "src": "524:6:0" } ], - "id": 26, + "id": 41, "name": "FunctionDefinition", - "src": "332:113:0" + "src": "462:68:0" } ], - "id": 27, + "id": 42, "name": "ContractDefinition", - "src": "34:413:0" + "src": "34:498:0" } ], - "id": 28, + "id": 43, "name": "SourceUnit", - "src": "0:447:0" + "src": "0:532:0" }, "compiler": { "name": "solc", @@ -839,8 +1234,7 @@ } }, "schemaVersion": "3.4.1", - "updatedAt": "2021-07-15T19:33:55.594Z", - "networkType": "ethereum", + "updatedAt": "2021-07-16T02:29:26.738Z", "devdoc": { "methods": {} }, diff --git a/contracts/ICOToken.sol b/contracts/ICOToken.sol index 0772177..ac95041 100644 --- a/contracts/ICOToken.sol +++ b/contracts/ICOToken.sol @@ -9,10 +9,56 @@ contract ICOToken { string public standard = "v1.0"; uint256 public totalSupply; + event Transfer( + address indexed _from, + address indexed _to, + uint256 _value + ); + + event Approval( + address indexed _owner, + address indexed _spender, + uint256 _value + ); + mapping(address => uint256) public balanceOf; + // Amount that spender is allowed on behalf of owner through transferFrom + mapping(address => mapping(address => uint256)) public allowance; constructor(uint256 _initialSupply) public { balanceOf[msg.sender] = _initialSupply; totalSupply = _initialSupply; } + + function transfer(address _recipient, uint256 _amount) public returns (bool success) { + require(balanceOf[msg.sender] >= _amount); + balanceOf[msg.sender] -= _amount; + balanceOf[_recipient] += _amount; + + emit Transfer(msg.sender, _recipient, _amount); + + return true; + } + + function approve(address _spender, uint256 _amount) public returns (bool success) { + allowance[msg.sender][_spender] = _amount; + + emit Approval(msg.sender, _spender, _amount); + + return true; + } + + function transferFrom(address _sender, address _recipient, uint256 _amount) public returns (bool success) { + require(_amount <= balanceOf[_sender]); + require(_amount <= allowance[_sender][msg.sender]); + + balanceOf[_sender] -= _amount; + balanceOf[_recipient] += _amount; + + allowance[_sender][msg.sender] -= _amount; + + emit Transfer(_sender, _recipient, _amount); + + return true; + } } \ No newline at end of file diff --git a/test/ICOToken.js b/test/ICOToken.js index 101efb4..cd8b7ce 100644 --- a/test/ICOToken.js +++ b/test/ICOToken.js @@ -27,7 +27,89 @@ contract('ICOToken', (accounts) => { return tokenInstance.balanceOf(accounts[0]); }).then((adminBalance) => { assert.equal(adminBalance.toNumber(), 50000000, 'it allocates the initial supply to the admin') - }) + }); + }); + + it('transfers token ownership', () => { + return ICOToken.deployed().then((instance) => { + tokenInstance = instance; + return tokenInstance.transfer.call(accounts[1], 99999999999); + }).then(assert.fail).catch(function(error) { + assert(error.message.indexOf('revert') >= 0, 'error message must contain revert'); + return tokenInstance.transfer.call(accounts[1], 250000, { from: accounts[0] }); + }).then(function(success) { + assert.equal(success, true, 'it returns true'); + return tokenInstance.transfer(accounts[1], 250000, { from: accounts[0] }); + }).then(function(receipt) { + assert.equal(receipt.logs.length, 1, 'triggers one event'); + assert.equal(receipt.logs[0].event, 'Transfer', 'should be the "Transfer" event'); + assert.equal(receipt.logs[0].args._from, accounts[0], 'logs the account the tokens are transferred from'); + assert.equal(receipt.logs[0].args._to, accounts[1], 'logs the account the tokens are transferred to'); + assert.equal(receipt.logs[0].args._value, 250000, 'logs the transfer amount'); + return tokenInstance.balanceOf(accounts[1]); + }).then(function(balance) { + assert.equal(balance.toNumber(), 250000, 'adds the amount to the receiving account'); + return tokenInstance.balanceOf(accounts[0]); + }).then(function(balance) { + assert.equal(balance.toNumber(), 50000000 - 250000, 'deducts the amount from the sending account'); + }); + }); + + it('approves tokens for delegated transfer', function() { + return ICOToken.deployed().then(function(instance) { + tokenInstance = instance; + return tokenInstance.approve.call(accounts[1], 100); + }).then(function(success) { + assert.equal(success, true, 'it returns true'); + return tokenInstance.approve(accounts[1], 100, { from: accounts[0] }); + }).then(function(receipt) { + assert.equal(receipt.logs.length, 1, 'triggers one event'); + assert.equal(receipt.logs[0].event, 'Approval', 'should be the "Approval" event'); + assert.equal(receipt.logs[0].args._owner, accounts[0], 'logs the account the tokens are authorized by'); + assert.equal(receipt.logs[0].args._spender, accounts[1], 'logs the account the tokens are authorized to'); + assert.equal(receipt.logs[0].args._value, 100, 'logs the transfer amount'); + return tokenInstance.allowance(accounts[0], accounts[1]); + }).then(function(allowance) { + assert.equal(allowance.toNumber(), 100, 'stores the allowance for delegated trasnfer'); + }); + }); + + it('handles delegated token transfers', function() { + return ICOToken.deployed().then(function(instance) { + tokenInstance = instance; + fromAccount = accounts[2]; + toAccount = accounts[3]; + spendingAccount = accounts[4]; + return tokenInstance.transfer(fromAccount, 100, { from: accounts[0] }); + }).then(function(receipt) { + return tokenInstance.approve(spendingAccount, 10, { from: fromAccount }); + }).then(function(receipt) { + return tokenInstance.transferFrom(fromAccount, toAccount, 9999, { from: spendingAccount }); + }).then(assert.fail).catch(function(error) { + assert(error.message.indexOf('revert') >= 0, 'cannot transfer value larger than balance'); + return tokenInstance.transferFrom(fromAccount, toAccount, 20, { from: spendingAccount }); + }).then(assert.fail).catch(function(error) { + assert(error.message.indexOf('revert') >= 0, 'cannot transfer value larger than approved amount'); + return tokenInstance.transferFrom.call(fromAccount, toAccount, 10, { from: spendingAccount }); + }).then(function(success) { + assert.equal(success, true); + return tokenInstance.transferFrom(fromAccount, toAccount, 10, { from: spendingAccount }); + }).then(function(receipt) { + assert.equal(receipt.logs.length, 1, 'triggers one event'); + assert.equal(receipt.logs[0].event, 'Transfer', 'should be the "Transfer" event'); + assert.equal(receipt.logs[0].args._from, fromAccount, 'logs the account the tokens are transferred from'); + assert.equal(receipt.logs[0].args._to, toAccount, 'logs the account the tokens are transferred to'); + assert.equal(receipt.logs[0].args._value, 10, 'logs the transfer amount'); + return tokenInstance.balanceOf(fromAccount); + }).then(function(balance) { + assert.equal(balance.toNumber(), 90, 'deducts the amount from the sending account'); + return tokenInstance.balanceOf(toAccount); + }).then(function(balance) { + assert.equal(balance.toNumber(), 10, 'adds the amount from the receiving account'); + return tokenInstance.allowance(fromAccount, spendingAccount); + }).then(function(allowance) { + assert.equal(allowance.toNumber(), 0, 'deducts the amount from the allowance'); + }); }); }); \ No newline at end of file