From a335b52034c311343b7595f3ee40f432c79b6259 Mon Sep 17 00:00:00 2001 From: Izuking Date: Mon, 22 Feb 2021 08:45:50 +0100 Subject: [PATCH] first commit --- migrations/1_initial_migration.js | 2 +- migrations/2_deploy_contracts.js | 15 + package.json | 7 +- src/abis/EthSwap.json | 4259 ++++++++++++++++++++++++ src/abis/Migrations.json | 1491 +++++++++ src/abis/Token.json | 5150 +++++++++++++++++++++++++++++ src/components/App.js | 186 +- src/components/BuyForm.js | 79 + src/components/Main.js | 56 + src/components/Navbar.js | 38 + src/components/SellForm.js | 85 + src/contracts/EthSwap.sol | 57 + src/contracts/Migrations.sol | 30 +- src/contracts/Token.sol | 51 + src/eth-logo.png | Bin 0 -> 4472 bytes src/token-logo.png | Bin 0 -> 3729 bytes test/ethSwap.test.js | 92 + truffle-config.js | 3 +- 18 files changed, 11535 insertions(+), 66 deletions(-) create mode 100644 migrations/2_deploy_contracts.js create mode 100644 src/abis/EthSwap.json create mode 100644 src/abis/Migrations.json create mode 100644 src/abis/Token.json create mode 100644 src/components/BuyForm.js create mode 100644 src/components/Main.js create mode 100644 src/components/Navbar.js create mode 100644 src/components/SellForm.js create mode 100644 src/contracts/EthSwap.sol create mode 100644 src/contracts/Token.sol create mode 100644 src/eth-logo.png create mode 100644 src/token-logo.png create mode 100644 test/ethSwap.test.js diff --git a/migrations/1_initial_migration.js b/migrations/1_initial_migration.js index ee2135d29..a664edda6 100644 --- a/migrations/1_initial_migration.js +++ b/migrations/1_initial_migration.js @@ -2,4 +2,4 @@ const Migrations = artifacts.require("Migrations"); module.exports = function(deployer) { deployer.deploy(Migrations); -}; +}; \ No newline at end of file diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js new file mode 100644 index 000000000..f481958e2 --- /dev/null +++ b/migrations/2_deploy_contracts.js @@ -0,0 +1,15 @@ +const Token = artifacts.require("Token"); +const EthSwap = artifacts.require("EthSwap"); + +module.exports = async function(deployer) { + //deploy Token + await deployer.deploy(Token); + const token = await Token.deployed(); + + //deploy EthSwap + await deployer.deploy(EthSwap, token.address); + const ethSwap = await EthSwap.deployed(); + + //transfer all tokens to EthSwap (1 million) + token.transfer(ethSwap.address, "1000000000000000000000000"); +}; diff --git a/package.json b/package.json index 6c1ffc537..37642031e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "eth-marketplace", + "name": "eth-swap", "version": "0.1.0", - "description": "An Ethereum Marketplace", + "description": "An instant ERC20 crypto exchange", "author": "gregory@dappuniversity.com", "dependencies": { "babel-polyfill": "6.26.0", @@ -14,11 +14,12 @@ "chai": "4.2.0", "chai-as-promised": "7.1.1", "chai-bignumber": "3.0.0", + "identicon.js": "^2.3.3", "react": "16.8.4", "react-bootstrap": "1.0.0-beta.5", "react-dom": "16.8.4", "react-scripts": "2.1.3", - "truffle": "5.0.5", + "truffle": "^5.1.66", "web3": "1.0.0-beta.55" }, "scripts": { diff --git a/src/abis/EthSwap.json b/src/abis/EthSwap.json new file mode 100644 index 000000000..5a3da3f53 --- /dev/null +++ b/src/abis/EthSwap.json @@ -0,0 +1,4259 @@ +{ + "contractName": "EthSwap", + "abi": [ + { + "inputs": [ + { + "internalType": "contract Token", + "name": "_token", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "TokensPurchase", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "TokensSold", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "token", + "outputs": [ + { + "internalType": "contract Token", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "buyTokens", + "outputs": [], + "payable": true, + "stateMutability": "payable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "sellTokens", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract Token\",\"name\":\"_token\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rate\",\"type\":\"uint256\"}],\"name\":\"TokensPurchase\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"rate\",\"type\":\"uint256\"}],\"name\":\"TokensSold\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"buyTokens\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"sellTokens\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contract Token\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/EthSwap.sol\":\"EthSwap\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/EthSwap.sol\":{\"keccak256\":\"0x89b88ce4bbdeda3d27be745420f7b529f3f16e824df243fe7df4e457ca3d3fa8\",\"urls\":[\"bzz-raw://a3616176108a48b29ba7a00195710f427871351e0479b83ad9b8e2560fd10930\",\"dweb:/ipfs/QmdwnXeyQ5kknWGNgzgqppe4LgPfRE9vBpRc4iACBdRS99\"]},\"/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol\":{\"keccak256\":\"0x9030fca2a55f386312a637f48f53b364c61c41868e7192612ff86040d7cc985d\",\"urls\":[\"bzz-raw://f454e80fb8c1db9adeaa48b4a811c23de9f1f3e899f36ac8bae6caba37ce5a9f\",\"dweb:/ipfs/QmWV2HJL56dez2rmxofktNnzX28EDCMSiXk1BeaWDjdnu5\"]}},\"version\":1}", + "bytecode": "0x60806040526040518060400160405280601981526020017f4574685377617020496e7374616e74732065786368616e6765000000000000008152506000908051906020019061004f9291906100dc565b50606460025534801561006157600080fd5b506040516109cd3803806109cd8339818101604052602081101561008457600080fd5b810190808051906020019092919050505080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610181565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061011d57805160ff191683800117855561014b565b8280016001018555821561014b579182015b8281111561014a57825182559160200191906001019061012f565b5b509050610158919061015c565b5090565b61017e91905b8082111561017a576000816000905550600101610162565b5090565b90565b61083d806101906000396000f3fe60806040526004361061003f5760003560e01c806306fdde03146100445780636c11bcd3146100d4578063d0febe4c1461010f578063fc0c546a14610119575b600080fd5b34801561005057600080fd5b50610059610170565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561009957808201518184015260208101905061007e565b50505050905090810190601f1680156100c65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156100e057600080fd5b5061010d600480360360208110156100f757600080fd5b810190808035906020019092919050505061020e565b005b610117610540565b005b34801561012557600080fd5b5061012e6107e2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102065780601f106101db57610100808354040283529160200191610206565b820191906000526020600020905b8154815290600101906020018083116101e957829003601f168201915b505050505081565b80600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156102ae57600080fd5b505afa1580156102c2573d6000803e3d6000fd5b505050506040513d60208110156102d857600080fd5b810190808051906020019092919050505010156102f457600080fd5b6000600254828161030157fe5b0490508047101561031157600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156103ee57600080fd5b505af1158015610402573d6000803e3d6000fd5b505050506040513d602081101561041857600080fd5b8101908080519060200190929190505050503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610470573d6000803e3d6000fd5b507f697c42d55a5e1fed3f464ec6f38b32546a0bd368dc8068b065c67566d73f329033600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684600254604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200194505050505060405180910390a15050565b60003460025402905080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156105e957600080fd5b505afa1580156105fd573d6000803e3d6000fd5b505050506040513d602081101561061357600080fd5b8101908080519060200190929190505050101561062f57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156106d857600080fd5b505af11580156106ec573d6000803e3d6000fd5b505050506040513d602081101561070257600080fd5b8101908080519060200190929190505050507fbe52c1773bb2528744725b29470d0cb959c94e22fc4817ad800fd3d83816dbad33600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683600254604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200194505050505060405180910390a150565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea265627a7a72315820ad4d72d2daf6b00fe45e1a2093dd99ebc29e6722af56369df94f4fc28da4acb064736f6c63430005100032", + "deployedBytecode": "0x60806040526004361061003f5760003560e01c806306fdde03146100445780636c11bcd3146100d4578063d0febe4c1461010f578063fc0c546a14610119575b600080fd5b34801561005057600080fd5b50610059610170565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561009957808201518184015260208101905061007e565b50505050905090810190601f1680156100c65780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156100e057600080fd5b5061010d600480360360208110156100f757600080fd5b810190808035906020019092919050505061020e565b005b610117610540565b005b34801561012557600080fd5b5061012e6107e2565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102065780601f106101db57610100808354040283529160200191610206565b820191906000526020600020905b8154815290600101906020018083116101e957829003601f168201915b505050505081565b80600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231336040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156102ae57600080fd5b505afa1580156102c2573d6000803e3d6000fd5b505050506040513d60208110156102d857600080fd5b810190808051906020019092919050505010156102f457600080fd5b6000600254828161030157fe5b0490508047101561031157600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b1580156103ee57600080fd5b505af1158015610402573d6000803e3d6000fd5b505050506040513d602081101561041857600080fd5b8101908080519060200190929190505050503373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050158015610470573d6000803e3d6000fd5b507f697c42d55a5e1fed3f464ec6f38b32546a0bd368dc8068b065c67566d73f329033600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684600254604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200194505050505060405180910390a15050565b60003460025402905080600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060206040518083038186803b1580156105e957600080fd5b505afa1580156105fd573d6000803e3d6000fd5b505050506040513d602081101561061357600080fd5b8101908080519060200190929190505050101561062f57600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb33836040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050602060405180830381600087803b1580156106d857600080fd5b505af11580156106ec573d6000803e3d6000fd5b505050506040513d602081101561070257600080fd5b8101908080519060200190929190505050507fbe52c1773bb2528744725b29470d0cb959c94e22fc4817ad800fd3d83816dbad33600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1683600254604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200182815260200194505050505060405180910390a150565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168156fea265627a7a72315820ad4d72d2daf6b00fe45e1a2093dd99ebc29e6722af56369df94f4fc28da4acb064736f6c63430005100032", + "sourceMap": "48:1673:0:-;;;71:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;164:3;149:18;;423:64;8:9:-1;5:2;;;30:1;27;20:12;5:2;423:64:0;;;;;;;;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;423:64:0;;;;;;;;;;;;;;;;474:6;466:5;;:14;;;;;;;;;;;;;;;;;;423:64;48:1673;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "48:1673:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;71:48;;8:9:-1;5:2;;;30:1;27;20:12;5:2;71:48:0;;;:::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;71:48:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1037:682;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1037:682:0;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1037:682:0;;;;;;;;;;;;;;;;;:::i;:::-;;493:535;;;:::i;:::-;;125:18;;8:9:-1;5:2;;;30:1;27;20:12;5:2;125:18:0;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;71:48;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;1037:682::-;1182:7;1151:5;;;;;;;;;;;:15;;;1167:10;1151:27;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1151:27:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1151:27:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1151:27:0;;;;;;;;;;;;;;;;:38;;1143:47;;;;;;1250:18;1282:4;;1272:7;:14;;;;;;1250:36;;1389:10;1364:21;:35;;1356:44;;;;;;1524:5;;;;;;;;;;;:18;;;1543:10;1563:4;1570:7;1524:54;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1524:54:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1524:54:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1524:54:0;;;;;;;;;;;;;;;;;1588:10;:19;;:31;1608:10;1588:31;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1588:31:0;1659:53;1670:10;1690:5;;;;;;;;;;;1698:7;1707:4;;1659:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1037:682;;:::o;493:535::-;587:19;616:9;609:4;;:16;587:38;;737:11;703:5;;;;;;;;;;;:15;;;727:4;703:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;703:30:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;703:30:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;703:30:0;;;;;;;;;;;;;;;;:45;;695:54;;;;;;873:5;;;;;;;;;;;:14;;;888:10;900:11;873:39;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;873:39:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;873:39:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;873:39:0;;;;;;;;;;;;;;;;;960:61;975:10;995:5;;;;;;;;;;;1003:11;1016:4;;960:61;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;493:535;:::o;125:18::-;;;;;;;;;;;;;:::o", + "source": "pragma solidity ^0.5.0;\n\nimport \"./Token.sol\";\n\ncontract EthSwap {\n string public name = \"EthSwap Instants exchange\";\n Token public token;\n uint256 rate = 100;\n event TokensPurchase(\n address account,\n address token,\n uint256 amount,\n uint256 rate\n );\n\n event TokensSold(\n address account,\n address token,\n uint256 amount,\n uint256 rate\n );\n\n constructor(Token _token) public {\n token = _token;\n }\n\n function buyTokens() public payable {\n //calculate the number of tokens to buy\n uint256 tokenAmount = rate * msg.value;\n \n // requires that EthSwap has enough tokens\n require(token.balanceOf(address(this)) >= tokenAmount);// note the 'this' refferences the contract address (ie EthSwap address)\n \n //transfer token to user\n token.transfer(msg.sender, tokenAmount);\n \n //Emit an event\n emit TokensPurchase(msg.sender, address(token), tokenAmount, rate);\n }\n \n function sellTokens(uint _amount) public {\n // users can't sell more tokens than they have\n require(token.balanceOf(msg.sender) >= _amount);\n //calculate the number of ether to redeem\n uint256 etheAmount = _amount / rate;\n \n // requires that EthSwap has enough ethers\n require(address(this).balance >= etheAmount);// note the 'this' refferences the contract address (ie EthSwap address)\n \n //transfer token to user\n token.transferFrom(msg.sender, address(this), _amount);\n msg.sender.transfer(etheAmount);\n\n //Emit an event\n emit TokensSold(msg.sender, address(token), _amount, rate);\n }\n}\n", + "sourcePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/EthSwap.sol", + "ast": { + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/EthSwap.sol", + "exportedSymbols": { + "EthSwap": [ + 141 + ] + }, + "id": 142, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 1, + "literals": [ + "solidity", + "^", + "0.5", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:23:0" + }, + { + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol", + "file": "./Token.sol", + "id": 2, + "nodeType": "ImportDirective", + "scope": 142, + "sourceUnit": 380, + "src": "25:21:0", + "symbolAliases": [], + "unitAlias": "" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 141, + "linearizedBaseContracts": [ + 141 + ], + "name": "EthSwap", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 5, + "name": "name", + "nodeType": "VariableDeclaration", + "scope": 141, + "src": "71:48:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_storage", + "typeString": "string" + }, + "typeName": { + "id": 3, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "71:6:0", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "value": { + "argumentTypes": null, + "hexValue": "4574685377617020496e7374616e74732065786368616e6765", + "id": 4, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "92:27:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_09eb895bb1644ca62c23c793038b0bbc19edc8637bd160ff5b73e322fa7b7c1e", + "typeString": "literal_string \"EthSwap Instants exchange\"" + }, + "value": "EthSwap Instants exchange" + }, + "visibility": "public" + }, + { + "constant": false, + "id": 7, + "name": "token", + "nodeType": "VariableDeclaration", + "scope": 141, + "src": "125:18:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + }, + "typeName": { + "contractScope": null, + "id": 6, + "name": "Token", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 379, + "src": "125:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 10, + "name": "rate", + "nodeType": "VariableDeclaration", + "scope": 141, + "src": "149:18:0", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 8, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "149:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": { + "argumentTypes": null, + "hexValue": "313030", + "id": 9, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "164:3:0", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_100_by_1", + "typeString": "int_const 100" + }, + "value": "100" + }, + "visibility": "internal" + }, + { + "anonymous": false, + "documentation": null, + "id": 20, + "name": "TokensPurchase", + "nodeType": "EventDefinition", + "parameters": { + "id": 19, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 12, + "indexed": false, + "name": "account", + "nodeType": "VariableDeclaration", + "scope": 20, + "src": "203:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 11, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "203:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 14, + "indexed": false, + "name": "token", + "nodeType": "VariableDeclaration", + "scope": 20, + "src": "228:13:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 13, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "228:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 16, + "indexed": false, + "name": "amount", + "nodeType": "VariableDeclaration", + "scope": 20, + "src": "251:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 15, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "251:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 18, + "indexed": false, + "name": "rate", + "nodeType": "VariableDeclaration", + "scope": 20, + "src": "275:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 17, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "275:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "193:100:0" + }, + "src": "173:121:0" + }, + { + "anonymous": false, + "documentation": null, + "id": 30, + "name": "TokensSold", + "nodeType": "EventDefinition", + "parameters": { + "id": 29, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 22, + "indexed": false, + "name": "account", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "326:15:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 21, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "326:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 24, + "indexed": false, + "name": "token", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "351:13:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 23, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "351:7:0", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 26, + "indexed": false, + "name": "amount", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "374:14:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 25, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "374:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 28, + "indexed": false, + "name": "rate", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "398:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 27, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "398:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "316:100:0" + }, + "src": "300:117:0" + }, + { + "body": { + "id": 39, + "nodeType": "Block", + "src": "456:31:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 37, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 35, + "name": "token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "466:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 36, + "name": "_token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 32, + "src": "474:6:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "src": "466:14:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "id": 38, + "nodeType": "ExpressionStatement", + "src": "466:14:0" + } + ] + }, + "documentation": null, + "id": 40, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 33, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 32, + "name": "_token", + "nodeType": "VariableDeclaration", + "scope": 40, + "src": "435:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + }, + "typeName": { + "contractScope": null, + "id": 31, + "name": "Token", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 379, + "src": "435:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "434:14:0" + }, + "returnParameters": { + "id": 34, + "nodeType": "ParameterList", + "parameters": [], + "src": "456:0:0" + }, + "scope": 141, + "src": "423:64:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 79, + "nodeType": "Block", + "src": "529:499:0", + "statements": [ + { + "assignments": [ + 44 + ], + "declarations": [ + { + "constant": false, + "id": 44, + "name": "tokenAmount", + "nodeType": "VariableDeclaration", + "scope": 79, + "src": "587:19:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 43, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "587:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 49, + "initialValue": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 48, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 45, + "name": "rate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 10, + "src": "609:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "*", + "rightExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 46, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "616:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 47, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "value", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "616:9:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "609:16:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "587:38:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 58, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 54, + "name": "this", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 410, + "src": "727:4:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + ], + "id": 53, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "719:7:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": "address" + }, + "id": 55, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "719:13:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "expression": { + "argumentTypes": null, + "id": 51, + "name": "token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "703:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "id": 52, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "balanceOf", + "nodeType": "MemberAccess", + "referencedDeclaration": 232, + "src": "703:15:0", + "typeDescriptions": { + "typeIdentifier": "t_function_external_view$_t_address_$returns$_t_uint256_$", + "typeString": "function (address) view external returns (uint256)" + } + }, + "id": 56, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "703:30:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 57, + "name": "tokenAmount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 44, + "src": "737:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "703:45:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 50, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "src": "695:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 59, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "695:54:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 60, + "nodeType": "ExpressionStatement", + "src": "695:54:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 64, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "888:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 65, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "888:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + { + "argumentTypes": null, + "id": 66, + "name": "tokenAmount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 44, + "src": "900:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 61, + "name": "token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "873:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "id": 63, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": 290, + "src": "873:14:0", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_uint256_$returns$_t_bool_$", + "typeString": "function (address,uint256) external returns (bool)" + } + }, + "id": 67, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "873:39:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 68, + "nodeType": "ExpressionStatement", + "src": "873:39:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 70, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "975:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 71, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "975:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 73, + "name": "token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "995:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + ], + "id": 72, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "987:7:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": "address" + }, + "id": 74, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "987:14:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 75, + "name": "tokenAmount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 44, + "src": "1003:11:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + { + "argumentTypes": null, + "id": 76, + "name": "rate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 10, + "src": "1016:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 69, + "name": "TokensPurchase", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 20, + "src": "960:14:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256,uint256)" + } + }, + "id": 77, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "960:61:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 78, + "nodeType": "EmitStatement", + "src": "955:66:0" + } + ] + }, + "documentation": null, + "id": 80, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "buyTokens", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 41, + "nodeType": "ParameterList", + "parameters": [], + "src": "511:2:0" + }, + "returnParameters": { + "id": 42, + "nodeType": "ParameterList", + "parameters": [], + "src": "529:0:0" + }, + "scope": 141, + "src": "493:535:0", + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 139, + "nodeType": "Block", + "src": "1078:641:0", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 92, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 88, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1167:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 89, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1167:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + ], + "expression": { + "argumentTypes": null, + "id": 86, + "name": "token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1151:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "id": 87, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "balanceOf", + "nodeType": "MemberAccess", + "referencedDeclaration": 232, + "src": "1151:15:0", + "typeDescriptions": { + "typeIdentifier": "t_function_external_view$_t_address_$returns$_t_uint256_$", + "typeString": "function (address) view external returns (uint256)" + } + }, + "id": 90, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1151:27:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 91, + "name": "_amount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 82, + "src": "1182:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1151:38:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 85, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "src": "1143:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 93, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1143:47:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 94, + "nodeType": "ExpressionStatement", + "src": "1143:47:0" + }, + { + "assignments": [ + 96 + ], + "declarations": [ + { + "constant": false, + "id": 96, + "name": "etheAmount", + "nodeType": "VariableDeclaration", + "scope": 139, + "src": "1250:18:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 95, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "1250:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 100, + "initialValue": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 99, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 97, + "name": "_amount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 82, + "src": "1272:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "/", + "rightExpression": { + "argumentTypes": null, + "id": 98, + "name": "rate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 10, + "src": "1282:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1272:14:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "1250:36:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 107, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 103, + "name": "this", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 410, + "src": "1372:4:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + ], + "id": 102, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "1364:7:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": "address" + }, + "id": 104, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1364:13:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 105, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "balance", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1364:21:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 106, + "name": "etheAmount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 96, + "src": "1389:10:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1364:35:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 101, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "src": "1356:7:0", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 108, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1356:44:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 109, + "nodeType": "ExpressionStatement", + "src": "1356:44:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 113, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1543:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 114, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1543:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 116, + "name": "this", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 410, + "src": "1563:4:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + ], + "id": 115, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "1555:7:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": "address" + }, + "id": 117, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1555:13:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 118, + "name": "_amount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 82, + "src": "1570:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 110, + "name": "token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1524:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + }, + "id": 112, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transferFrom", + "nodeType": "MemberAccess", + "referencedDeclaration": 378, + "src": "1524:18:0", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$_t_bool_$", + "typeString": "function (address,address,uint256) external returns (bool)" + } + }, + "id": 119, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1524:54:0", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "id": 120, + "nodeType": "ExpressionStatement", + "src": "1524:54:0" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 126, + "name": "etheAmount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 96, + "src": "1608:10:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 121, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1588:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 124, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1588:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "id": 125, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "transfer", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1588:19:0", + "typeDescriptions": { + "typeIdentifier": "t_function_transfer_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256)" + } + }, + "id": 127, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1588:31:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 128, + "nodeType": "ExpressionStatement", + "src": "1588:31:0" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 130, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1670:3:0", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 131, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1670:10:0", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 133, + "name": "token", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 7, + "src": "1690:5:0", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + ], + "id": 132, + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "nodeType": "ElementaryTypeNameExpression", + "src": "1682:7:0", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_address_$", + "typeString": "type(address)" + }, + "typeName": "address" + }, + "id": 134, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1682:14:0", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 135, + "name": "_amount", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 82, + "src": "1698:7:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + { + "argumentTypes": null, + "id": 136, + "name": "rate", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 10, + "src": "1707:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 129, + "name": "TokensSold", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 30, + "src": "1659:10:0", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256,uint256)" + } + }, + "id": 137, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1659:53:0", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 138, + "nodeType": "EmitStatement", + "src": "1654:58:0" + } + ] + }, + "documentation": null, + "id": 140, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "sellTokens", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 83, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 82, + "name": "_amount", + "nodeType": "VariableDeclaration", + "scope": 140, + "src": "1057:12:0", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 81, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "1057:4:0", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1056:14:0" + }, + "returnParameters": { + "id": 84, + "nodeType": "ParameterList", + "parameters": [], + "src": "1078:0:0" + }, + "scope": 141, + "src": "1037:682:0", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 142, + "src": "48:1673:0" + } + ], + "src": "0:1722:0" + }, + "legacyAST": { + "attributes": { + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/EthSwap.sol", + "exportedSymbols": { + "EthSwap": [ + 141 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "^", + "0.5", + ".0" + ] + }, + "id": 1, + "name": "PragmaDirective", + "src": "0:23:0" + }, + { + "attributes": { + "SourceUnit": 380, + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol", + "file": "./Token.sol", + "scope": 142, + "symbolAliases": [ + null + ], + "unitAlias": "" + }, + "id": 2, + "name": "ImportDirective", + "src": "25:21:0" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 141 + ], + "name": "EthSwap", + "scope": 142 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "name", + "scope": 141, + "stateVariable": true, + "storageLocation": "default", + "type": "string", + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string" + }, + "id": 3, + "name": "ElementaryTypeName", + "src": "71:6:0" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "4574685377617020496e7374616e74732065786368616e6765", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "string", + "type": "literal_string \"EthSwap Instants exchange\"", + "value": "EthSwap Instants exchange" + }, + "id": 4, + "name": "Literal", + "src": "92:27:0" + } + ], + "id": 5, + "name": "VariableDeclaration", + "src": "71:48:0" + }, + { + "attributes": { + "constant": false, + "name": "token", + "scope": 141, + "stateVariable": true, + "storageLocation": "default", + "type": "contract Token", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "contractScope": null, + "name": "Token", + "referencedDeclaration": 379, + "type": "contract Token" + }, + "id": 6, + "name": "UserDefinedTypeName", + "src": "125:5:0" + } + ], + "id": 7, + "name": "VariableDeclaration", + "src": "125:18:0" + }, + { + "attributes": { + "constant": false, + "name": "rate", + "scope": 141, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 8, + "name": "ElementaryTypeName", + "src": "149:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "313030", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 100", + "value": "100" + }, + "id": 9, + "name": "Literal", + "src": "164:3:0" + } + ], + "id": 10, + "name": "VariableDeclaration", + "src": "149:18:0" + }, + { + "attributes": { + "anonymous": false, + "documentation": null, + "name": "TokensPurchase" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "indexed": false, + "name": "account", + "scope": 20, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 11, + "name": "ElementaryTypeName", + "src": "203:7:0" + } + ], + "id": 12, + "name": "VariableDeclaration", + "src": "203:15:0" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "token", + "scope": 20, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 13, + "name": "ElementaryTypeName", + "src": "228:7:0" + } + ], + "id": 14, + "name": "VariableDeclaration", + "src": "228:13:0" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "amount", + "scope": 20, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 15, + "name": "ElementaryTypeName", + "src": "251:7:0" + } + ], + "id": 16, + "name": "VariableDeclaration", + "src": "251:14:0" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "rate", + "scope": 20, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 17, + "name": "ElementaryTypeName", + "src": "275:7:0" + } + ], + "id": 18, + "name": "VariableDeclaration", + "src": "275:12:0" + } + ], + "id": 19, + "name": "ParameterList", + "src": "193:100:0" + } + ], + "id": 20, + "name": "EventDefinition", + "src": "173:121:0" + }, + { + "attributes": { + "anonymous": false, + "documentation": null, + "name": "TokensSold" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "indexed": false, + "name": "account", + "scope": 30, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 21, + "name": "ElementaryTypeName", + "src": "326:7:0" + } + ], + "id": 22, + "name": "VariableDeclaration", + "src": "326:15:0" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "token", + "scope": 30, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 23, + "name": "ElementaryTypeName", + "src": "351:7:0" + } + ], + "id": 24, + "name": "VariableDeclaration", + "src": "351:13:0" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "amount", + "scope": 30, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 25, + "name": "ElementaryTypeName", + "src": "374:7:0" + } + ], + "id": 26, + "name": "VariableDeclaration", + "src": "374:14:0" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "rate", + "scope": 30, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 27, + "name": "ElementaryTypeName", + "src": "398:7:0" + } + ], + "id": 28, + "name": "VariableDeclaration", + "src": "398:12:0" + } + ], + "id": 29, + "name": "ParameterList", + "src": "316:100:0" + } + ], + "id": 30, + "name": "EventDefinition", + "src": "300:117:0" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": true, + "kind": "constructor", + "modifiers": [ + null + ], + "name": "", + "scope": 141, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "_token", + "scope": 40, + "stateVariable": false, + "storageLocation": "default", + "type": "contract Token", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "contractScope": null, + "name": "Token", + "referencedDeclaration": 379, + "type": "contract Token" + }, + "id": 31, + "name": "UserDefinedTypeName", + "src": "435:5:0" + } + ], + "id": 32, + "name": "VariableDeclaration", + "src": "435:12:0" + } + ], + "id": 33, + "name": "ParameterList", + "src": "434:14:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 34, + "name": "ParameterList", + "src": "456:0:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "contract Token" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "contract Token", + "value": "token" + }, + "id": 35, + "name": "Identifier", + "src": "466:5:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 32, + "type": "contract Token", + "value": "_token" + }, + "id": 36, + "name": "Identifier", + "src": "474:6:0" + } + ], + "id": 37, + "name": "Assignment", + "src": "466:14:0" + } + ], + "id": 38, + "name": "ExpressionStatement", + "src": "466:14:0" + } + ], + "id": 39, + "name": "Block", + "src": "456:31:0" + } + ], + "id": 40, + "name": "FunctionDefinition", + "src": "423:64:0" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "modifiers": [ + null + ], + "name": "buyTokens", + "scope": 141, + "stateMutability": "payable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 41, + "name": "ParameterList", + "src": "511:2:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 42, + "name": "ParameterList", + "src": "529:0:0" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 44 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "tokenAmount", + "scope": 79, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 43, + "name": "ElementaryTypeName", + "src": "587:7:0" + } + ], + "id": 44, + "name": "VariableDeclaration", + "src": "587:19:0" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "*", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 10, + "type": "uint256", + "value": "rate" + }, + "id": 45, + "name": "Identifier", + "src": "609:4:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "value", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 394, + "type": "msg", + "value": "msg" + }, + "id": 46, + "name": "Identifier", + "src": "616:3:0" + } + ], + "id": 47, + "name": "MemberAccess", + "src": "616:9:0" + } + ], + "id": 48, + "name": "BinaryOperation", + "src": "609:16:0" + } + ], + "id": 49, + "name": "VariableDeclarationStatement", + "src": "587:38:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "type": "function (bool) pure", + "value": "require" + }, + "id": 50, + "name": "Identifier", + "src": "695:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": ">=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "uint256", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "balanceOf", + "referencedDeclaration": 232, + "type": "function (address) view external returns (uint256)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "contract Token", + "value": "token" + }, + "id": 51, + "name": "Identifier", + "src": "703:5:0" + } + ], + "id": 52, + "name": "MemberAccess", + "src": "703:15:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "address", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(address)", + "value": "address" + }, + "id": 53, + "name": "ElementaryTypeNameExpression", + "src": "719:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 410, + "type": "contract EthSwap", + "value": "this" + }, + "id": 54, + "name": "Identifier", + "src": "727:4:0" + } + ], + "id": 55, + "name": "FunctionCall", + "src": "719:13:0" + } + ], + "id": 56, + "name": "FunctionCall", + "src": "703:30:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 44, + "type": "uint256", + "value": "tokenAmount" + }, + "id": 57, + "name": "Identifier", + "src": "737:11:0" + } + ], + "id": 58, + "name": "BinaryOperation", + "src": "703:45:0" + } + ], + "id": 59, + "name": "FunctionCall", + "src": "695:54:0" + } + ], + "id": 60, + "name": "ExpressionStatement", + "src": "695:54:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "bool", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "transfer", + "referencedDeclaration": 290, + "type": "function (address,uint256) external returns (bool)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "contract Token", + "value": "token" + }, + "id": 61, + "name": "Identifier", + "src": "873:5:0" + } + ], + "id": 63, + "name": "MemberAccess", + "src": "873:14: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": 394, + "type": "msg", + "value": "msg" + }, + "id": 64, + "name": "Identifier", + "src": "888:3:0" + } + ], + "id": 65, + "name": "MemberAccess", + "src": "888:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 44, + "type": "uint256", + "value": "tokenAmount" + }, + "id": 66, + "name": "Identifier", + "src": "900:11:0" + } + ], + "id": 67, + "name": "FunctionCall", + "src": "873:39:0" + } + ], + "id": 68, + "name": "ExpressionStatement", + "src": "873:39:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 20, + "type": "function (address,address,uint256,uint256)", + "value": "TokensPurchase" + }, + "id": 69, + "name": "Identifier", + "src": "960:14: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": 394, + "type": "msg", + "value": "msg" + }, + "id": 70, + "name": "Identifier", + "src": "975:3:0" + } + ], + "id": 71, + "name": "MemberAccess", + "src": "975:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "address", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(address)", + "value": "address" + }, + "id": 72, + "name": "ElementaryTypeNameExpression", + "src": "987:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "contract Token", + "value": "token" + }, + "id": 73, + "name": "Identifier", + "src": "995:5:0" + } + ], + "id": 74, + "name": "FunctionCall", + "src": "987:14:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 44, + "type": "uint256", + "value": "tokenAmount" + }, + "id": 75, + "name": "Identifier", + "src": "1003:11:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 10, + "type": "uint256", + "value": "rate" + }, + "id": 76, + "name": "Identifier", + "src": "1016:4:0" + } + ], + "id": 77, + "name": "FunctionCall", + "src": "960:61:0" + } + ], + "id": 78, + "name": "EmitStatement", + "src": "955:66:0" + } + ], + "id": 79, + "name": "Block", + "src": "529:499:0" + } + ], + "id": 80, + "name": "FunctionDefinition", + "src": "493:535:0" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "modifiers": [ + null + ], + "name": "sellTokens", + "scope": 141, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "_amount", + "scope": 140, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint", + "type": "uint256" + }, + "id": 81, + "name": "ElementaryTypeName", + "src": "1057:4:0" + } + ], + "id": 82, + "name": "VariableDeclaration", + "src": "1057:12:0" + } + ], + "id": 83, + "name": "ParameterList", + "src": "1056:14:0" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 84, + "name": "ParameterList", + "src": "1078:0:0" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "type": "function (bool) pure", + "value": "require" + }, + "id": 85, + "name": "Identifier", + "src": "1143:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": ">=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "uint256", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "balanceOf", + "referencedDeclaration": 232, + "type": "function (address) view external returns (uint256)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "contract Token", + "value": "token" + }, + "id": 86, + "name": "Identifier", + "src": "1151:5:0" + } + ], + "id": 87, + "name": "MemberAccess", + "src": "1151:15: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": 394, + "type": "msg", + "value": "msg" + }, + "id": 88, + "name": "Identifier", + "src": "1167:3:0" + } + ], + "id": 89, + "name": "MemberAccess", + "src": "1167:10:0" + } + ], + "id": 90, + "name": "FunctionCall", + "src": "1151:27:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 82, + "type": "uint256", + "value": "_amount" + }, + "id": 91, + "name": "Identifier", + "src": "1182:7:0" + } + ], + "id": 92, + "name": "BinaryOperation", + "src": "1151:38:0" + } + ], + "id": 93, + "name": "FunctionCall", + "src": "1143:47:0" + } + ], + "id": 94, + "name": "ExpressionStatement", + "src": "1143:47:0" + }, + { + "attributes": { + "assignments": [ + 96 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "etheAmount", + "scope": 139, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 95, + "name": "ElementaryTypeName", + "src": "1250:7:0" + } + ], + "id": 96, + "name": "VariableDeclaration", + "src": "1250:18:0" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "/", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 82, + "type": "uint256", + "value": "_amount" + }, + "id": 97, + "name": "Identifier", + "src": "1272:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 10, + "type": "uint256", + "value": "rate" + }, + "id": 98, + "name": "Identifier", + "src": "1282:4:0" + } + ], + "id": 99, + "name": "BinaryOperation", + "src": "1272:14:0" + } + ], + "id": 100, + "name": "VariableDeclarationStatement", + "src": "1250:36:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "type": "function (bool) pure", + "value": "require" + }, + "id": 101, + "name": "Identifier", + "src": "1356:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": ">=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "balance", + "referencedDeclaration": null, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "address", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(address)", + "value": "address" + }, + "id": 102, + "name": "ElementaryTypeNameExpression", + "src": "1364:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 410, + "type": "contract EthSwap", + "value": "this" + }, + "id": 103, + "name": "Identifier", + "src": "1372:4:0" + } + ], + "id": 104, + "name": "FunctionCall", + "src": "1364:13:0" + } + ], + "id": 105, + "name": "MemberAccess", + "src": "1364:21:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 96, + "type": "uint256", + "value": "etheAmount" + }, + "id": 106, + "name": "Identifier", + "src": "1389:10:0" + } + ], + "id": 107, + "name": "BinaryOperation", + "src": "1364:35:0" + } + ], + "id": 108, + "name": "FunctionCall", + "src": "1356:44:0" + } + ], + "id": 109, + "name": "ExpressionStatement", + "src": "1356:44:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "bool", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "transferFrom", + "referencedDeclaration": 378, + "type": "function (address,address,uint256) external returns (bool)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "contract Token", + "value": "token" + }, + "id": 110, + "name": "Identifier", + "src": "1524:5:0" + } + ], + "id": 112, + "name": "MemberAccess", + "src": "1524:18: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": 394, + "type": "msg", + "value": "msg" + }, + "id": 113, + "name": "Identifier", + "src": "1543:3:0" + } + ], + "id": 114, + "name": "MemberAccess", + "src": "1543:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "address", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_EthSwap_$141", + "typeString": "contract EthSwap" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(address)", + "value": "address" + }, + "id": 115, + "name": "ElementaryTypeNameExpression", + "src": "1555:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 410, + "type": "contract EthSwap", + "value": "this" + }, + "id": 116, + "name": "Identifier", + "src": "1563:4:0" + } + ], + "id": 117, + "name": "FunctionCall", + "src": "1555:13:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 82, + "type": "uint256", + "value": "_amount" + }, + "id": 118, + "name": "Identifier", + "src": "1570:7:0" + } + ], + "id": 119, + "name": "FunctionCall", + "src": "1524:54:0" + } + ], + "id": 120, + "name": "ExpressionStatement", + "src": "1524:54:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "transfer", + "referencedDeclaration": null, + "type": "function (uint256)" + }, + "children": [ + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 121, + "name": "Identifier", + "src": "1588:3:0" + } + ], + "id": 124, + "name": "MemberAccess", + "src": "1588:10:0" + } + ], + "id": 125, + "name": "MemberAccess", + "src": "1588:19:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 96, + "type": "uint256", + "value": "etheAmount" + }, + "id": 126, + "name": "Identifier", + "src": "1608:10:0" + } + ], + "id": 127, + "name": "FunctionCall", + "src": "1588:31:0" + } + ], + "id": 128, + "name": "ExpressionStatement", + "src": "1588:31:0" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 30, + "type": "function (address,address,uint256,uint256)", + "value": "TokensSold" + }, + "id": 129, + "name": "Identifier", + "src": "1659:10: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": 394, + "type": "msg", + "value": "msg" + }, + "id": 130, + "name": "Identifier", + "src": "1670:3:0" + } + ], + "id": 131, + "name": "MemberAccess", + "src": "1670:10:0" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "address", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_contract$_Token_$379", + "typeString": "contract Token" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "type": "type(address)", + "value": "address" + }, + "id": 132, + "name": "ElementaryTypeNameExpression", + "src": "1682:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 7, + "type": "contract Token", + "value": "token" + }, + "id": 133, + "name": "Identifier", + "src": "1690:5:0" + } + ], + "id": 134, + "name": "FunctionCall", + "src": "1682:14:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 82, + "type": "uint256", + "value": "_amount" + }, + "id": 135, + "name": "Identifier", + "src": "1698:7:0" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 10, + "type": "uint256", + "value": "rate" + }, + "id": 136, + "name": "Identifier", + "src": "1707:4:0" + } + ], + "id": 137, + "name": "FunctionCall", + "src": "1659:53:0" + } + ], + "id": 138, + "name": "EmitStatement", + "src": "1654:58:0" + } + ], + "id": 139, + "name": "Block", + "src": "1078:641:0" + } + ], + "id": 140, + "name": "FunctionDefinition", + "src": "1037:682:0" + } + ], + "id": 141, + "name": "ContractDefinition", + "src": "48:1673:0" + } + ], + "id": 142, + "name": "SourceUnit", + "src": "0:1722:0" + }, + "compiler": { + "name": "solc", + "version": "0.5.16+commit.9c3226ce.Emscripten.clang" + }, + "networks": { + "5777": { + "events": { + "0xbe52c1773bb2528744725b29470d0cb959c94e22fc4817ad800fd3d83816dbad": { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "TokensPurchase", + "type": "event" + }, + "0x697c42d55a5e1fed3f464ec6f38b32546a0bd368dc8068b065c67566d73f3290": { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "TokensSold", + "type": "event" + } + }, + "links": {}, + "address": "0xd380a05846220b474f1038DaF348FF1669CAA097", + "transactionHash": "0xf63d879d1123f0e475bb66a88d70251fd376ee42354117f2e93eb2cbec4a16fc" + } + }, + "schemaVersion": "3.3.4", + "updatedAt": "2021-02-21T16:03:22.184Z", + "networkType": "ethereum", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/src/abis/Migrations.json b/src/abis/Migrations.json new file mode 100644 index 000000000..b57ea1bb6 --- /dev/null +++ b/src/abis/Migrations.json @@ -0,0 +1,1491 @@ +{ + "contractName": "Migrations", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": true, + "inputs": [], + "name": "last_completed_migration", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "uint256", + "name": "completed", + "type": "uint256" + } + ], + "name": "setCompleted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "new_address", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"constant\":true,\"inputs\":[],\"name\":\"last_completed_migration\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"completed\",\"type\":\"uint256\"}],\"name\":\"setCompleted\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"new_address\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Migrations.sol\":\"Migrations\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Migrations.sol\":{\"keccak256\":\"0xaeec20b728a7f5c296eca896e4d777881337bed4a4a481e4fea0efd22dd8b72c\",\"urls\":[\"bzz-raw://c63b678508ccf3a68aa97571001b95a31682f20b1e712573409125393924bc12\",\"dweb:/ipfs/QmWD5sp4ez3nJAscC6FdDPUu8ZS6WBW5S7ccVCferrp217\"]}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102b7806100606000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea265627a7a72315820113548230ed0dc7db7208349491be0ee471b97d6ea912d1d74f40668f034bb2464736f6c63430005100032", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061004c5760003560e01c80630900f01014610051578063445df0ac146100955780638da5cb5b146100b3578063fdacd576146100fd575b600080fd5b6100936004803603602081101561006757600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061012b565b005b61009d6101f7565b6040518082815260200191505060405180910390f35b6100bb6101fd565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6101296004803603602081101561011357600080fd5b8101908080359060200190929190505050610222565b005b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101f45760008190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff1660e01b815260040180828152602001915050600060405180830381600087803b1580156101da57600080fd5b505af11580156101ee573d6000803e3d6000fd5b50505050505b50565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561027f57806001819055505b5056fea265627a7a72315820113548230ed0dc7db7208349491be0ee471b97d6ea912d1d74f40668f034bb2464736f6c63430005100032", + "sourceMap": "34:526:1:-;;;132:56;8:9:-1;5:2;;;30:1;27;20:12;5:2;132:56:1;171:10;163:5;;:18;;;;;;;;;;;;;;;;;;34:526;;;;;;", + "deployedSourceMap": "34:526:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:526:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;383:175;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;383:175:1;;;;;;;;;;;;;;;;;;;:::i;:::-;;86:39;;;:::i;:::-;;;;;;;;;;;;;;;;;;;60:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;265:112;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;265:112:1;;;;;;;;;;;;;;;;;:::i;:::-;;383:175;244:5;;;;;;;;;;;230:19;;:10;:19;;;226:26;;;449:19;482:11;449:45;;504:8;:21;;;526:24;;504:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;504:47:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;504:47:1;;;;251:1;226:26;383:175;:::o;86:39::-;;;;:::o;60:20::-;;;;;;;;;;;;;:::o;265:112::-;244:5;;;;;;;;;;;230:19;;:10;:19;;;226:26;;;361:9;334:24;:36;;;;226:26;265:112;:::o", + "source": "pragma solidity >=0.4.21 <0.6.0;\n\ncontract Migrations {\n address public owner;\n uint256 public last_completed_migration;\n\n constructor() public {\n owner = msg.sender;\n }\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n function setCompleted(uint256 completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", + "sourcePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Migrations.sol", + "ast": { + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 198 + ] + }, + "id": 199, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 143, + "literals": [ + "solidity", + ">=", + "0.4", + ".21", + "<", + "0.6", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 198, + "linearizedBaseContracts": [ + 198 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 145, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 198, + "src": "60:20:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 144, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "60:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 147, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 198, + "src": "86:39:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 146, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "86:7:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 155, + "nodeType": "Block", + "src": "153:35:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 153, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 150, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 145, + "src": "163:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 151, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "171:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 152, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "171:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "src": "163:18:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 154, + "nodeType": "ExpressionStatement", + "src": "163:18:1" + } + ] + }, + "documentation": null, + "id": 156, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 148, + "nodeType": "ParameterList", + "parameters": [], + "src": "143:2:1" + }, + "returnParameters": { + "id": 149, + "nodeType": "ParameterList", + "parameters": [], + "src": "153:0:1" + }, + "scope": 198, + "src": "132:56:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 164, + "nodeType": "Block", + "src": "216:43:1", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 161, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 158, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "230:3:1", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 159, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "230:10:1", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 160, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 145, + "src": "244:5:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "230:19:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 163, + "nodeType": "IfStatement", + "src": "226:26:1", + "trueBody": { + "id": 162, + "nodeType": "PlaceholderStatement", + "src": "251:1:1" + } + } + ] + }, + "documentation": null, + "id": 165, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 157, + "nodeType": "ParameterList", + "parameters": [], + "src": "213:2:1" + }, + "src": "194:65:1", + "visibility": "internal" + }, + { + "body": { + "id": 176, + "nodeType": "Block", + "src": "324:53:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 174, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 172, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 147, + "src": "334:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 173, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 167, + "src": "361:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "334:36:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 175, + "nodeType": "ExpressionStatement", + "src": "334:36:1" + } + ] + }, + "documentation": null, + "id": 177, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": null, + "id": 170, + "modifierName": { + "argumentTypes": null, + "id": 169, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 165, + "src": "313:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "313:10:1" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 168, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 167, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 177, + "src": "287:17:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 166, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "287:7:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "286:19:1" + }, + "returnParameters": { + "id": 171, + "nodeType": "ParameterList", + "parameters": [], + "src": "324:0:1" + }, + "scope": 198, + "src": "265:112:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 196, + "nodeType": "Block", + "src": "439:119:1", + "statements": [ + { + "assignments": [ + 185 + ], + "declarations": [ + { + "constant": false, + "id": 185, + "name": "upgraded", + "nodeType": "VariableDeclaration", + "scope": 196, + "src": "449:19:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$198", + "typeString": "contract Migrations" + }, + "typeName": { + "contractScope": null, + "id": 184, + "name": "Migrations", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 198, + "src": "449:10:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$198", + "typeString": "contract Migrations" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 189, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 187, + "name": "new_address", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 179, + "src": "482:11:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 186, + "name": "Migrations", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 198, + "src": "471:10:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Migrations_$198_$", + "typeString": "type(contract Migrations)" + } + }, + "id": 188, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "471:23:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$198", + "typeString": "contract Migrations" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "449:45:1" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 193, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 147, + "src": "526:24:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 190, + "name": "upgraded", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 185, + "src": "504:8:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$198", + "typeString": "contract Migrations" + } + }, + "id": 192, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "setCompleted", + "nodeType": "MemberAccess", + "referencedDeclaration": 177, + "src": "504:21:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256) external" + } + }, + "id": 194, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "504:47:1", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 195, + "nodeType": "ExpressionStatement", + "src": "504:47:1" + } + ] + }, + "documentation": null, + "id": 197, + "implemented": true, + "kind": "function", + "modifiers": [ + { + "arguments": null, + "id": 182, + "modifierName": { + "argumentTypes": null, + "id": 181, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 165, + "src": "428:10:1", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "428:10:1" + } + ], + "name": "upgrade", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 180, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 179, + "name": "new_address", + "nodeType": "VariableDeclaration", + "scope": 197, + "src": "400:19:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 178, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "400:7:1", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "399:21:1" + }, + "returnParameters": { + "id": 183, + "nodeType": "ParameterList", + "parameters": [], + "src": "439:0:1" + }, + "scope": 198, + "src": "383:175:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 199, + "src": "34:526:1" + } + ], + "src": "0:561:1" + }, + "legacyAST": { + "attributes": { + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 198 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + ">=", + "0.4", + ".21", + "<", + "0.6", + ".0" + ] + }, + "id": 143, + "name": "PragmaDirective", + "src": "0:32:1" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 198 + ], + "name": "Migrations", + "scope": 199 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "owner", + "scope": 198, + "stateVariable": true, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 144, + "name": "ElementaryTypeName", + "src": "60:7:1" + } + ], + "id": 145, + "name": "VariableDeclaration", + "src": "60:20:1" + }, + { + "attributes": { + "constant": false, + "name": "last_completed_migration", + "scope": 198, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 146, + "name": "ElementaryTypeName", + "src": "86:7:1" + } + ], + "id": 147, + "name": "VariableDeclaration", + "src": "86:39:1" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": true, + "kind": "constructor", + "modifiers": [ + null + ], + "name": "", + "scope": 198, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 148, + "name": "ParameterList", + "src": "143:2:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 149, + "name": "ParameterList", + "src": "153:0:1" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "address" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 145, + "type": "address", + "value": "owner" + }, + "id": 150, + "name": "Identifier", + "src": "163:5:1" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 151, + "name": "Identifier", + "src": "171:3:1" + } + ], + "id": 152, + "name": "MemberAccess", + "src": "171:10:1" + } + ], + "id": 153, + "name": "Assignment", + "src": "163:18:1" + } + ], + "id": 154, + "name": "ExpressionStatement", + "src": "163:18:1" + } + ], + "id": 155, + "name": "Block", + "src": "153:35:1" + } + ], + "id": 156, + "name": "FunctionDefinition", + "src": "132:56:1" + }, + { + "attributes": { + "documentation": null, + "name": "restricted", + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 157, + "name": "ParameterList", + "src": "213:2:1" + }, + { + "children": [ + { + "attributes": { + "falseBody": null + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "==", + "type": "bool" + }, + "children": [ + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 158, + "name": "Identifier", + "src": "230:3:1" + } + ], + "id": 159, + "name": "MemberAccess", + "src": "230:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 145, + "type": "address", + "value": "owner" + }, + "id": 160, + "name": "Identifier", + "src": "244:5:1" + } + ], + "id": 161, + "name": "BinaryOperation", + "src": "230:19:1" + }, + { + "id": 162, + "name": "PlaceholderStatement", + "src": "251:1:1" + } + ], + "id": 163, + "name": "IfStatement", + "src": "226:26:1" + } + ], + "id": 164, + "name": "Block", + "src": "216:43:1" + } + ], + "id": 165, + "name": "ModifierDefinition", + "src": "194:65:1" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "name": "setCompleted", + "scope": 198, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "completed", + "scope": 177, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 166, + "name": "ElementaryTypeName", + "src": "287:7:1" + } + ], + "id": 167, + "name": "VariableDeclaration", + "src": "287:17:1" + } + ], + "id": 168, + "name": "ParameterList", + "src": "286:19:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 171, + "name": "ParameterList", + "src": "324:0:1" + }, + { + "attributes": { + "arguments": null + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 165, + "type": "modifier ()", + "value": "restricted" + }, + "id": 169, + "name": "Identifier", + "src": "313:10:1" + } + ], + "id": 170, + "name": "ModifierInvocation", + "src": "313:10:1" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "=", + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 147, + "type": "uint256", + "value": "last_completed_migration" + }, + "id": 172, + "name": "Identifier", + "src": "334:24:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 167, + "type": "uint256", + "value": "completed" + }, + "id": 173, + "name": "Identifier", + "src": "361:9:1" + } + ], + "id": 174, + "name": "Assignment", + "src": "334:36:1" + } + ], + "id": 175, + "name": "ExpressionStatement", + "src": "334:36:1" + } + ], + "id": 176, + "name": "Block", + "src": "324:53:1" + } + ], + "id": 177, + "name": "FunctionDefinition", + "src": "265:112:1" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "name": "upgrade", + "scope": 198, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "new_address", + "scope": 197, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 178, + "name": "ElementaryTypeName", + "src": "400:7:1" + } + ], + "id": 179, + "name": "VariableDeclaration", + "src": "400:19:1" + } + ], + "id": 180, + "name": "ParameterList", + "src": "399:21:1" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 183, + "name": "ParameterList", + "src": "439:0:1" + }, + { + "attributes": { + "arguments": null + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 165, + "type": "modifier ()", + "value": "restricted" + }, + "id": 181, + "name": "Identifier", + "src": "428:10:1" + } + ], + "id": 182, + "name": "ModifierInvocation", + "src": "428:10:1" + }, + { + "children": [ + { + "attributes": { + "assignments": [ + 185 + ] + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "upgraded", + "scope": 196, + "stateVariable": false, + "storageLocation": "default", + "type": "contract Migrations", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "contractScope": null, + "name": "Migrations", + "referencedDeclaration": 198, + "type": "contract Migrations" + }, + "id": 184, + "name": "UserDefinedTypeName", + "src": "449:10:1" + } + ], + "id": 185, + "name": "VariableDeclaration", + "src": "449:19:1" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "contract Migrations", + "type_conversion": true + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 198, + "type": "type(contract Migrations)", + "value": "Migrations" + }, + "id": 186, + "name": "Identifier", + "src": "471:10:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 179, + "type": "address", + "value": "new_address" + }, + "id": 187, + "name": "Identifier", + "src": "482:11:1" + } + ], + "id": 188, + "name": "FunctionCall", + "src": "471:23:1" + } + ], + "id": 189, + "name": "VariableDeclarationStatement", + "src": "449:45:1" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "member_name": "setCompleted", + "referencedDeclaration": 177, + "type": "function (uint256) external" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 185, + "type": "contract Migrations", + "value": "upgraded" + }, + "id": 190, + "name": "Identifier", + "src": "504:8:1" + } + ], + "id": 192, + "name": "MemberAccess", + "src": "504:21:1" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 147, + "type": "uint256", + "value": "last_completed_migration" + }, + "id": 193, + "name": "Identifier", + "src": "526:24:1" + } + ], + "id": 194, + "name": "FunctionCall", + "src": "504:47:1" + } + ], + "id": 195, + "name": "ExpressionStatement", + "src": "504:47:1" + } + ], + "id": 196, + "name": "Block", + "src": "439:119:1" + } + ], + "id": 197, + "name": "FunctionDefinition", + "src": "383:175:1" + } + ], + "id": 198, + "name": "ContractDefinition", + "src": "34:526:1" + } + ], + "id": 199, + "name": "SourceUnit", + "src": "0:561:1" + }, + "compiler": { + "name": "solc", + "version": "0.5.16+commit.9c3226ce.Emscripten.clang" + }, + "networks": { + "5777": { + "events": {}, + "links": {}, + "address": "0xB14CfBE368393388aB16dd08D16B27e40743452F", + "transactionHash": "0x947a2ea487e691597be4bce1dc022b7a64fb074bd77a8cc08e825c6e82965020" + } + }, + "schemaVersion": "3.3.4", + "updatedAt": "2021-02-21T16:03:22.186Z", + "networkType": "ethereum", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/src/abis/Token.json b/src/abis/Token.json new file mode 100644 index 000000000..ce6634b8e --- /dev/null +++ b/src/abis/Token.json @@ -0,0 +1,5150 @@ +{ + "contractName": "Token", + "abi": [ + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "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": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "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": "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": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"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\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"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\":\"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\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol\":\"Token\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol\":{\"keccak256\":\"0x9030fca2a55f386312a637f48f53b364c61c41868e7192612ff86040d7cc985d\",\"urls\":[\"bzz-raw://f454e80fb8c1db9adeaa48b4a811c23de9f1f3e899f36ac8bae6caba37ce5a9f\",\"dweb:/ipfs/QmWV2HJL56dez2rmxofktNnzX28EDCMSiXk1BeaWDjdnu5\"]}},\"version\":1}", + "bytecode": "0x60806040526040518060400160405280600a81526020017f4441707020546f6b656e000000000000000000000000000000000000000000008152506000908051906020019061004f92919061011e565b506040518060400160405280600481526020017f44415050000000000000000000000000000000000000000000000000000000008152506001908051906020019061009b92919061011e565b5069d3c21bcecceda10000006002556012600360006101000a81548160ff021916908360ff1602179055503480156100d257600080fd5b50600254600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506101c3565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061015f57805160ff191683800117855561018d565b8280016001018555821561018d579182015b8281111561018c578251825591602001919060010190610171565b5b50905061019a919061019e565b5090565b6101c091905b808211156101bc5760008160009055506001016101a4565b5090565b90565b610a7d806101d26000396000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce5671461022557806370a082311461024957806395d89b41146102a1578063a9059cbb14610324578063dd62ed3e1461038a57610093565b806306fdde0314610098578063095ea7b31461011b57806318160ddd1461018157806323b872dd1461019f575b600080fd5b6100a0610402565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101676004803603604081101561013157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104a0565b604051808215151515815260200191505060405180910390f35b610189610592565b6040518082815260200191505060405180910390f35b61020b600480360360608110156101b557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610598565b604051808215151515815260200191505060405180910390f35b61022d610803565b604051808260ff1660ff16815260200191505060405180910390f35b61028b6004803603602081101561025f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610816565b6040518082815260200191505060405180910390f35b6102a961082e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102e95780820151818401526020810190506102ce565b50505050905090810190601f1680156103165780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103706004803603604081101561033a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108cc565b604051808215151515815260200191505060405180910390f35b6103ec600480360360408110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a23565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104985780601f1061046d57610100808354040283529160200191610498565b820191906000526020600020905b81548152906001019060200180831161047b57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156105e657600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111561066f57600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600360009054906101000a900460ff1681565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108c45780601f10610899576101008083540402835291602001916108c4565b820191906000526020600020905b8154815290600101906020018083116108a757829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561091a57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600560205281600052604060002060205280600052604060002060009150915050548156fea265627a7a72315820d14e291481bd3244a316fdbb4a24b6874919790d41dd3242f7a730b6c173628264736f6c63430005100032", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063313ce56711610066578063313ce5671461022557806370a082311461024957806395d89b41146102a1578063a9059cbb14610324578063dd62ed3e1461038a57610093565b806306fdde0314610098578063095ea7b31461011b57806318160ddd1461018157806323b872dd1461019f575b600080fd5b6100a0610402565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100e05780820151818401526020810190506100c5565b50505050905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101676004803603604081101561013157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506104a0565b604051808215151515815260200191505060405180910390f35b610189610592565b6040518082815260200191505060405180910390f35b61020b600480360360608110156101b557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610598565b604051808215151515815260200191505060405180910390f35b61022d610803565b604051808260ff1660ff16815260200191505060405180910390f35b61028b6004803603602081101561025f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610816565b6040518082815260200191505060405180910390f35b6102a961082e565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102e95780820151818401526020810190506102ce565b50505050905090810190601f1680156103165780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6103706004803603604081101561033a57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108cc565b604051808215151515815260200191505060405180910390f35b6103ec600480360360408110156103a057600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610a23565b6040518082815260200191505060405180910390f35b60008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156104985780601f1061046d57610100808354040283529160200191610498565b820191906000526020600020905b81548152906001019060200180831161047b57829003601f168201915b505050505081565b600081600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a36001905092915050565b60025481565b6000600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548211156105e657600080fd5b600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205482111561066f57600080fd5b81600460008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555081600560008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3600190509392505050565b600360009054906101000a900460ff1681565b60046020528060005260406000206000915090505481565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108c45780601f10610899576101008083540402835291602001916108c4565b820191906000526020600020905b8154815290600101906020018083116108a757829003601f168201915b505050505081565b600081600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054101561091a57600080fd5b81600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254039250508190555081600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a36001905092915050565b600560205281600052604060002060205280600052604060002060009150915050548156fea265627a7a72315820d14e291481bd3244a316fdbb4a24b6874919790d41dd3242f7a730b6c173628264736f6c63430005100032", + "sourceMap": "25:1531:2:-;;;46:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;86:30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;151:25;122:54;;228:2;202:28;;;;;;;;;;;;;;;;;;;;586:73;8:9:-1;5:2;;;30:1;27;20:12;5:2;586:73:2;641:11;;617:9;:21;627:10;617:21;;;;;;;;;;;;;;;:35;;;;25:1531;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;:::-;;;;;;;", + "deployedSourceMap": "25:1531:2:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;25:1531:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;46:34;;;:::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;46:34:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;949:212;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;949:212:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;122:54;;;:::i;:::-;;;;;;;;;;;;;;;;;;;1167:387;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;1167:387:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;202:28;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;465:44;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;465:44:2;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;86:30;;;:::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;86:30:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;665:278;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;665:278:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;515:64;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;515:64:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;46:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;949:212::-;1016:12;1074:6;1040:9;:21;1050:10;1040:21;;;;;;;;;;;;;;;:31;1062:8;1040:31;;;;;;;;;;;;;;;:40;;;;1116:8;1095:38;;1104:10;1095:38;;;1126:6;1095:38;;;;;;;;;;;;;;;;;;1150:4;1143:11;;949:212;;;;:::o;122:54::-;;;;:::o;1167:387::-;1249:12;1291:9;:16;1301:5;1291:16;;;;;;;;;;;;;;;;1281:6;:26;;1273:35;;;;;;1336:9;:16;1346:5;1336:16;;;;;;;;;;;;;;;:28;1353:10;1336:28;;;;;;;;;;;;;;;;1326:6;:38;;1318:47;;;;;;1395:6;1375:9;:16;1385:5;1375:16;;;;;;;;;;;;;;;;:26;;;;;;;;;;;1429:6;1411:9;:14;1421:3;1411:14;;;;;;;;;;;;;;;;:24;;;;;;;;;;;1477:6;1445:9;:16;1455:5;1445:16;;;;;;;;;;;;;;;:28;1462:10;1445:28;;;;;;;;;;;;;;;;:38;;;;;;;;;;;1514:3;1498:28;;1507:5;1498:28;;;1519:6;1498:28;;;;;;;;;;;;;;;;;;1543:4;1536:11;;1167:387;;;;;:::o;202:28::-;;;;;;;;;;;;;:::o;465:44::-;;;;;;;;;;;;;;;;;:::o;86:30::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::o;665:278::-;728:12;785:6;760:9;:21;770:10;760:21;;;;;;;;;;;;;;;;:31;;752:40;;;;;;827:6;802:9;:21;812:10;802:21;;;;;;;;;;;;;;;;:31;;;;;;;;;;;861:6;843:9;:14;853:3;843:14;;;;;;;;;;;;;;;;:24;;;;;;;;;;;903:3;882:33;;891:10;882:33;;;908:6;882:33;;;;;;;;;;;;;;;;;;932:4;925:11;;665:278;;;;:::o;515:64::-;;;;;;;;;;;;;;;;;;;;;;;;;;:::o", + "source": "pragma solidity ^0.5.0;\n\ncontract Token {\n string public name = \"DApp Token\";\n string public symbol = \"DAPP\";\n uint256 public totalSupply = 1000000000000000000000000; // 1 million tokens\n uint8 public decimals = 18;\n\n event Transfer(\n address indexed _from,\n address indexed _to,\n uint256 _value\n );\n\n event Approval(\n address indexed _owner,\n address indexed _spender,\n uint256 _value\n );\n\n mapping(address => uint256) public balanceOf;\n mapping(address => mapping(address => uint256)) public allowance;\n\n constructor() public {\n balanceOf[msg.sender] = totalSupply;\n }\n\n function transfer(address _to, uint256 _value) public returns (bool success) {\n require(balanceOf[msg.sender] >= _value);\n balanceOf[msg.sender] -= _value;\n balanceOf[_to] += _value;\n emit Transfer(msg.sender, _to, _value);\n return true;\n }\n\n function approve(address _spender, uint256 _value) public returns (bool success) {\n allowance[msg.sender][_spender] = _value;\n emit Approval(msg.sender, _spender, _value);\n return true;\n }\n\n function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {\n require(_value <= balanceOf[_from]);\n require(_value <= allowance[_from][msg.sender]);\n balanceOf[_from] -= _value;\n balanceOf[_to] += _value;\n allowance[_from][msg.sender] -= _value;\n emit Transfer(_from, _to, _value);\n return true;\n }\n}", + "sourcePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol", + "ast": { + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol", + "exportedSymbols": { + "Token": [ + 379 + ] + }, + "id": 380, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 200, + "literals": [ + "solidity", + "^", + "0.5", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:23:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 379, + "linearizedBaseContracts": [ + 379 + ], + "name": "Token", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 203, + "name": "name", + "nodeType": "VariableDeclaration", + "scope": 379, + "src": "46:34:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_storage", + "typeString": "string" + }, + "typeName": { + "id": 201, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "46:6:2", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "value": { + "argumentTypes": null, + "hexValue": "4441707020546f6b656e", + "id": 202, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "68:12:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_4bb1c77e58fe7915ae82d4848a9c7f3a9bd772743e283b0e9e22385825f37dce", + "typeString": "literal_string \"DApp Token\"" + }, + "value": "DApp Token" + }, + "visibility": "public" + }, + { + "constant": false, + "id": 206, + "name": "symbol", + "nodeType": "VariableDeclaration", + "scope": 379, + "src": "86:30:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_string_storage", + "typeString": "string" + }, + "typeName": { + "id": 204, + "name": "string", + "nodeType": "ElementaryTypeName", + "src": "86:6:2", + "typeDescriptions": { + "typeIdentifier": "t_string_storage_ptr", + "typeString": "string" + } + }, + "value": { + "argumentTypes": null, + "hexValue": "44415050", + "id": 205, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "string", + "lValueRequested": false, + "nodeType": "Literal", + "src": "110:6:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_stringliteral_2f0440134a0794b969e8c19364bb3c2fbe91c99bfae2a18a4a19e46c2cead377", + "typeString": "literal_string \"DAPP\"" + }, + "value": "DAPP" + }, + "visibility": "public" + }, + { + "constant": false, + "id": 209, + "name": "totalSupply", + "nodeType": "VariableDeclaration", + "scope": 379, + "src": "122:54:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 207, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "122:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": { + "argumentTypes": null, + "hexValue": "31303030303030303030303030303030303030303030303030", + "id": 208, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "151:25:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_1000000000000000000000000_by_1", + "typeString": "int_const 1000000000000000000000000" + }, + "value": "1000000000000000000000000" + }, + "visibility": "public" + }, + { + "constant": false, + "id": 212, + "name": "decimals", + "nodeType": "VariableDeclaration", + "scope": 379, + "src": "202:28:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint8", + "typeString": "uint8" + }, + "typeName": { + "id": 210, + "name": "uint8", + "nodeType": "ElementaryTypeName", + "src": "202:5:2", + "typeDescriptions": { + "typeIdentifier": "t_uint8", + "typeString": "uint8" + } + }, + "value": { + "argumentTypes": null, + "hexValue": "3138", + "id": 211, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "228:2:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_18_by_1", + "typeString": "int_const 18" + }, + "value": "18" + }, + "visibility": "public" + }, + { + "anonymous": false, + "documentation": null, + "id": 220, + "name": "Transfer", + "nodeType": "EventDefinition", + "parameters": { + "id": 219, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 214, + "indexed": true, + "name": "_from", + "nodeType": "VariableDeclaration", + "scope": 220, + "src": "261:21:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 213, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "261:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 216, + "indexed": true, + "name": "_to", + "nodeType": "VariableDeclaration", + "scope": 220, + "src": "292:19:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 215, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "292:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 218, + "indexed": false, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 220, + "src": "321:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 217, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "321:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "251:90:2" + }, + "src": "237:105:2" + }, + { + "anonymous": false, + "documentation": null, + "id": 228, + "name": "Approval", + "nodeType": "EventDefinition", + "parameters": { + "id": 227, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 222, + "indexed": true, + "name": "_owner", + "nodeType": "VariableDeclaration", + "scope": 228, + "src": "372:22:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 221, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "372:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 224, + "indexed": true, + "name": "_spender", + "nodeType": "VariableDeclaration", + "scope": 228, + "src": "404:24:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 223, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "404:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 226, + "indexed": false, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 228, + "src": "438:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 225, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "438:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "362:96:2" + }, + "src": "348:111:2" + }, + { + "constant": false, + "id": 232, + "name": "balanceOf", + "nodeType": "VariableDeclaration", + "scope": 379, + "src": "465:44:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + }, + "typeName": { + "id": 231, + "keyType": { + "id": 229, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "473:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Mapping", + "src": "465:27:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + }, + "valueType": { + "id": 230, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "484:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 238, + "name": "allowance", + "nodeType": "VariableDeclaration", + "scope": 379, + "src": "515:64:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", + "typeString": "mapping(address => mapping(address => uint256))" + }, + "typeName": { + "id": 237, + "keyType": { + "id": 233, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "523:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Mapping", + "src": "515:47:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", + "typeString": "mapping(address => mapping(address => uint256))" + }, + "valueType": { + "id": 236, + "keyType": { + "id": 234, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "542:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Mapping", + "src": "534:27:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + }, + "valueType": { + "id": 235, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "553:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 248, + "nodeType": "Block", + "src": "607:52:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 246, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 241, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 232, + "src": "617:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 244, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 242, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "627:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 243, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "627:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "617:21:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 245, + "name": "totalSupply", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 209, + "src": "641:11:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "617:35:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 247, + "nodeType": "ExpressionStatement", + "src": "617:35:2" + } + ] + }, + "documentation": null, + "id": 249, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 239, + "nodeType": "ParameterList", + "parameters": [], + "src": "597:2:2" + }, + "returnParameters": { + "id": 240, + "nodeType": "ParameterList", + "parameters": [], + "src": "607:0:2" + }, + "scope": 379, + "src": "586:73:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 289, + "nodeType": "Block", + "src": "742:201:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 264, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 259, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 232, + "src": "760:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 262, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 260, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "770:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 261, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "770:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "760:21:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": ">=", + "rightExpression": { + "argumentTypes": null, + "id": 263, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 253, + "src": "785:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "760:31:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 258, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "src": "752:7:2", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 265, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "752:40:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 266, + "nodeType": "ExpressionStatement", + "src": "752:40:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 272, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 267, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 232, + "src": "802:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 270, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 268, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "812:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 269, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "812:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "802:21:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "-=", + "rightHandSide": { + "argumentTypes": null, + "id": 271, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 253, + "src": "827:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "802:31:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 273, + "nodeType": "ExpressionStatement", + "src": "802:31:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 278, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 274, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 232, + "src": "843:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 276, + "indexExpression": { + "argumentTypes": null, + "id": 275, + "name": "_to", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 251, + "src": "853:3:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "843:14:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "+=", + "rightHandSide": { + "argumentTypes": null, + "id": 277, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 253, + "src": "861:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "843:24:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 279, + "nodeType": "ExpressionStatement", + "src": "843:24:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 281, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "891:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 282, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "891:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + { + "argumentTypes": null, + "id": 283, + "name": "_to", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 251, + "src": "903:3:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 284, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 253, + "src": "908:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 280, + "name": "Transfer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 220, + "src": "882:8:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256)" + } + }, + "id": 285, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "882:33:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 286, + "nodeType": "EmitStatement", + "src": "877:38:2" + }, + { + "expression": { + "argumentTypes": null, + "hexValue": "74727565", + "id": 287, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "bool", + "lValueRequested": false, + "nodeType": "Literal", + "src": "932:4:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "value": "true" + }, + "functionReturnParameters": 257, + "id": 288, + "nodeType": "Return", + "src": "925:11:2" + } + ] + }, + "documentation": null, + "id": 290, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "transfer", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 254, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 251, + "name": "_to", + "nodeType": "VariableDeclaration", + "scope": 290, + "src": "683:11:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 250, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "683:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 253, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 290, + "src": "696:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 252, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "696:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "682:29:2" + }, + "returnParameters": { + "id": 257, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 256, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 290, + "src": "728:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 255, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "728:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "727:14:2" + }, + "scope": 379, + "src": "665:278:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 317, + "nodeType": "Block", + "src": "1030:131:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 306, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 299, + "name": "allowance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 238, + "src": "1040:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", + "typeString": "mapping(address => mapping(address => uint256))" + } + }, + "id": 303, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 300, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1050:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 301, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1050:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "1040:21:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 304, + "indexExpression": { + "argumentTypes": null, + "id": 302, + "name": "_spender", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 292, + "src": "1062:8:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "1040:31:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 305, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 294, + "src": "1074:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1040:40:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 307, + "nodeType": "ExpressionStatement", + "src": "1040:40:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 309, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1104:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 310, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1104:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + { + "argumentTypes": null, + "id": 311, + "name": "_spender", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 292, + "src": "1116:8:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 312, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 294, + "src": "1126:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 308, + "name": "Approval", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 228, + "src": "1095:8:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256)" + } + }, + "id": 313, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1095:38:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 314, + "nodeType": "EmitStatement", + "src": "1090:43:2" + }, + { + "expression": { + "argumentTypes": null, + "hexValue": "74727565", + "id": 315, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "bool", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1150:4:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "value": "true" + }, + "functionReturnParameters": 298, + "id": 316, + "nodeType": "Return", + "src": "1143:11:2" + } + ] + }, + "documentation": null, + "id": 318, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "approve", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 295, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 292, + "name": "_spender", + "nodeType": "VariableDeclaration", + "scope": 318, + "src": "966:16:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 291, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "966:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 294, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 318, + "src": "984:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 293, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "984:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "965:34:2" + }, + "returnParameters": { + "id": 298, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 297, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 318, + "src": "1016:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 296, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1016:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1015:14:2" + }, + "scope": 379, + "src": "949:212:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 377, + "nodeType": "Block", + "src": "1263:291:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 334, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 330, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "1281:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 331, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 232, + "src": "1291:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 333, + "indexExpression": { + "argumentTypes": null, + "id": 332, + "name": "_from", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 320, + "src": "1301:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "1291:16:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1281:26:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 329, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "src": "1273:7:2", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 335, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1273:35:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 336, + "nodeType": "ExpressionStatement", + "src": "1273:35:2" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 345, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 338, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "1326:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "<=", + "rightExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 339, + "name": "allowance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 238, + "src": "1336:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", + "typeString": "mapping(address => mapping(address => uint256))" + } + }, + "id": 341, + "indexExpression": { + "argumentTypes": null, + "id": 340, + "name": "_from", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 320, + "src": "1346:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "1336:16:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 344, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 342, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1353:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 343, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1353:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "1336:28:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1326:38:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "id": 337, + "name": "require", + "nodeType": "Identifier", + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "src": "1318:7:2", + "typeDescriptions": { + "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", + "typeString": "function (bool) pure" + } + }, + "id": 346, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1318:47:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 347, + "nodeType": "ExpressionStatement", + "src": "1318:47:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 352, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 348, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 232, + "src": "1375:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 350, + "indexExpression": { + "argumentTypes": null, + "id": 349, + "name": "_from", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 320, + "src": "1385:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "1375:16:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "-=", + "rightHandSide": { + "argumentTypes": null, + "id": 351, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "1395:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1375:26:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 353, + "nodeType": "ExpressionStatement", + "src": "1375:26:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 358, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 354, + "name": "balanceOf", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 232, + "src": "1411:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 356, + "indexExpression": { + "argumentTypes": null, + "id": 355, + "name": "_to", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 322, + "src": "1421:3:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "1411:14:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "+=", + "rightHandSide": { + "argumentTypes": null, + "id": 357, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "1429:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1411:24:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 359, + "nodeType": "ExpressionStatement", + "src": "1411:24:2" + }, + { + "expression": { + "argumentTypes": null, + "id": 367, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "baseExpression": { + "argumentTypes": null, + "id": 360, + "name": "allowance", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 238, + "src": "1445:9:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_mapping$_t_address_$_t_uint256_$_$", + "typeString": "mapping(address => mapping(address => uint256))" + } + }, + "id": 364, + "indexExpression": { + "argumentTypes": null, + "id": 361, + "name": "_from", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 320, + "src": "1455:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "nodeType": "IndexAccess", + "src": "1445:16:2", + "typeDescriptions": { + "typeIdentifier": "t_mapping$_t_address_$_t_uint256_$", + "typeString": "mapping(address => uint256)" + } + }, + "id": 365, + "indexExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 362, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 394, + "src": "1462:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 363, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "1462:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + } + }, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": true, + "nodeType": "IndexAccess", + "src": "1445:28:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "-=", + "rightHandSide": { + "argumentTypes": null, + "id": 366, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "1477:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "1445:38:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 368, + "nodeType": "ExpressionStatement", + "src": "1445:38:2" + }, + { + "eventCall": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 370, + "name": "_from", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 320, + "src": "1507:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 371, + "name": "_to", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 322, + "src": "1514:3:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + { + "argumentTypes": null, + "id": 372, + "name": "_value", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 324, + "src": "1519:6:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "id": 369, + "name": "Transfer", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 220, + "src": "1498:8:2", + "typeDescriptions": { + "typeIdentifier": "t_function_event_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$__$", + "typeString": "function (address,address,uint256)" + } + }, + "id": 373, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "1498:28:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 374, + "nodeType": "EmitStatement", + "src": "1493:33:2" + }, + { + "expression": { + "argumentTypes": null, + "hexValue": "74727565", + "id": 375, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "bool", + "lValueRequested": false, + "nodeType": "Literal", + "src": "1543:4:2", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "value": "true" + }, + "functionReturnParameters": 328, + "id": 376, + "nodeType": "Return", + "src": "1536:11:2" + } + ] + }, + "documentation": null, + "id": 378, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "transferFrom", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 325, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 320, + "name": "_from", + "nodeType": "VariableDeclaration", + "scope": 378, + "src": "1189:13:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 319, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1189:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 322, + "name": "_to", + "nodeType": "VariableDeclaration", + "scope": 378, + "src": "1204:11:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 321, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "1204:7:2", + "stateMutability": "nonpayable", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 324, + "name": "_value", + "nodeType": "VariableDeclaration", + "scope": 378, + "src": "1217:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 323, + "name": "uint256", + "nodeType": "ElementaryTypeName", + "src": "1217:7:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1188:44:2" + }, + "returnParameters": { + "id": 328, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 327, + "name": "success", + "nodeType": "VariableDeclaration", + "scope": 378, + "src": "1249:12:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 326, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "1249:4:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "1248:14:2" + }, + "scope": 379, + "src": "1167:387:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 380, + "src": "25:1531:2" + } + ], + "src": "0:1556:2" + }, + "legacyAST": { + "attributes": { + "absolutePath": "/Users/Izuking/Desktop/solidity_practice/eth_swap/src/contracts/Token.sol", + "exportedSymbols": { + "Token": [ + 379 + ] + } + }, + "children": [ + { + "attributes": { + "literals": [ + "solidity", + "^", + "0.5", + ".0" + ] + }, + "id": 200, + "name": "PragmaDirective", + "src": "0:23:2" + }, + { + "attributes": { + "baseContracts": [ + null + ], + "contractDependencies": [ + null + ], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "linearizedBaseContracts": [ + 379 + ], + "name": "Token", + "scope": 380 + }, + "children": [ + { + "attributes": { + "constant": false, + "name": "name", + "scope": 379, + "stateVariable": true, + "storageLocation": "default", + "type": "string", + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string" + }, + "id": 201, + "name": "ElementaryTypeName", + "src": "46:6:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "4441707020546f6b656e", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "string", + "type": "literal_string \"DApp Token\"", + "value": "DApp Token" + }, + "id": 202, + "name": "Literal", + "src": "68:12:2" + } + ], + "id": 203, + "name": "VariableDeclaration", + "src": "46:34:2" + }, + { + "attributes": { + "constant": false, + "name": "symbol", + "scope": 379, + "stateVariable": true, + "storageLocation": "default", + "type": "string", + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "string", + "type": "string" + }, + "id": 204, + "name": "ElementaryTypeName", + "src": "86:6:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "44415050", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "string", + "type": "literal_string \"DAPP\"", + "value": "DAPP" + }, + "id": 205, + "name": "Literal", + "src": "110:6:2" + } + ], + "id": 206, + "name": "VariableDeclaration", + "src": "86:30:2" + }, + { + "attributes": { + "constant": false, + "name": "totalSupply", + "scope": 379, + "stateVariable": true, + "storageLocation": "default", + "type": "uint256", + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 207, + "name": "ElementaryTypeName", + "src": "122:7:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "31303030303030303030303030303030303030303030303030", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 1000000000000000000000000", + "value": "1000000000000000000000000" + }, + "id": 208, + "name": "Literal", + "src": "151:25:2" + } + ], + "id": 209, + "name": "VariableDeclaration", + "src": "122:54:2" + }, + { + "attributes": { + "constant": false, + "name": "decimals", + "scope": 379, + "stateVariable": true, + "storageLocation": "default", + "type": "uint8", + "visibility": "public" + }, + "children": [ + { + "attributes": { + "name": "uint8", + "type": "uint8" + }, + "id": 210, + "name": "ElementaryTypeName", + "src": "202:5:2" + }, + { + "attributes": { + "argumentTypes": null, + "hexvalue": "3138", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "number", + "type": "int_const 18", + "value": "18" + }, + "id": 211, + "name": "Literal", + "src": "228:2:2" + } + ], + "id": 212, + "name": "VariableDeclaration", + "src": "202:28:2" + }, + { + "attributes": { + "anonymous": false, + "documentation": null, + "name": "Transfer" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "indexed": true, + "name": "_from", + "scope": 220, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 213, + "name": "ElementaryTypeName", + "src": "261:7:2" + } + ], + "id": 214, + "name": "VariableDeclaration", + "src": "261:21:2" + }, + { + "attributes": { + "constant": false, + "indexed": true, + "name": "_to", + "scope": 220, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 215, + "name": "ElementaryTypeName", + "src": "292:7:2" + } + ], + "id": 216, + "name": "VariableDeclaration", + "src": "292:19:2" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "_value", + "scope": 220, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 217, + "name": "ElementaryTypeName", + "src": "321:7:2" + } + ], + "id": 218, + "name": "VariableDeclaration", + "src": "321:14:2" + } + ], + "id": 219, + "name": "ParameterList", + "src": "251:90:2" + } + ], + "id": 220, + "name": "EventDefinition", + "src": "237:105:2" + }, + { + "attributes": { + "anonymous": false, + "documentation": null, + "name": "Approval" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "indexed": true, + "name": "_owner", + "scope": 228, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 221, + "name": "ElementaryTypeName", + "src": "372:7:2" + } + ], + "id": 222, + "name": "VariableDeclaration", + "src": "372:22:2" + }, + { + "attributes": { + "constant": false, + "indexed": true, + "name": "_spender", + "scope": 228, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 223, + "name": "ElementaryTypeName", + "src": "404:7:2" + } + ], + "id": 224, + "name": "VariableDeclaration", + "src": "404:24:2" + }, + { + "attributes": { + "constant": false, + "indexed": false, + "name": "_value", + "scope": 228, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 225, + "name": "ElementaryTypeName", + "src": "438:7:2" + } + ], + "id": 226, + "name": "VariableDeclaration", + "src": "438:14:2" + } + ], + "id": 227, + "name": "ParameterList", + "src": "362:96:2" + } + ], + "id": 228, + "name": "EventDefinition", + "src": "348:111:2" + }, + { + "attributes": { + "constant": false, + "name": "balanceOf", + "scope": 379, + "stateVariable": true, + "storageLocation": "default", + "type": "mapping(address => uint256)", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "type": "mapping(address => uint256)" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 229, + "name": "ElementaryTypeName", + "src": "473:7:2" + }, + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 230, + "name": "ElementaryTypeName", + "src": "484:7:2" + } + ], + "id": 231, + "name": "Mapping", + "src": "465:27:2" + } + ], + "id": 232, + "name": "VariableDeclaration", + "src": "465:44:2" + }, + { + "attributes": { + "constant": false, + "name": "allowance", + "scope": 379, + "stateVariable": true, + "storageLocation": "default", + "type": "mapping(address => mapping(address => uint256))", + "value": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "type": "mapping(address => mapping(address => uint256))" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 233, + "name": "ElementaryTypeName", + "src": "523:7:2" + }, + { + "attributes": { + "type": "mapping(address => uint256)" + }, + "children": [ + { + "attributes": { + "name": "address", + "type": "address" + }, + "id": 234, + "name": "ElementaryTypeName", + "src": "542:7:2" + }, + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 235, + "name": "ElementaryTypeName", + "src": "553:7:2" + } + ], + "id": 236, + "name": "Mapping", + "src": "534:27:2" + } + ], + "id": 237, + "name": "Mapping", + "src": "515:47:2" + } + ], + "id": 238, + "name": "VariableDeclaration", + "src": "515:64:2" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": true, + "kind": "constructor", + "modifiers": [ + null + ], + "name": "", + "scope": 379, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 239, + "name": "ParameterList", + "src": "597:2:2" + }, + { + "attributes": { + "parameters": [ + null + ] + }, + "children": [], + "id": 240, + "name": "ParameterList", + "src": "607:0:2" + }, + { + "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": 232, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 241, + "name": "Identifier", + "src": "617:9:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 242, + "name": "Identifier", + "src": "627:3:2" + } + ], + "id": 243, + "name": "MemberAccess", + "src": "627:10:2" + } + ], + "id": 244, + "name": "IndexAccess", + "src": "617:21:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 209, + "type": "uint256", + "value": "totalSupply" + }, + "id": 245, + "name": "Identifier", + "src": "641:11:2" + } + ], + "id": 246, + "name": "Assignment", + "src": "617:35:2" + } + ], + "id": 247, + "name": "ExpressionStatement", + "src": "617:35:2" + } + ], + "id": 248, + "name": "Block", + "src": "607:52:2" + } + ], + "id": 249, + "name": "FunctionDefinition", + "src": "586:73:2" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "modifiers": [ + null + ], + "name": "transfer", + "scope": 379, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "_to", + "scope": 290, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 250, + "name": "ElementaryTypeName", + "src": "683:7:2" + } + ], + "id": 251, + "name": "VariableDeclaration", + "src": "683:11:2" + }, + { + "attributes": { + "constant": false, + "name": "_value", + "scope": 290, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 252, + "name": "ElementaryTypeName", + "src": "696:7:2" + } + ], + "id": 253, + "name": "VariableDeclaration", + "src": "696:14:2" + } + ], + "id": 254, + "name": "ParameterList", + "src": "682:29:2" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "success", + "scope": 290, + "stateVariable": false, + "storageLocation": "default", + "type": "bool", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "bool", + "type": "bool" + }, + "id": 255, + "name": "ElementaryTypeName", + "src": "728:4:2" + } + ], + "id": 256, + "name": "VariableDeclaration", + "src": "728:12:2" + } + ], + "id": 257, + "name": "ParameterList", + "src": "727:14:2" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "type": "function (bool) pure", + "value": "require" + }, + "id": 258, + "name": "Identifier", + "src": "752:7:2" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": ">=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 232, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 259, + "name": "Identifier", + "src": "760:9:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 260, + "name": "Identifier", + "src": "770:3:2" + } + ], + "id": 261, + "name": "MemberAccess", + "src": "770:10:2" + } + ], + "id": 262, + "name": "IndexAccess", + "src": "760:21:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 253, + "type": "uint256", + "value": "_value" + }, + "id": 263, + "name": "Identifier", + "src": "785:6:2" + } + ], + "id": 264, + "name": "BinaryOperation", + "src": "760:31:2" + } + ], + "id": 265, + "name": "FunctionCall", + "src": "752:40:2" + } + ], + "id": 266, + "name": "ExpressionStatement", + "src": "752:40:2" + }, + { + "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": 232, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 267, + "name": "Identifier", + "src": "802:9:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 268, + "name": "Identifier", + "src": "812:3:2" + } + ], + "id": 269, + "name": "MemberAccess", + "src": "812:10:2" + } + ], + "id": 270, + "name": "IndexAccess", + "src": "802:21:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 253, + "type": "uint256", + "value": "_value" + }, + "id": 271, + "name": "Identifier", + "src": "827:6:2" + } + ], + "id": 272, + "name": "Assignment", + "src": "802:31:2" + } + ], + "id": 273, + "name": "ExpressionStatement", + "src": "802:31:2" + }, + { + "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": 232, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 274, + "name": "Identifier", + "src": "843:9:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 251, + "type": "address", + "value": "_to" + }, + "id": 275, + "name": "Identifier", + "src": "853:3:2" + } + ], + "id": 276, + "name": "IndexAccess", + "src": "843:14:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 253, + "type": "uint256", + "value": "_value" + }, + "id": 277, + "name": "Identifier", + "src": "861:6:2" + } + ], + "id": 278, + "name": "Assignment", + "src": "843:24:2" + } + ], + "id": 279, + "name": "ExpressionStatement", + "src": "843:24:2" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 220, + "type": "function (address,address,uint256)", + "value": "Transfer" + }, + "id": 280, + "name": "Identifier", + "src": "882:8:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 281, + "name": "Identifier", + "src": "891:3:2" + } + ], + "id": 282, + "name": "MemberAccess", + "src": "891:10:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 251, + "type": "address", + "value": "_to" + }, + "id": 283, + "name": "Identifier", + "src": "903:3:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 253, + "type": "uint256", + "value": "_value" + }, + "id": 284, + "name": "Identifier", + "src": "908:6:2" + } + ], + "id": 285, + "name": "FunctionCall", + "src": "882:33:2" + } + ], + "id": 286, + "name": "EmitStatement", + "src": "877:38:2" + }, + { + "attributes": { + "functionReturnParameters": 257 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "hexvalue": "74727565", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "bool", + "type": "bool", + "value": "true" + }, + "id": 287, + "name": "Literal", + "src": "932:4:2" + } + ], + "id": 288, + "name": "Return", + "src": "925:11:2" + } + ], + "id": 289, + "name": "Block", + "src": "742:201:2" + } + ], + "id": 290, + "name": "FunctionDefinition", + "src": "665:278:2" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "modifiers": [ + null + ], + "name": "approve", + "scope": 379, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "_spender", + "scope": 318, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 291, + "name": "ElementaryTypeName", + "src": "966:7:2" + } + ], + "id": 292, + "name": "VariableDeclaration", + "src": "966:16:2" + }, + { + "attributes": { + "constant": false, + "name": "_value", + "scope": 318, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 293, + "name": "ElementaryTypeName", + "src": "984:7:2" + } + ], + "id": 294, + "name": "VariableDeclaration", + "src": "984:14:2" + } + ], + "id": 295, + "name": "ParameterList", + "src": "965:34:2" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "success", + "scope": 318, + "stateVariable": false, + "storageLocation": "default", + "type": "bool", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "bool", + "type": "bool" + }, + "id": 296, + "name": "ElementaryTypeName", + "src": "1016:4:2" + } + ], + "id": 297, + "name": "VariableDeclaration", + "src": "1016:12:2" + } + ], + "id": 298, + "name": "ParameterList", + "src": "1015:14:2" + }, + { + "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, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "mapping(address => uint256)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 238, + "type": "mapping(address => mapping(address => uint256))", + "value": "allowance" + }, + "id": 299, + "name": "Identifier", + "src": "1040:9:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 300, + "name": "Identifier", + "src": "1050:3:2" + } + ], + "id": 301, + "name": "MemberAccess", + "src": "1050:10:2" + } + ], + "id": 303, + "name": "IndexAccess", + "src": "1040:21:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 292, + "type": "address", + "value": "_spender" + }, + "id": 302, + "name": "Identifier", + "src": "1062:8:2" + } + ], + "id": 304, + "name": "IndexAccess", + "src": "1040:31:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 294, + "type": "uint256", + "value": "_value" + }, + "id": 305, + "name": "Identifier", + "src": "1074:6:2" + } + ], + "id": 306, + "name": "Assignment", + "src": "1040:40:2" + } + ], + "id": 307, + "name": "ExpressionStatement", + "src": "1040:40:2" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address_payable", + "typeString": "address payable" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 228, + "type": "function (address,address,uint256)", + "value": "Approval" + }, + "id": 308, + "name": "Identifier", + "src": "1095:8:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 309, + "name": "Identifier", + "src": "1104:3:2" + } + ], + "id": 310, + "name": "MemberAccess", + "src": "1104:10:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 292, + "type": "address", + "value": "_spender" + }, + "id": 311, + "name": "Identifier", + "src": "1116:8:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 294, + "type": "uint256", + "value": "_value" + }, + "id": 312, + "name": "Identifier", + "src": "1126:6:2" + } + ], + "id": 313, + "name": "FunctionCall", + "src": "1095:38:2" + } + ], + "id": 314, + "name": "EmitStatement", + "src": "1090:43:2" + }, + { + "attributes": { + "functionReturnParameters": 298 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "hexvalue": "74727565", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "bool", + "type": "bool", + "value": "true" + }, + "id": 315, + "name": "Literal", + "src": "1150:4:2" + } + ], + "id": 316, + "name": "Return", + "src": "1143:11:2" + } + ], + "id": 317, + "name": "Block", + "src": "1030:131:2" + } + ], + "id": 318, + "name": "FunctionDefinition", + "src": "949:212:2" + }, + { + "attributes": { + "documentation": null, + "implemented": true, + "isConstructor": false, + "kind": "function", + "modifiers": [ + null + ], + "name": "transferFrom", + "scope": 379, + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + "children": [ + { + "children": [ + { + "attributes": { + "constant": false, + "name": "_from", + "scope": 378, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 319, + "name": "ElementaryTypeName", + "src": "1189:7:2" + } + ], + "id": 320, + "name": "VariableDeclaration", + "src": "1189:13:2" + }, + { + "attributes": { + "constant": false, + "name": "_to", + "scope": 378, + "stateVariable": false, + "storageLocation": "default", + "type": "address", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "address", + "stateMutability": "nonpayable", + "type": "address" + }, + "id": 321, + "name": "ElementaryTypeName", + "src": "1204:7:2" + } + ], + "id": 322, + "name": "VariableDeclaration", + "src": "1204:11:2" + }, + { + "attributes": { + "constant": false, + "name": "_value", + "scope": 378, + "stateVariable": false, + "storageLocation": "default", + "type": "uint256", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "uint256", + "type": "uint256" + }, + "id": 323, + "name": "ElementaryTypeName", + "src": "1217:7:2" + } + ], + "id": 324, + "name": "VariableDeclaration", + "src": "1217:14:2" + } + ], + "id": 325, + "name": "ParameterList", + "src": "1188:44:2" + }, + { + "children": [ + { + "attributes": { + "constant": false, + "name": "success", + "scope": 378, + "stateVariable": false, + "storageLocation": "default", + "type": "bool", + "value": null, + "visibility": "internal" + }, + "children": [ + { + "attributes": { + "name": "bool", + "type": "bool" + }, + "id": 326, + "name": "ElementaryTypeName", + "src": "1249:4:2" + } + ], + "id": 327, + "name": "VariableDeclaration", + "src": "1249:12:2" + } + ], + "id": 328, + "name": "ParameterList", + "src": "1248:14:2" + }, + { + "children": [ + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "type": "function (bool) pure", + "value": "require" + }, + "id": 329, + "name": "Identifier", + "src": "1273:7:2" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "<=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 324, + "type": "uint256", + "value": "_value" + }, + "id": 330, + "name": "Identifier", + "src": "1281:6:2" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 232, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 331, + "name": "Identifier", + "src": "1291:9:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 320, + "type": "address", + "value": "_from" + }, + "id": 332, + "name": "Identifier", + "src": "1301:5:2" + } + ], + "id": 333, + "name": "IndexAccess", + "src": "1291:16:2" + } + ], + "id": 334, + "name": "BinaryOperation", + "src": "1281:26:2" + } + ], + "id": 335, + "name": "FunctionCall", + "src": "1273:35:2" + } + ], + "id": 336, + "name": "ExpressionStatement", + "src": "1273:35:2" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + ], + "overloadedDeclarations": [ + 397, + 398 + ], + "referencedDeclaration": 397, + "type": "function (bool) pure", + "value": "require" + }, + "id": 337, + "name": "Identifier", + "src": "1318:7:2" + }, + { + "attributes": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "operator": "<=", + "type": "bool" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 324, + "type": "uint256", + "value": "_value" + }, + "id": 338, + "name": "Identifier", + "src": "1326:6:2" + }, + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "uint256" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "mapping(address => uint256)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 238, + "type": "mapping(address => mapping(address => uint256))", + "value": "allowance" + }, + "id": 339, + "name": "Identifier", + "src": "1336:9:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 320, + "type": "address", + "value": "_from" + }, + "id": 340, + "name": "Identifier", + "src": "1346:5:2" + } + ], + "id": 341, + "name": "IndexAccess", + "src": "1336:16:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 342, + "name": "Identifier", + "src": "1353:3:2" + } + ], + "id": 343, + "name": "MemberAccess", + "src": "1353:10:2" + } + ], + "id": 344, + "name": "IndexAccess", + "src": "1336:28:2" + } + ], + "id": 345, + "name": "BinaryOperation", + "src": "1326:38:2" + } + ], + "id": 346, + "name": "FunctionCall", + "src": "1318:47:2" + } + ], + "id": 347, + "name": "ExpressionStatement", + "src": "1318:47:2" + }, + { + "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": 232, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 348, + "name": "Identifier", + "src": "1375:9:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 320, + "type": "address", + "value": "_from" + }, + "id": 349, + "name": "Identifier", + "src": "1385:5:2" + } + ], + "id": 350, + "name": "IndexAccess", + "src": "1375:16:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 324, + "type": "uint256", + "value": "_value" + }, + "id": 351, + "name": "Identifier", + "src": "1395:6:2" + } + ], + "id": 352, + "name": "Assignment", + "src": "1375:26:2" + } + ], + "id": 353, + "name": "ExpressionStatement", + "src": "1375:26:2" + }, + { + "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": 232, + "type": "mapping(address => uint256)", + "value": "balanceOf" + }, + "id": 354, + "name": "Identifier", + "src": "1411:9:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 322, + "type": "address", + "value": "_to" + }, + "id": 355, + "name": "Identifier", + "src": "1421:3:2" + } + ], + "id": 356, + "name": "IndexAccess", + "src": "1411:14:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 324, + "type": "uint256", + "value": "_value" + }, + "id": 357, + "name": "Identifier", + "src": "1429:6:2" + } + ], + "id": 358, + "name": "Assignment", + "src": "1411:24:2" + } + ], + "id": 359, + "name": "ExpressionStatement", + "src": "1411:24:2" + }, + { + "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, + "isConstant": false, + "isLValue": true, + "isPure": false, + "lValueRequested": false, + "type": "mapping(address => uint256)" + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 238, + "type": "mapping(address => mapping(address => uint256))", + "value": "allowance" + }, + "id": 360, + "name": "Identifier", + "src": "1445:9:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 320, + "type": "address", + "value": "_from" + }, + "id": 361, + "name": "Identifier", + "src": "1455:5:2" + } + ], + "id": 364, + "name": "IndexAccess", + "src": "1445:16:2" + }, + { + "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": 394, + "type": "msg", + "value": "msg" + }, + "id": 362, + "name": "Identifier", + "src": "1462:3:2" + } + ], + "id": 363, + "name": "MemberAccess", + "src": "1462:10:2" + } + ], + "id": 365, + "name": "IndexAccess", + "src": "1445:28:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 324, + "type": "uint256", + "value": "_value" + }, + "id": 366, + "name": "Identifier", + "src": "1477:6:2" + } + ], + "id": 367, + "name": "Assignment", + "src": "1445:38:2" + } + ], + "id": 368, + "name": "ExpressionStatement", + "src": "1445:38:2" + }, + { + "children": [ + { + "attributes": { + "argumentTypes": null, + "isConstant": false, + "isLValue": false, + "isPure": false, + "isStructConstructorCall": false, + "lValueRequested": false, + "names": [ + null + ], + "type": "tuple()", + "type_conversion": false + }, + "children": [ + { + "attributes": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_address", + "typeString": "address" + }, + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 220, + "type": "function (address,address,uint256)", + "value": "Transfer" + }, + "id": 369, + "name": "Identifier", + "src": "1498:8:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 320, + "type": "address", + "value": "_from" + }, + "id": 370, + "name": "Identifier", + "src": "1507:5:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 322, + "type": "address", + "value": "_to" + }, + "id": 371, + "name": "Identifier", + "src": "1514:3:2" + }, + { + "attributes": { + "argumentTypes": null, + "overloadedDeclarations": [ + null + ], + "referencedDeclaration": 324, + "type": "uint256", + "value": "_value" + }, + "id": 372, + "name": "Identifier", + "src": "1519:6:2" + } + ], + "id": 373, + "name": "FunctionCall", + "src": "1498:28:2" + } + ], + "id": 374, + "name": "EmitStatement", + "src": "1493:33:2" + }, + { + "attributes": { + "functionReturnParameters": 328 + }, + "children": [ + { + "attributes": { + "argumentTypes": null, + "hexvalue": "74727565", + "isConstant": false, + "isLValue": false, + "isPure": true, + "lValueRequested": false, + "subdenomination": null, + "token": "bool", + "type": "bool", + "value": "true" + }, + "id": 375, + "name": "Literal", + "src": "1543:4:2" + } + ], + "id": 376, + "name": "Return", + "src": "1536:11:2" + } + ], + "id": 377, + "name": "Block", + "src": "1263:291:2" + } + ], + "id": 378, + "name": "FunctionDefinition", + "src": "1167:387:2" + } + ], + "id": 379, + "name": "ContractDefinition", + "src": "25:1531:2" + } + ], + "id": 380, + "name": "SourceUnit", + "src": "0:1556:2" + }, + "compiler": { + "name": "solc", + "version": "0.5.16+commit.9c3226ce.Emscripten.clang" + }, + "networks": { + "5777": { + "events": { + "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925": { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef": { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + } + }, + "links": {}, + "address": "0x26B17441cF82809Aeb93634720D640f4ce364B78", + "transactionHash": "0x24f0621d93503359995b7aab948edc8df0fb55db667cd0313445fb57f38c8801" + } + }, + "schemaVersion": "3.3.4", + "updatedAt": "2021-02-21T16:03:22.180Z", + "networkType": "ethereum", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/src/components/App.js b/src/components/App.js index 588f6251f..37aa38887 100755 --- a/src/components/App.js +++ b/src/components/App.js @@ -1,51 +1,145 @@ -import React, { Component } from 'react'; -import logo from '../logo.png'; -import './App.css'; - -class App extends Component { - render() { - return ( -
- -
-
-
-
- - logo - -

Dapp University Starter Kit

-

- Edit src/components/App.js and save to reload. -

- - LEARN BLOCKCHAIN NOW! - -
-
-
+
+ + {content} +
+
- ); - } -} + + ); +}; export default App; diff --git a/src/components/BuyForm.js b/src/components/BuyForm.js new file mode 100644 index 000000000..e9dd47a37 --- /dev/null +++ b/src/components/BuyForm.js @@ -0,0 +1,79 @@ +import React, { useRef, useState } from "react"; +import tokenLogo from "../token-logo.png"; +import ethLogo from "../eth-logo.png"; + +function BuyForm(props) { + const ref = useRef({ input: null }); + const [state, setState] = useState({ input: "0" }); + + return ( +
{ + event.preventDefault(); + let etherAmount; + etherAmount = ref.current.input.value.toString(); + etherAmount = window.web3.utils.toWei(etherAmount, "Ether"); + props.buyTokens(etherAmount); + }} + > +
+ + + Balance: {window.web3.utils.fromWei(props.ethBalance, "Ether")} + +
+
+ { + const etherAmount = ref.current.input.value.toString(); + setState({ ...state, output: etherAmount * 100 }); + }} + ref={(input) => { + ref.current.input = input; + }} + className="form-control form-control-lg" + placeholder="0" + required + /> +
+ +
    ETH
+
+
+
+ + + Balance: {window.web3.utils.fromWei(props.tokenBalance, "Ether")} + +
+
+ +
+ +
  DApp
+
+
+
+ Exchange Rate + 1 ETH = 100 DApp +
+ +
+ ); +} + +export default BuyForm; diff --git a/src/components/Main.js b/src/components/Main.js new file mode 100644 index 000000000..985a6b0f1 --- /dev/null +++ b/src/components/Main.js @@ -0,0 +1,56 @@ +import React, { useState, useRef } from "react"; +import BuyForm from "./BuyForm"; +import SellForm from "./SellForm"; + +function Main(props) { + const [state, setState] = useState({ currentForm: "buy" }); + + let content; + if (state.currentForm === "buy") { + content = ( + + ); + } else { + content = ( + + ); + } + + return ( +
+
+ + <   > + +
+ +
+
{content}
+
+
+ ); +} + +export default Main; diff --git a/src/components/Navbar.js b/src/components/Navbar.js new file mode 100644 index 000000000..3e30443ca --- /dev/null +++ b/src/components/Navbar.js @@ -0,0 +1,38 @@ +import React from 'react' +import Identicon from 'identicon.js'; +function Navbar(props) { + return ( + + ) +} + +export default Navbar diff --git a/src/components/SellForm.js b/src/components/SellForm.js new file mode 100644 index 000000000..bcaff97cc --- /dev/null +++ b/src/components/SellForm.js @@ -0,0 +1,85 @@ +import React, { useRef, useState } from "react"; +import tokenLogo from "../token-logo.png"; +import ethLogo from "../eth-logo.png"; + +function SellForm(props) { + const ref = useRef({ input: null }); + const [state, setState] = useState({ input: "0" }); + + return ( +
{ + event.preventDefault(); + let etherAmount; + etherAmount = ref.current.input.value.toString(); + etherAmount = window.web3.utils.toWei(etherAmount, "Ether"); + props.sellTokens(etherAmount); + }} + > +
+ + + Balance: {window.web3.utils.fromWei(props.tokenBalance, "Ether")} + +
+
+ { + const tokenAmount = ref.current.input.value.toString(); + setState({ + output: tokenAmount / 100, + }); + }} + ref={(input) => { + ref.current.input = input; + }} + className="form-control form-control-lg" + placeholder="0" + required + /> +
+
+ +   DApp +
+
+
+
+ + + Balance: {window.web3.utils.fromWei(props.ethBalance, "Ether")} + +
+
+ +
+
+ +     ETH +
+
+
+
+ Exchange Rate + 100 DApp = 1 ETH +
+ +
+ ); +} + +export default SellForm; diff --git a/src/contracts/EthSwap.sol b/src/contracts/EthSwap.sol new file mode 100644 index 000000000..b1c5d9a85 --- /dev/null +++ b/src/contracts/EthSwap.sol @@ -0,0 +1,57 @@ +pragma solidity ^0.5.0; + +import "./Token.sol"; + +contract EthSwap { + string public name = "EthSwap Instants exchange"; + Token public token; + uint256 rate = 100; + event TokensPurchase( + address account, + address token, + uint256 amount, + uint256 rate + ); + + event TokensSold( + address account, + address token, + uint256 amount, + uint256 rate + ); + + constructor(Token _token) public { + token = _token; + } + + function buyTokens() public payable { + //calculate the number of tokens to buy + uint256 tokenAmount = rate * msg.value; + + // requires that EthSwap has enough tokens + require(token.balanceOf(address(this)) >= tokenAmount);// note the 'this' refferences the contract address (ie EthSwap address) + + //transfer token to user + token.transfer(msg.sender, tokenAmount); + + //Emit an event + emit TokensPurchase(msg.sender, address(token), tokenAmount, rate); + } + + function sellTokens(uint _amount) public { + // users can't sell more tokens than they have + require(token.balanceOf(msg.sender) >= _amount); + //calculate the number of ether to redeem + uint256 etheAmount = _amount / rate; + + // requires that EthSwap has enough ethers + require(address(this).balance >= etheAmount);// note the 'this' refferences the contract address (ie EthSwap address) + + //transfer token to user + token.transferFrom(msg.sender, address(this), _amount); + msg.sender.transfer(etheAmount); + + //Emit an event + emit TokensSold(msg.sender, address(token), _amount, rate); + } +} diff --git a/src/contracts/Migrations.sol b/src/contracts/Migrations.sol index c378ffb02..74ecda2f0 100644 --- a/src/contracts/Migrations.sol +++ b/src/contracts/Migrations.sol @@ -1,23 +1,23 @@ pragma solidity >=0.4.21 <0.6.0; contract Migrations { - address public owner; - uint public last_completed_migration; + address public owner; + uint256 public last_completed_migration; - constructor() public { - owner = msg.sender; - } + constructor() public { + owner = msg.sender; + } - modifier restricted() { - if (msg.sender == owner) _; - } + modifier restricted() { + if (msg.sender == owner) _; + } - function setCompleted(uint completed) public restricted { - last_completed_migration = completed; - } + function setCompleted(uint256 completed) public restricted { + last_completed_migration = completed; + } - function upgrade(address new_address) public restricted { - Migrations upgraded = Migrations(new_address); - upgraded.setCompleted(last_completed_migration); - } + function upgrade(address new_address) public restricted { + Migrations upgraded = Migrations(new_address); + upgraded.setCompleted(last_completed_migration); + } } diff --git a/src/contracts/Token.sol b/src/contracts/Token.sol new file mode 100644 index 000000000..0c99ffdf1 --- /dev/null +++ b/src/contracts/Token.sol @@ -0,0 +1,51 @@ +pragma solidity ^0.5.0; + +contract Token { + string public name = "DApp Token"; + string public symbol = "DAPP"; + uint256 public totalSupply = 1000000000000000000000000; // 1 million tokens + uint8 public decimals = 18; + + 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; + mapping(address => mapping(address => uint256)) public allowance; + + constructor() public { + balanceOf[msg.sender] = totalSupply; + } + + function transfer(address _to, uint256 _value) public returns (bool success) { + require(balanceOf[msg.sender] >= _value); + balanceOf[msg.sender] -= _value; + balanceOf[_to] += _value; + emit Transfer(msg.sender, _to, _value); + return true; + } + + function approve(address _spender, uint256 _value) public returns (bool success) { + allowance[msg.sender][_spender] = _value; + emit Approval(msg.sender, _spender, _value); + return true; + } + + function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) { + require(_value <= balanceOf[_from]); + require(_value <= allowance[_from][msg.sender]); + balanceOf[_from] -= _value; + balanceOf[_to] += _value; + allowance[_from][msg.sender] -= _value; + emit Transfer(_from, _to, _value); + return true; + } +} \ No newline at end of file diff --git a/src/eth-logo.png b/src/eth-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..b5fe9f6b84c6d92eb1675ca2672d9b5976ec21cf GIT binary patch literal 4472 zcmai2c{r4P_a7O%QCYGxSwdkJ`!JY=NRuU%vSiGRH8UDxm+V`}Rv~+2CnOQsWh@EV zLJB1zDqC54r{{fo-uI8+_5SYby6^A#p6m1Zobx^B-1i@MjM=%_-GiUSF3?2dOLS&;BVzw3084gkQ+=VEC^ zv%;N45Gd}-_}>_1Uw01%8vxMJ^Yy?J+(~9d>4J595exx$5)BXbb-zaTMED}5{?bJ-?B8yP6!4Xt1A&;s+wR8EoGRxDpW;X5e$dIv>;GT2uwu@3PV8E5o#LXzb`39 zG%C>%VSzRLI~HSylyaugJP;6wkB^VCkBTyd>I8vlX)!e55I9_kfl%`FBh&D{N@P#z zKMGiqCxPnXL35#y!M_#p4iqmMQi_r3zmMSVfy4bHO!oY{P>hm6eDNL-m@*XN?*98+ zf1y2T7Nq~A@qeN{E&V)55DStg#fwT{^utm551CQB{~hQzkdX}nOCfl**duGlQ8pYF@;=yPY916za2`=Q{j^DNYJ5>_Z#hXMlq*C0$e-#Je z@?QyH;p!?_tSVH~0Aql{s=&3>F)%b%RZ|nIp#?QW!=?V_5dZ7I|1Sr^2oCw($^Yu? z9~Wa>ew+WyDP!}`q?5>u@uo87*kOCAYaG_$fe54!3i`tg2jdaI@J52 z+_lhvs;b!xPdgQ9_KuBZ-!f%xWYt>pV)k0#qV{52R=Ez_CGPWVC|U@sL~;30n<^la zN5T@v7Wpf>$TzxMOTNbh)icnMj$rFd`5a8NNS}Dse*2;&L0^ZXi=KM9!1Z0etZax$ zL#Eks>bs_nww#mfOKi5uPm7?Y2=mk`eQRyDP28b%2hKocW+A>-D9%hE(uqlawL_oZ z>y;|#(tM?64M3f>(hXE~t0P|1*(ECIL(%4sqOz3wy6%mybQxXdlLu|@ANu+xF=rRH zgc<&LLvXBgZ1os79yBo4@mUuk;Ezhy>dHT#&T#)g#f(`C4zk_H>;C7N%o1UM%e>oLM})NSQ6F zaCKEfqa>pqRj(b84~O}L!dTqR`KWtG($z0osTW)NV=jVvAdc@68xxL>$)>(qMd`J- z(c8w5z2DaY3!21Dh4Mm=%w6r7W=GgqzYb1y@b2!bYl47*--mXooO^3G%bTCCet&(k zC@d`aUTyBgs6B0WHoLKMK0XcHC)V@~_rrdB{7r{Yv=DQqz$x$CkzsOc5Bw-+yH01a z<7q`7(c5<66_STr)}puiKvN493(?bHVa%9~Ryy6rW9fC0QV0HUCrKhZ;KEzKg~z%@ z(0h~L&{1+3Q{2;;ZG>$W`vow^n<16-O4Q&`HVdBhgFtt`pq=p-oD85H#g=a%gKoJt z$Kjbv5JB_oP(xd_sqfZABb4OIUatv!s44%Hm`x#%4U$Bs;&(oWP*)sa0!&16hZ%-e5+@%XX*G$d0VAJX( z@CsOx!3rV^%?HCUViyCCAWg-i?$@efCWV1@$!I1Xu?r7d4(t{Ts+<87`~2<*#EE%L z=JFWLQ~fLx%~#WR*Rp!Qs$p{T#sWhfA_9Ua#uU~_~Tr;-k;IVX~2q43f+@e z>*aHzDsl>gstGy%m&gf#jF(3om+1L5qEf~h=su9#OD*KGZun;Egp7i=e<6r2%C+d5 zd)f|xOA>Uh0E+l_ILj@3T)$XT>uJ7m!`Nss%cov$d`y)dbW@)t>wK#{XLod^RJo-G zmq_4am4=__+7m1=x^UzT=}&hds`CTe$M6S=YXYpp?>n4d>XpRIle54orulGRMx(O^9?I%^MyEU^@tdsxVnH}mplbjeE^JN+{vgzE6}XoxI{H8wWzhE+huqZR(zd!nP8BGd3mjt8vTje(WY zuN2meEqjfC-k70~&Lj)m#0~ue6CE;|`;O+R9ux5F3og^F3m;jUnkvG56s}1<1(RmG z^ftV>S}yj>-7vwXL2YVkbcyfpt#?0Q@u)cmSbl%B6WCUM9(Q7?w zQ71?fib&rbE6I)n$+3P95Duio@x6DLd^Q$G;i#7Pa24;=bsJ5Geg&<8#mLlP%L(s+M$-Ya(HmvlR|Q54L>lXPq}qj zHBGw%#B5TioWlnzHg0Pavtg?lju7xib!mB(kMtgnDL_V>R~ypn)$#}J7eyu}uIU?y zT0BwiC9Ky@J=$mgevHZ2$ z!aX)3uj@Z0CYA^%=}r`KV^W~Fvj%>-Jk6L?amFXJW;G@|13Jxdr%ojBXCe2Gy#7=T zEv6LLZ2cQ@+4ZLbfDs?K0)5L4iRmPT8iotaNU=PYEbDO-&wY@Nx{kg*bS1t*p`Q(i z6z|SQ=w7PANZXxZ)1pQ3q#E+Hc{{)R!W7OSez2~t-%0L#ApUP%M0ab;mI zNbL6A$NU~uv22gT_WiUJ`pkaJAn&f*2DuUCL?cTEqa+$Xa@FNCIlRy+9|m>s4b zR~;)NF7VWKlWz2+AhmxiS0_9`9ahEn*>d15h_{l<>`TiAb|QIU`AH}K!yEaPiF=Q; z^Ymp0Z9$G3M`64Q6EZboGY3f{8C|s6qNnd3F54c#oKc52fp8DtA|mPX90J~_#6pK6 z-8q&|(Nc`nlXbCw8Vo0ewM9j6_L!+vBXHf zvd9Ln46ZH0+_m;5Or)c$(W^np4{Np?_e1%d2BxxjUS5gt|BJ zg{6j>9xixS8>V1_0N&vC7reEj@=>t-LXXL+IbW%(0?PHS#dE)8KG1q=Vvtl*%yl0C zh|WcNy8*5kuV>rl-F}-;{OG#1MIpCKR3u&KOi**IuhstU^vl7+$HmWEOf}x4GKDp0 zH0B9@jDZ}Sk`8Y~`k`>qaF&Z7pI#D0EKnjVxPtRnyYgq zv^QD5P*ZhdUiIzD$3r&5)y^8R#))U#9gJu=)Svk&blBl-@0_(a-Dnh{T9=+C%5Adr zR(&A8v~{xKqBvXOwhC)MkRrumx44E(YZjb&9~Q%&cQRFi zAL4F4W5L9~gJqRmJ=adJE$yOtXGjpk$3ak9@P^dUun$QAr}c6VuPE&&Ijh~TG}P=t zX~%Xt*}1oTR>ABVkL8J8*`UcfhmP_oSD7V=5qrMEteqcO0PX_!17ak3mX<4z0mn6} z1iI~BWS=O}Pwx1V+i}O?)!G3f!s@o|*ML%$VhrXUb}6KBW!0*P@;3dE?gP=f6sDdB zmbJGfq>!b~tlh<1@yAW%^m5}Q6m_s_tbO@9d8nGbE)Xm{c376b#M+2$w&oO*U?MQ| zlY(}ZD8iaAh_Yb6G?TX<@nGm_!effvLB7*R;&$(}*ohHQ>1RhCh;G`4d`K12se3q6 zI$z~z%ud>Ui&5Z@j+K4C+8HtG9Xm9o_%c(=ywP-Ap8pfea6NZ}=epGQg!|!4uug5Y z;guR8(h6GfMwzSE&hneBzPJMBsP(PE>~VYTk3x`A=Ilw8P`fRx1ET*K-E*+j!YSa) zhiZg?8ItSLbN>KhcTL9Rd9m%+4s$iGQHpbgKGlG=o5|s(TXNdZ|>CX)6x@;wO> zf=Gy3sA6% zjk4~BUi({vDP|E894xEb_m)=2dr%3so|LWGS^hi;6}Fn611rM~%Qx%xhVZ1hjPINN zMQ*F!12M}v%|`S)&aD!!?TOfj1|~1=^4Fpy1GOlTP8n=7_w~`d=Gp6?WmVWBeHzSu zj49oJ2-yqag6TzUB+ewKVWoxjd7Jm*Tse&EQ%J-p0Y1aVnDP4XU%s!wcvnq%5gx^1 z<2g^k`$6KhQyx?6%TW?Jnl?5@$a3G|gT8bd;zQfw=#mPN4ac#MctPvZ)Z7JbG*}AR4Xbn5Nn!VMA5%GN(hnnh>G?(~Jk|TS(S@2~CGmXaWL&%Y7awu4T?@7ta zU2^(@&Dknsv8QK6Y9fs3U@4(cfXk7qYd)%4wt#*`DqS>{Bd!M!%OWh$ny5Q{-?J!& zB;DJ2sd!YTsBzHEM)K*@R`<=fHN62l;nh1fVOuteNnc{EVVx_B;*I>hhd1;T&u~t3 z2gzPDs5(SGeAx+LN^vuv`(*W^IJlAX=P_;b=c2Rm$Fo@7?G#4U+)~P18`!G9JxiH3 zO*;FFaq3e ze(s|Ol16*pFX6lwBu4@R_s^V0!-7OiJfzKjao-WR7@gSD(P6Tbpd-^vt`zpX)I2+Q zZ#T0Wm18||>nshMY?Mnq97=|Fr)L{k6G`ob?({c-2HvK|G0cddyDPj%Hl#oLffq@NzQ^D zwXsA+1n=F(2^E4(iEHN0bz%B)L&$7Eh(Kdf0I*dc*$;3A$h6R)r+|Tw(3VKLt2@`- z&K6H)2Exc2Ixt=!OMn&C=nO;1eEkCmm`*cvo;ROVN0GABr1qLuUc%C8TFJ8Pr-nfQCz<;T5j~hb%cFNt( z5lm#V0WcP(1EnG{dSG1~45@=bpmh#{Q3xasj?jZ6(NF{ukI=zmb-_O$h`<_~=8JbG zng6sUI2l6xxm*?=4i5F`ch4`dAb0=Y(1xPG8@vOXE+`5)fW)Mp2m}~hE0Q5Z@C8Pr z)9@%?Uz{F_st2WDeUVTs1_MCJx>ytxheH4efI{;{V10k_{2Lx&N6j9JVXYV(E}20Ee%YoAZ2!dS{$DJf$Ogz1A{1unujy5@hn=+~8?H8;e6W{3|@+uwD%Lad6lkT<7lHT*Si0hbc!R!6fDCJ+M)O*-ez-< z70J#PLukKFlKrvCNtVDjxgK}On*PkUt_&SmP&r&XP&-}wPW9S+w#(Jzkef>{ZK2Fh z*3f~an! z*t<3oBs9|!9@jFRbEWNW$yZZoH3-rs>o(R%RS3gcFydQ?%@zy8m4r8!eUEB=d^u5R zTp!D0Rk&r)lnxJ>R6E8Ty8UNycXs~i*-e|jdpYxrv1&d8C2<~ow{e`E%|b}KtqL~H zlQ#}FnIJBo)~MxhZ)%@SJ1JMLw;p#S$_w4+SJmaecyiXhW9Ni|4Z)PRhcgN;t$UZ$ zyV9|W^c;g?L?sGY_W>EL&+g;Brq+a6{T+EL%T4Dq%L2L%EO=&3XGu#-K4_3T6YyF# zt1Uih{=UR9y{+0ap;76&V$mR}OK00vs3sQdEstLhNj?&%LEEQ*(!C7uksRpPc{pEH z$zr8NOQdG-^xO*tYC=Syjt%X!YP62c`0}Z=7CE7j+fAa6U?x5bZ1+dWoKq@aEBid2 zISf|27X9wjjpRL<1-Z0NGZgvduR}XSvnP@HP9sVZsc-WU`Q)u`N1vW|eXnzS==Y|T z%cT3GsUB5b?9dxMrG&O8jEDEyw>sVN+8kwhwk2tSa?dOtwcv2UQ8!Uk(o6j468O3E z{UMuSbb5=Qr!*`2!=1yOPCX|SNlgU4LJ#?ZwbcH6i}uLR7SbQYAr@G-MlbD_@zIAj zb;BiV+f##j6D>P{LjLYBK(^RAcW9w*Ho4cV??IisOd5d9$?q)5v}wEHbgyhS>x^TY z5T02-^mI)4PW!A<4p>QAPp47Z=m=?{6O(Lty1*LoEHtKvNeEpxepNWGzUn#WP@iz1 zvoaOri|opHqRESZj*Zo7_kjW+M~`*ib(_r9?( zOX6sZRIKh}*TH(`mF+ES*MC#AIb1(>!rO*qt?{by)UNK46B4$sT;Lqdy+?YWOJ>n0 zAWyC+hVgSNR`pPBCBy_XVw%R2AerfC9yIP5Rwb6CI&oGp>bXdqL$tD;`g$w1Fhw=0 zJBUzEf+>&=XG4o`)k=yO*LGcQFKTe>j7hLlFl|Zy?(Ao6*BAf6wqxlKi!M zUHnz+rafaoF65ljsf)5f#@X?a&hd{CeA@}1t>4R)T{H50e%umTQ3g6ySeTp2+vPf} zI-`x2qr_a}*JG!Oww%u|3bqoR29XZGa2sqbaG-umQ8Nv<)7{6t+ohMA1ABMJ=2)BTDQZpi4$ykWfYL|u z?i8%xRE+t;*1RSVJ;TuDQLv%&cu>E7)Uc@iB{`PJ&ZdH$QYMwt2`KEgx0}3>TEyKi zef(F&hQFwemrrYdyz=e7e4&F>e%K6D>!C_bBM4&D)e+!w+rggP_oXNQ^P~!r-dnsa z?QLw7+f}m;O*|`o)@kt%`ZDSuBbzoES1nq~CvV}0Xv!V*E1VtFjeY8_`glO|o40Pj zp*ZKF{6U33JCBZ>!LcRT^M9D~d!t&k)i3&v96P)##ZqR#+`XbQIUxT{`Oc!Mu`cPc z*Zoy$uP;emez1>@%2YxviUn8KqT&i%8*)k@o*2;kBp2?^!)1=3ipF%aC;;49my9gRGQOV9Kc!`OZ39WF85}94h?&! zuDCe5SRLK6wBl51&awh0jJK=1haBOr842%4d*QWlzaQCN65Sd@Q8`$5s|ExS4jSU) zByy*sowLm;@6e)m%$G0EM>M?MuP!UoMCAS9r_|mdmZ5#*@&}!4xO0R^MpsaC?QjCR zAUU4$-fQ=hQL|mPo3k4}l)f2xilN{z%RfQgwqQd_bAt|%bf||^r=F1 z#{Dxk)8AWJ!@~!ELFJ~bQJ;<5^^A<%in+yQQkc}k{s!enZ=>a+t2~mc=S!av(eS5w ztHm!e;%gmK8V)2h=#(YqiD?nHU7sBkIj|S|05qTHS=MpDN-;|$32I69QNn!nL`pfN zx7eq8dlapXR`5ZVrhJ)AnxN8Qryp-SJMiS%N2DwvMj5ytJD-c9apI(C~8 zDaE$JtUj+k$g0eBJ~%;>oN$+{p3_q{RIansu#%6%-7r?qe==X1PaO{8&R?qhUhZLB zb=GLB)ni(00cc?Fr@US>a>=8~Z@VRW;Lci*@R*XQVqL&u{F&&assJe2e>T$7p!lTUm7$vmd_ z+^Ny$??+^Qd#5_JW1&ZZo--G(v68WGCru4N6Z{^mZSl`1%T>x3rVV^d3@hP% z@DyA1apC0IrFxi{Re9RZS~pxd9$o{zoNn6;EgMq1R{L!sBeOBfEi|$3Yyo)3u9!RV zsf907J$iFmzR9+`F-*pW%S>C#Q!*Q{39Hqg`_rI>)^eG_q}=!N7}7JDS(A?`nofoh z=aY(o*_f{U$`GehR^M53C8=>lbDtxI-+qYB^oyWB%b(p&yoF7_7JE!1#>-E}utOLV z_1wQprghs<&h6rM%j11E1~y998j~Qw8p&qN=X*QOFFg?cGCNydC->xv-D_33CQ?O` z2W&L@@!Z{D_KsVcOLs=5{56Fm>-&bw?wuI%TAYi1@ABU8%R~W~KajVaCDqaUBXRSs z%DCl6`#)>d$FnQ0w!*j(;iYyn@%$f29I=5#F1%`28*xa#xknDF;AejbwFeN|n&qhG=SoUKG2s+b()RrU$XE!~&Eb)Q+E z32tK=tJnNEH#He*0JXoz{FA0QotEP#p2L!`s`PE|`_o4&n9C-lb3+i5ca3F3bQ%W@ zH2Iph@~T(+AAYs-P*tLQ75)J|XPjh+Rp8g|UVL8VXBMSy#LBtm`XlvT#4xSz;koe4 z<-t&mkA`nL{9dd;*Lvq0z2|$@&TW;FRoi!})A`%6xA99nhlKkC+Z^KNH)^CEpyOj} zhi>fEzha)%r_x+D#>gwyNV6fCU`o#M97NW-=U_2aTi1JJ9(_0rmt5&L2ub8!;K|Gx zM_Egpa;%AoG)Qk0?hj+8*7OfNGI;wbh#5IrsIZ { + let token, ethSwap; + const tokenValue = etherToWei("1000000"); + before(async () => { + token = await Token.new(); + ethSwap = await EthSwap.new(token.address); + // ethSwap = await EthSwap.new(token.address); + await token.transfer(ethSwap.address, tokenValue); //transfer 1 million tokens + }); + describe("Token deployment", async () => { + it("contract has a name", async () => { + const name = await token.name(); + assert.equal(name, "DApp Token"); + }); + }); + describe("EthSwap deployment", async () => { + it("contract has a name", async () => { + const name = await ethSwap.name(); + assert.equal(name, "EthSwap Instants exchange"); + }); + it("contract has token", async () => { + let balance = await token.balanceOf(ethSwap.address); + assert.equal(balance.toString(), tokenValue); + }); + }); + describe('buyTokens()', async() => { + let result; + before(async()=>{ + //purchase tokens before each example + result = await ethSwap.buyTokens({from:investor, value:etherToWei('1')}) + }) + it('Allows users to instantly purchase tokens from ethSwap for a fixed price', async()=>{ + // check investor's token balance after purchase + const investorBalance = await token.balanceOf(investor); + assert.equal(investorBalance.toString(), etherToWei('100')); + + //check EthSwap balance after purchase + const ethSwapTokenBalance = await token.balanceOf(ethSwap.address); + assert.equal(ethSwapTokenBalance.toString(), etherToWei('999900')); + const ethSwapEtherBalance = await web3.eth.getBalance(ethSwap.address); + assert.equal(ethSwapEtherBalance.toString(), etherToWei('1')) + + // check logs to ensure events was emitted with correct data + const events = result.logs[0].args; + assert.equal(events.account,investor); + assert.equal(events.token,token.address); + assert.equal(events.amount.toString(), etherToWei('100').toString()); + assert.equal(events.rate.toString(),"100") + }) + }); + describe('sellTokens()', async() => { + let soldTokenResult; + before(async()=>{ + // Investor must approve tokens before the seeling them. + await token.approve(ethSwap.address,etherToWei('100'), {from:investor}); + // Investor sells tokens + soldTokenResult = await ethSwap.sellTokens(etherToWei('100'), {from:investor}); + }) + it('Allows users to instantly sell tokens from ethSwap for a fixed price', async()=>{ + // check investor's balance + const investorBalance = await token.balanceOf(investor); + assert.equal(investorBalance.toString(), etherToWei('0')); + + //check EthSwap balance after purchase + const ethSwapTokenBalance = await token.balanceOf(ethSwap.address); + assert.equal(ethSwapTokenBalance.toString(), etherToWei('1000000')); + const ethSwapEtherBalance = await web3.eth.getBalance(ethSwap.address); + assert.equal(ethSwapEtherBalance.toString(), etherToWei('0')) + + // check logs to ensure events was emitted with correct data + const events = soldTokenResult.logs[0].args; + assert.equal(events.account,investor); + assert.equal(events.token,token.address); + assert.equal(events.amount.toString(), etherToWei('100').toString()); + assert.equal(events.rate.toString(),"100"); + + // FAILUR: Investor can't sell more tokens than they have + await ethSwap.sellTokens(etherToWei('500'), {from:investor}).should.be.rejected + }) + }); +}); diff --git a/truffle-config.js b/truffle-config.js index 92b5ae506..a1bcdfe32 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -16,7 +16,8 @@ module.exports = { optimizer: { enabled: true, runs: 200 - } + }, + evmVersion: "petersburg" } } }