UNPKG

@reality.eth/contracts

Version:

Collection of smart contracts for the Realitio fact verification platform

930 lines (929 loc) 670 kB
{ "contractName": "ERC20", "abi": [ { "anonymous": false, "inputs": [ { "indexed": true, "name": "from", "type": "address" }, { "indexed": true, "name": "to", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "owner", "type": "address" }, { "indexed": true, "name": "spender", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "Approval", "type": "event" }, { "constant": false, "inputs": [ { "name": "to", "type": "address" }, { "name": "val", "type": "uint256" } ], "name": "mint", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "owner", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [ { "name": "owner", "type": "address" }, { "name": "spender", "type": "address" } ], "name": "allowance", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "to", "type": "address" }, { "name": "value", "type": "uint256" } ], "name": "transfer", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "spender", "type": "address" }, { "name": "value", "type": "uint256" } ], "name": "approve", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "from", "type": "address" }, { "name": "to", "type": "address" }, { "name": "value", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "spender", "type": "address" }, { "name": "addedValue", "type": "uint256" } ], "name": "increaseAllowance", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "spender", "type": "address" }, { "name": "subtractedValue", "type": "uint256" } ], "name": "decreaseAllowance", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" } ], "bytecode": "0x608060405234801561001057600080fd5b50610629806100206000396000f3006080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461009d57806318160ddd146100d557806323b872dd146100fc578063395093511461012657806340c10f191461014a57806370a0823114610170578063a457c2d714610191578063a9059cbb146101b5578063dd62ed3e146101d9575b600080fd5b3480156100a957600080fd5b506100c1600160a060020a0360043516602435610200565b604080519115158252519081900360200190f35b3480156100e157600080fd5b506100ea61027e565b60408051918252519081900360200190f35b34801561010857600080fd5b506100c1600160a060020a0360043581169060243516604435610284565b34801561013257600080fd5b506100c1600160a060020a03600435166024356102f1565b34801561015657600080fd5b5061016e600160a060020a03600435166024356103a1565b005b34801561017c57600080fd5b506100ea600160a060020a03600435166103af565b34801561019d57600080fd5b506100c1600160a060020a03600435166024356103ca565b3480156101c157600080fd5b506100c1600160a060020a0360043516602435610415565b3480156101e557600080fd5b506100ea600160a060020a036004358116906024351661042b565b6000600160a060020a038316151561021757600080fd5b336000818152600160209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b60025490565b600160a060020a03831660009081526001602090815260408083203384529091528120546102b8908363ffffffff61045616565b600160a060020a03851660009081526001602090815260408083203384529091529020556102e784848461046d565b5060019392505050565b6000600160a060020a038316151561030857600080fd5b336000908152600160209081526040808320600160a060020a038716845290915290205461033c908363ffffffff61053a16565b336000818152600160209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6103ab8282610553565b5050565b600160a060020a031660009081526020819052604090205490565b6000600160a060020a03831615156103e157600080fd5b336000908152600160209081526040808320600160a060020a038716845290915290205461033c908363ffffffff61045616565b600061042233848461046d565b50600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b6000808383111561046657600080fd5b5050900390565b600160a060020a038216151561048257600080fd5b600160a060020a0383166000908152602081905260409020546104ab908263ffffffff61045616565b600160a060020a0380851660009081526020819052604080822093909355908416815220546104e0908263ffffffff61053a16565b600160a060020a038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008282018381101561054c57600080fd5b9392505050565b600160a060020a038216151561056857600080fd5b60025461057b908263ffffffff61053a16565b600255600160a060020a0382166000908152602081905260409020546105a7908263ffffffff61053a16565b600160a060020a0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350505600a165627a7a723058205d4b55c814f57b7f8e4de98a04c44aa090f8b55b5cccf7a0d6d00fcb9f0917980029", "deployedBytecode": "0x6080604052600436106100985763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663095ea7b3811461009d57806318160ddd146100d557806323b872dd146100fc578063395093511461012657806340c10f191461014a57806370a0823114610170578063a457c2d714610191578063a9059cbb146101b5578063dd62ed3e146101d9575b600080fd5b3480156100a957600080fd5b506100c1600160a060020a0360043516602435610200565b604080519115158252519081900360200190f35b3480156100e157600080fd5b506100ea61027e565b60408051918252519081900360200190f35b34801561010857600080fd5b506100c1600160a060020a0360043581169060243516604435610284565b34801561013257600080fd5b506100c1600160a060020a03600435166024356102f1565b34801561015657600080fd5b5061016e600160a060020a03600435166024356103a1565b005b34801561017c57600080fd5b506100ea600160a060020a03600435166103af565b34801561019d57600080fd5b506100c1600160a060020a03600435166024356103ca565b3480156101c157600080fd5b506100c1600160a060020a0360043516602435610415565b3480156101e557600080fd5b506100ea600160a060020a036004358116906024351661042b565b6000600160a060020a038316151561021757600080fd5b336000818152600160209081526040808320600160a060020a03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a350600192915050565b60025490565b600160a060020a03831660009081526001602090815260408083203384529091528120546102b8908363ffffffff61045616565b600160a060020a03851660009081526001602090815260408083203384529091529020556102e784848461046d565b5060019392505050565b6000600160a060020a038316151561030857600080fd5b336000908152600160209081526040808320600160a060020a038716845290915290205461033c908363ffffffff61053a16565b336000818152600160209081526040808320600160a060020a0389168085529083529281902085905580519485525191937f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929081900390910190a350600192915050565b6103ab8282610553565b5050565b600160a060020a031660009081526020819052604090205490565b6000600160a060020a03831615156103e157600080fd5b336000908152600160209081526040808320600160a060020a038716845290915290205461033c908363ffffffff61045616565b600061042233848461046d565b50600192915050565b600160a060020a03918216600090815260016020908152604080832093909416825291909152205490565b6000808383111561046657600080fd5b5050900390565b600160a060020a038216151561048257600080fd5b600160a060020a0383166000908152602081905260409020546104ab908263ffffffff61045616565b600160a060020a0380851660009081526020819052604080822093909355908416815220546104e0908263ffffffff61053a16565b600160a060020a038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008282018381101561054c57600080fd5b9392505050565b600160a060020a038216151561056857600080fd5b60025461057b908263ffffffff61053a16565b600255600160a060020a0382166000908152602081905260409020546105a7908263ffffffff61053a16565b600160a060020a0383166000818152602081815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a350505600a165627a7a723058205d4b55c814f57b7f8e4de98a04c44aa090f8b55b5cccf7a0d6d00fcb9f0917980029", "sourceMap": "2819:6750:3:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2819:6750:3;;;;;;;", "deployedSourceMap": "2819:6750:3:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4993:238;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;4993:238:3;-1:-1:-1;;;;;4993:238:3;;;;;;;;;;;;;;;;;;;;;;;;;3194:89;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3194:89:3;;;;;;;;;;;;;;;;;;;;5517:225;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;5517:225:3;-1:-1:-1;;;;;5517:225:3;;;;;;;;;;;;6213:317;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;6213:317:3;-1:-1:-1;;;;;6213:317:3;;;;;;;3044:82;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;3044:82:3;-1:-1:-1;;;;;3044:82:3;;;;;;;;;3492:104;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;3492:104:3;-1:-1:-1;;;;;3492:104:3;;;;;7006:327;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;7006:327:3;-1:-1:-1;;;;;7006:327:3;;;;;;;4220:137;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;4220:137:3;-1:-1:-1;;;;;4220:137:3;;;;;;;3927:129;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;3927:129:3;-1:-1:-1;;;;;3927:129:3;;;;;;;;;;4993:238;5058:4;-1:-1:-1;;;;;5082:21:3;;;;5074:30;;;;;;5124:10;5115:20;;;;:8;:20;;;;;;;;-1:-1:-1;;;;;5115:29:3;;;;;;;;;;;;:37;;;5167:36;;;;;;;5115:29;;5124:10;5167:36;;;;;;;;;;;-1:-1:-1;5220:4:3;4993:238;;;;:::o;3194:89::-;3264:12;;3194:89;:::o;5517:225::-;-1:-1:-1;;;;;5641:14:3;;5596:4;5641:14;;;:8;:14;;;;;;;;5656:10;5641:26;;;;;;;;:37;;5672:5;5641:37;:30;:37;:::i;:::-;-1:-1:-1;;;;;5612:14:3;;;;;;:8;:14;;;;;;;;5627:10;5612:26;;;;;;;:66;5688:26;5621:4;5704:2;5708:5;5688:9;:26::i;:::-;-1:-1:-1;5731:4:3;5517:225;;;;;:::o;6213:317::-;6293:4;-1:-1:-1;;;;;6317:21:3;;;;6309:30;;;;;;6391:10;6382:20;;;;:8;:20;;;;;;;;-1:-1:-1;;;;;6382:29:3;;;;;;;;;;:45;;6416:10;6382:45;:33;:45;:::i;:::-;6359:10;6350:20;;;;:8;:20;;;;;;;;-1:-1:-1;;;;;6350:29:3;;;;;;;;;;;;:77;;;6442:60;;;;;;6350:29;;6442:60;;;;;;;;;;;-1:-1:-1;6519:4:3;6213:317;;;;:::o;3044:82::-;3105:14;3111:2;3115:3;3105:5;:14::i;:::-;3044:82;;:::o;3492:104::-;-1:-1:-1;;;;;3573:16:3;3547:7;3573:16;;;;;;;;;;;;3492:104::o;7006:327::-;7091:4;-1:-1:-1;;;;;7115:21:3;;;;7107:30;;;;;;7189:10;7180:20;;;;:8;:20;;;;;;;;-1:-1:-1;;;;;7180:29:3;;;;;;;;;;:50;;7214:15;7180:50;:33;:50;:::i;4220:137::-;4281:4;4297:32;4307:10;4319:2;4323:5;4297:9;:32::i;:::-;-1:-1:-1;4346:4:3;4220:137;;;;:::o;3927:129::-;-1:-1:-1;;;;;4025:15:3;;;3999:7;4025:15;;;:8;:15;;;;;;;;:24;;;;;;;;;;;;;3927:129::o;1167:145::-;1225:7;;1252:6;;;;1244:15;;;;;;-1:-1:-1;;1281:5:3;;;1167:145::o;7547:256::-;-1:-1:-1;;;;;7634:16:3;;;;7626:25;;;;;;-1:-1:-1;;;;;7680:15:3;;:9;:15;;;;;;;;;;;:26;;7700:5;7680:26;:19;:26;:::i;:::-;-1:-1:-1;;;;;7662:15:3;;;:9;:15;;;;;;;;;;;:44;;;;7732:13;;;;;;;:24;;7750:5;7732:24;:17;:24;:::i;:::-;-1:-1:-1;;;;;7716:13:3;;;:9;:13;;;;;;;;;;;;:40;;;;7771:25;;;;;;;7716:13;;7771:25;;;;;;;;;;;;;7547:256;;;:::o;1383:145::-;1441:7;1472:5;;;1495:6;;;;1487:15;;;;;;1520:1;1383:145;-1:-1:-1;;;1383:145:3:o;8146:263::-;-1:-1:-1;;;;;8220:21:3;;;;8212:30;;;;;;8268:12;;:23;;8285:5;8268:23;:16;:23;:::i;:::-;8253:12;:38;-1:-1:-1;;;;;8322:18:3;;:9;:18;;;;;;;;;;;:29;;8345:5;8322:29;:22;:29;:::i;:::-;-1:-1:-1;;;;;8301:18:3;;:9;:18;;;;;;;;;;;:50;;;;8366:36;;;;;;;8301:18;;:9;;8366:36;;;;;;;;;;8146:263;;:::o", "source": "pragma solidity ^0.4.24;\n\n/**\n * @title SafeMath\n * @dev Math operations with safety checks that revert on error\n */\nlibrary SafeMath {\n /**\n * @dev Multiplies two numbers, reverts on overflow.\n */\n function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n if (a == 0) {\n return 0;\n }\n\n uint256 c = a * b;\n require(c / a == b);\n\n return c;\n }\n\n /**\n * @dev Integer division of two numbers truncating the quotient, reverts on division by zero.\n */\n function div(uint256 a, uint256 b) internal pure returns (uint256) {\n // Solidity only automatically asserts when dividing by 0\n require(b > 0);\n uint256 c = a / b;\n // assert(a == b * c + a % b); // There is no case in which this doesn't hold\n\n return c;\n }\n\n /**\n * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n */\n function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b <= a);\n uint256 c = a - b;\n\n return c;\n }\n\n /**\n * @dev Adds two numbers, reverts on overflow.\n */\n function add(uint256 a, uint256 b) internal pure returns (uint256) {\n uint256 c = a + b;\n require(c >= a);\n\n return c;\n }\n\n /**\n * @dev Divides two numbers and returns the remainder (unsigned integer modulo),\n * reverts when dividing by zero.\n */\n function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n require(b != 0);\n return a % b;\n }\n}\n\n/**\n * @title ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/20\n */\ninterface IERC20 {\n function totalSupply() external view returns (uint256);\n\n function balanceOf(address who) external view returns (uint256);\n\n function allowance(address owner, address spender) external view returns (uint256);\n\n function transfer(address to, uint256 value) external returns (bool);\n\n function approve(address spender, uint256 value) external returns (bool);\n\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n\n/**\n * @title Standard ERC20 token\n *\n * @dev Implementation of the basic standard token.\n * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md\n * Originally based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol\n */\ncontract ERC20 is IERC20 {\n using SafeMath for uint256;\n\n mapping (address => uint256) private _balances;\n\n mapping (address => mapping (address => uint256)) private _allowed;\n\n uint256 private _totalSupply;\n\n function mint(address to, uint256 val) \n public {\n _mint(to, val);\n }\n\n /**\n * @dev Total number of tokens in existence\n */\n function totalSupply() public view returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev Gets the balance of the specified address.\n * @param owner The address to query the balance of.\n * @return An uint256 representing the amount owned by the passed address.\n */\n function balanceOf(address owner) public view returns (uint256) {\n return _balances[owner];\n }\n\n /**\n * @dev Function to check the amount of tokens that an owner allowed to a spender.\n * @param owner address The address which owns the funds.\n * @param spender address The address which will spend the funds.\n * @return A uint256 specifying the amount of tokens still available for the spender.\n */\n function allowance(address owner, address spender) public view returns (uint256) {\n return _allowed[owner][spender];\n }\n\n /**\n * @dev Transfer token for a specified address\n * @param to The address to transfer to.\n * @param value The amount to be transferred.\n */\n function transfer(address to, uint256 value) public returns (bool) {\n _transfer(msg.sender, to, value);\n return true;\n }\n\n /**\n * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.\n * Beware that changing an allowance with this method brings the risk that someone may use both the old\n * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this\n * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n * @param spender The address which will spend the funds.\n * @param value The amount of tokens to be spent.\n */\n function approve(address spender, uint256 value) public returns (bool) {\n require(spender != address(0));\n\n _allowed[msg.sender][spender] = value;\n emit Approval(msg.sender, spender, value);\n return true;\n }\n\n /**\n * @dev Transfer tokens from one address to another\n * @param from address The address which you want to send tokens from\n * @param to address The address which you want to transfer to\n * @param value uint256 the amount of tokens to be transferred\n */\n function transferFrom(address from, address to, uint256 value) public returns (bool) {\n _allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Increase the amount of tokens that an owner allowed to a spender.\n * approve should be called when allowed_[_spender] == 0. To increment\n * allowed value is better to use this function to avoid 2 calls (and wait until\n * the first transaction is mined)\n * From MonolithDAO Token.sol\n * @param spender The address which will spend the funds.\n * @param addedValue The amount of tokens to increase the allowance by.\n */\n function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {\n require(spender != address(0));\n\n _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);\n emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);\n return true;\n }\n\n /**\n * @dev Decrease the amount of tokens that an owner allowed to a spender.\n * approve should be called when allowed_[_spender] == 0. To decrement\n * allowed value is better to use this function to avoid 2 calls (and wait until\n * the first transaction is mined)\n * From MonolithDAO Token.sol\n * @param spender The address which will spend the funds.\n * @param subtractedValue The amount of tokens to decrease the allowance by.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {\n require(spender != address(0));\n\n _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue);\n emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);\n return true;\n }\n\n /**\n * @dev Transfer token for a specified addresses\n * @param from The address to transfer from.\n * @param to The address to transfer to.\n * @param value The amount to be transferred.\n */\n function _transfer(address from, address to, uint256 value) internal {\n require(to != address(0));\n\n _balances[from] = _balances[from].sub(value);\n _balances[to] = _balances[to].add(value);\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Internal function that mints an amount of the token and assigns it to\n * an account. This encapsulates the modification of balances such that the\n * proper events are emitted.\n * @param account The account that will receive the created tokens.\n * @param value The amount that will be created.\n */\n function _mint(address account, uint256 value) internal {\n require(account != address(0));\n\n _totalSupply = _totalSupply.add(value);\n _balances[account] = _balances[account].add(value);\n emit Transfer(address(0), account, value);\n }\n\n /**\n * @dev Internal function that burns an amount of the token of a given\n * account.\n * @param account The account whose tokens will be burnt.\n * @param value The amount that will be burnt.\n */\n function _burn(address account, uint256 value) internal {\n require(account != address(0));\n\n _totalSupply = _totalSupply.sub(value);\n _balances[account] = _balances[account].sub(value);\n emit Transfer(account, address(0), value);\n }\n\n /**\n * @dev Internal function that burns an amount of the token of a given\n * account, deducting from the sender's allowance for said account. Uses the\n * internal burn function.\n * @param account The account whose tokens will be burnt.\n * @param value The amount that will be burnt.\n */\n function _burnFrom(address account, uint256 value) internal {\n // Should https://github.com/OpenZeppelin/zeppelin-solidity/issues/707 be accepted,\n // this function needs to emit an event with the updated approval.\n _allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);\n _burn(account, value);\n }\n}\n", "sourcePath": "/home/ed/working/realitio-contracts-newtest/truffle/contracts/ERC20Token.sol", "ast": { "absolutePath": "/home/ed/working/realitio-contracts-newtest/truffle/contracts/ERC20Token.sol", "exportedSymbols": { "ERC20": [ 1013 ], "IERC20": [ 596 ], "SafeMath": [ 529 ] }, "id": 1014, "nodeType": "SourceUnit", "nodes": [ { "id": 403, "literals": [ "solidity", "^", "0.4", ".24" ], "nodeType": "PragmaDirective", "src": "0:24:3" }, { "baseContracts": [], "contractDependencies": [], "contractKind": "library", "documentation": "@title SafeMath\n@dev Math operations with safety checks that revert on error", "fullyImplemented": true, "id": 529, "linearizedBaseContracts": [ 529 ], "name": "SafeMath", "nodeType": "ContractDefinition", "nodes": [ { "body": { "id": 435, "nodeType": "Block", "src": "278:354:3", "statements": [ { "condition": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 414, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 412, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 405, "src": "509:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 413, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "514:1:3", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "509:6:3", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } }, "falseBody": null, "id": 418, "nodeType": "IfStatement", "src": "505:45:3", "trueBody": { "id": 417, "nodeType": "Block", "src": "517:33:3", "statements": [ { "expression": { "argumentTypes": null, "hexValue": "30", "id": 415, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "538:1:3", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "functionReturnParameters": 411, "id": 416, "nodeType": "Return", "src": "531:8:3" } ] } }, { "assignments": [ 420 ], "declarations": [ { "constant": false, "id": 420, "name": "c", "nodeType": "VariableDeclaration", "scope": 436, "src": "560:9:3", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 419, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "560:7:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 424, "initialValue": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 423, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 421, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 405, "src": "572:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "*", "rightExpression": { "argumentTypes": null, "id": 422, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 407, "src": "576:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "572:5:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "560:17:3" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 430, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 428, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 426, "name": "c", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 420, "src": "595:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "/", "rightExpression": { "argumentTypes": null, "id": 427, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 405, "src": "599:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "595:5:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "==", "rightExpression": { "argumentTypes": null, "id": 429, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 407, "src": "604:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "595:10:3", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 425, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 5345, 5346 ], "referencedDeclaration": 5345, "src": "587:7:3", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 431, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "587:19:3", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 432, "nodeType": "ExpressionStatement", "src": "587:19:3" }, { "expression": { "argumentTypes": null, "id": 433, "name": "c", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 420, "src": "624:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "functionReturnParameters": 411, "id": 434, "nodeType": "Return", "src": "617:8:3" } ] }, "documentation": "@dev Multiplies two numbers, reverts on overflow.", "id": 436, "implemented": true, "isConstructor": false, "isDeclaredConst": true, "modifiers": [], "name": "mul", "nodeType": "FunctionDefinition", "parameters": { "id": 408, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 405, "name": "a", "nodeType": "VariableDeclaration", "scope": 436, "src": "224:9:3", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 404, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "224:7:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 407, "name": "b", "nodeType": "VariableDeclaration", "scope": 436, "src": "235:9:3", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 406, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "235:7:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "223:22:3" }, "payable": false, "returnParameters": { "id": 411, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 410, "name": "", "nodeType": "VariableDeclaration", "scope": 436, "src": "269:7:3", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 409, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "269:7:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "src": "268:9:3" }, "scope": 529, "src": "211:421:3", "stateMutability": "pure", "superFunction": null, "visibility": "internal" }, { "body": { "id": 459, "nodeType": "Block", "src": "817:229:3", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 448, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 446, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 440, "src": "901:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": ">", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 447, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "905:1:3", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "901:5:3", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 445, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 5345, 5346 ], "referencedDeclaration": 5345, "src": "893:7:3", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 449, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "893:14:3", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 450, "nodeType": "ExpressionStatement", "src": "893:14:3" }, { "assignments": [ 452 ], "declarations": [ { "constant": false, "id": 452, "name": "c", "nodeType": "VariableDeclaration", "scope": 460, "src": "917:9:3", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 451, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "917:7:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "id": 456, "initialValue": { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 455, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "id": 453, "name": "a", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 438, "src": "929:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "/", "rightExpression": { "argumentTypes": null, "id": 454, "name": "b", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 440, "src": "933:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "src": "929:5:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "VariableDeclarationStatement", "src": "917:17:3" }, { "expression": { "argumentTypes": null, "id": 457, "name": "c", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 452, "src": "1038:1:3", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "functionReturnParameters": 444, "id": 458, "nodeType": "Return", "src": "1031:8:3" } ] }, "documentation": "@dev Integer division of two numbers truncating the quotient, reverts on division by zero.", "id": 460, "implemented": true, "isConstructor": false, "isDeclaredConst": true, "modifiers": [], "name": "div", "nodeType": "FunctionDefinition", "parameters": { "id": 441, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 438, "name": "a", "nodeType": "VariableDeclaration",