UNPKG

arc_dx

Version:

A platform for building DAOs

953 lines (952 loc) 567 kB
{ "contractName": "MirrorContractICO", "abi": [ { "constant": true, "inputs": [], "name": "simpleICO", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "organization", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "renounceOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "destroy", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "_newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "name": "_recipient", "type": "address" } ], "name": "destroyAndSend", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "name": "_organization", "type": "address" }, { "name": "_simpleICO", "type": "address" } ], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "payable": true, "stateMutability": "payable", "type": "fallback" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "previousOwner", "type": "address" } ], "name": "OwnershipRenounced", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "previousOwner", "type": "address" }, { "indexed": true, "name": "newOwner", "type": "address" } ], "name": "OwnershipTransferred", "type": "event" } ], "bytecode": "0x608060405234801561001057600080fd5b5060405160408061042183398101604052805160209091015160008054600160a060020a0319908116331790915560018054600160a060020a03948516908316179055600280549390921692169190911790556103af806100726000396000f3006080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631ebbede2811461013b57806323bd4d7a1461016c578063715018a61461018157806383197ef0146101965780638da5cb5b146101ab578063f2fde38b146101c0578063f5074f41146101e1575b34151561008e57600080fd5b600254600154604080517f21bea7cc000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152336024820152905191909216916321bea7cc91349160448082019260209290919082900301818588803b15801561010157600080fd5b505af1158015610115573d6000803e3d6000fd5b50505050506040513d602081101561012c57600080fd5b5051151561013957600080fd5b005b34801561014757600080fd5b50610150610202565b60408051600160a060020a039092168252519081900360200190f35b34801561017857600080fd5b50610150610211565b34801561018d57600080fd5b50610139610220565b3480156101a257600080fd5b5061013961028c565b3480156101b757600080fd5b506101506102b1565b3480156101cc57600080fd5b50610139600160a060020a03600435166102c0565b3480156101ed57600080fd5b50610139600160a060020a03600435166102e3565b600254600160a060020a031681565b600154600160a060020a031681565b600054600160a060020a0316331461023757600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031633146102a357600080fd5b600054600160a060020a0316ff5b600054600160a060020a031681565b600054600160a060020a031633146102d757600080fd5b6102e081610306565b50565b600054600160a060020a031633146102fa57600080fd5b80600160a060020a0316ff5b600160a060020a038116151561031b57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820237703e0ba7ee17d4b61790f56099c4f1c7cd01ec89abd6fefd29cf227c411660029", "deployedBytecode": "0x6080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631ebbede2811461013b57806323bd4d7a1461016c578063715018a61461018157806383197ef0146101965780638da5cb5b146101ab578063f2fde38b146101c0578063f5074f41146101e1575b34151561008e57600080fd5b600254600154604080517f21bea7cc000000000000000000000000000000000000000000000000000000008152600160a060020a039283166004820152336024820152905191909216916321bea7cc91349160448082019260209290919082900301818588803b15801561010157600080fd5b505af1158015610115573d6000803e3d6000fd5b50505050506040513d602081101561012c57600080fd5b5051151561013957600080fd5b005b34801561014757600080fd5b50610150610202565b60408051600160a060020a039092168252519081900360200190f35b34801561017857600080fd5b50610150610211565b34801561018d57600080fd5b50610139610220565b3480156101a257600080fd5b5061013961028c565b3480156101b757600080fd5b506101506102b1565b3480156101cc57600080fd5b50610139600160a060020a03600435166102c0565b3480156101ed57600080fd5b50610139600160a060020a03600435166102e3565b600254600160a060020a031681565b600154600160a060020a031681565b600054600160a060020a0316331461023757600080fd5b60008054604051600160a060020a03909116917ff8df31144d9c2f0f6b59d69b8b98abd5459d07f2742c4df920b25aae33c6482091a26000805473ffffffffffffffffffffffffffffffffffffffff19169055565b600054600160a060020a031633146102a357600080fd5b600054600160a060020a0316ff5b600054600160a060020a031681565b600054600160a060020a031633146102d757600080fd5b6102e081610306565b50565b600054600160a060020a031633146102fa57600080fd5b80600160a060020a0316ff5b600160a060020a038116151561031b57600080fd5b60008054604051600160a060020a03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a36000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03929092169190911790555600a165627a7a72305820237703e0ba7ee17d4b61790f56099c4f1c7cd01ec89abd6fefd29cf227c411660029", "sourceMap": "369:893:32:-;;;726:140;8:9:-1;5:2;;;30:1;27;20:12;5:2;726:140:32;;;;;;;;;;;;;;;;;;;567:5:55;:18;;-1:-1:-1;;;;;;567:18:55;;;575:10;567:18;;;;;799:28:32;;-1:-1:-1;;;;;799:28:32;;;;;;;;;837:9;:22;;;;;;;;;;;;;;369:893;;;;;;", "deployedSourceMap": "369:893:32:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1110:9;:14;;1102:23;;;;;;1188:9;;;1222:12;1188:59;;;;;;-1:-1:-1;;;;;1222:12:32;;;1188:59;;;;1236:10;1188:59;;;;;;:9;;;;;:16;;1211:9;;1188:59;;;;;;;;;;;;;;;1211:9;1188;:59;;;5:2:-1;;;;30:1;27;20:12;5:2;1188:59:32;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;1188:59:32;;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1188:59:32;:64;;1180:73;;;;;;369:893;491:26;;8:9:-1;5:2;;;30:1;27;20:12;5:2;491:26:32;;;;;;;;-1:-1:-1;;;;;491:26:32;;;;;;;;;;;;;;418;;8:9:-1;5:2;;;30:1;27;20:12;5:2;418:26:32;;;;1001:111:55;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1001:111:55;;;;329:66:53;;8:9:-1;5:2;;;30:1;27;20:12;5:2;329:66:53;;;;238:20:55;;8:9:-1;5:2;;;30:1;27;20:12;5:2;238:20:55;;;;1274:103;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1274:103:55;;;-1:-1:-1;;;;;1274:103:55;;;399:96:53;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;399:96:53;;;-1:-1:-1;;;;;399:96:53;;;491:26:32;;;-1:-1:-1;;;;;491:26:32;;:::o;418:::-;;;-1:-1:-1;;;;;418:26:32;;:::o;1001:111:55:-;719:5;;-1:-1:-1;;;;;719:5:55;705:10;:19;697:28;;;;;;1077:5;;;1058:25;;-1:-1:-1;;;;;1077:5:55;;;;1058:25;;;1105:1;1089:18;;-1:-1:-1;;1089:18:55;;;1001:111::o;329:66:53:-;719:5:55;;-1:-1:-1;;;;;719:5:55;705:10;:19;697:28;;;;;;384:5:53;;-1:-1:-1;;;;;384:5:53;371:19;238:20:55;;;-1:-1:-1;;;;;238:20:55;;:::o;1274:103::-;719:5;;-1:-1:-1;;;;;719:5:55;705:10;:19;697:28;;;;;;1343:29;1362:9;1343:18;:29::i;:::-;1274:103;:::o;399:96:53:-;719:5:55;;-1:-1:-1;;;;;719:5:55;705:10;:19;697:28;;;;;;-1:-1:-1;;;;;466:24:53;;;1512:171:55;-1:-1:-1;;;;;1582:23:55;;;;1574:32;;;;;;1638:5;;;1617:38;;-1:-1:-1;;;;;1617:38:55;;;;1638:5;;;1617:38;;;1661:5;:17;;-1:-1:-1;;1661:17:55;-1:-1:-1;;;;;1661:17:55;;;;;;;;;;1512:171::o", "source": "pragma solidity ^0.4.25;\n\nimport \"./UniversalScheme.sol\";\nimport \"openzeppelin-solidity/contracts/ownership/Ownable.sol\";\nimport \"openzeppelin-solidity/contracts/math/SafeMath.sol\";\nimport \"openzeppelin-solidity/contracts/lifecycle/Destructible.sol\";\n\n\n/**\n * @title An avatar contract for ICO.\n * @dev Allow people to donate by simply sending ether to an address.\n */\ncontract MirrorContractICO is Destructible {\n Avatar public organization; // The organization address (the avatar)\n SimpleICO public simpleICO; // The ICO contract address\n /**\n * @dev Constructor, setting the organization and ICO scheme.\n * @param _organization The organization's avatar.\n * @param _simpleICO The ICO Scheme.\n */\n constructor(Avatar _organization, SimpleICO _simpleICO) public {\n organization = _organization;\n simpleICO = _simpleICO;\n }\n\n /**\n * @dev Fallback function, when ether is sent it will donate to the ICO.\n * The ether will be returned if the donation is failed.\n */\n function () public payable {\n // Not to waste gas, if no value.\n require(msg.value != 0);\n\n // Return ether if couldn't donate.\n require(simpleICO.donate.value(msg.value)(organization, msg.sender) != 0);\n }\n}\n\n\n/**\n * @title SimpleICO scheme.\n * @dev A universal scheme to allow organizations to open a simple ICO and get donations.\n */\ncontract SimpleICO is UniversalScheme {\n using SafeMath for uint;\n\n // Struct holding the data for each organization\n struct Organization {\n bytes32 paramsHash; // Save the parameters approved by the org to open the ICO, so reuse of ICO will not change.\n address avatarContractICO; // Avatar is a contract for users that want to send ether without calling a function.\n uint totalEthRaised;\n bool isHalted; // The admin of the ICO can halt the ICO at any time, and also resume it.\n }\n\n // A mapping from hashes to parameters (use to store a particular configuration on the controller)\n struct Parameters {\n uint cap; // Cap in Eth\n uint price; // Price represents Tokens per 1 Eth\n uint startBlock;\n uint endBlock;\n address beneficiary; // all funds received will be transferred to this address.\n address admin; // The admin can halt or resume ICO.\n }\n\n // A mapping from the organization (Avatar) address to the saved data of the organization:\n mapping(address=>Organization) public organizationsICOInfo;\n\n mapping(bytes32=>Parameters) public parameters;\n\n event DonationReceived(address indexed organization, address indexed _beneficiary, uint _incomingEther, uint indexed _tokensAmount);\n\n /**\n * @dev Hash the parameters, save them if necessary, and return the hash value\n * @param _cap the ico cap\n * @param _price represents Tokens per 1 Eth\n * @param _startBlock ico start block\n * @param _endBlock ico end\n * @param _beneficiary the ico ether beneficiary\n * @param _admin the address of the ico admin which can hold and resume the ICO.\n * @return bytes32 -the params hash\n */\n function setParameters(\n uint _cap,\n uint _price,\n uint _startBlock,\n uint _endBlock,\n address _beneficiary,\n address _admin\n )\n public\n returns(bytes32)\n {\n require(_cap != 0);\n bytes32 paramsHash = getParametersHash(\n _cap,\n _price,\n _startBlock,\n _endBlock,\n _beneficiary,\n _admin\n );\n if (parameters[paramsHash].cap == 0) {\n parameters[paramsHash] = Parameters({\n cap: _cap,\n price: _price,\n startBlock: _startBlock,\n endBlock:_endBlock,\n beneficiary:_beneficiary,\n admin:_admin\n });\n }\n return paramsHash;\n }\n\n /**\n * @dev Hash the parameters and return the hash value\n * @param _cap the ico cap\n * @param _price represents Tokens per 1 Eth\n * @param _startBlock ico start block\n * @param _endBlock ico end\n * @param _beneficiary the ico ether beneficiary\n * @param _admin the address of the ico admin which can hold and resume the ICO.\n * @return bytes32 -the params hash\n */\n function getParametersHash(\n uint _cap,\n uint _price,\n uint _startBlock,\n uint _endBlock,\n address _beneficiary,\n address _admin\n )\n public\n pure\n returns(bytes32)\n {\n return (keccak256(\n abi.encodePacked(\n _cap,\n _price,\n _startBlock,\n _endBlock,\n _beneficiary,\n _admin\n )));\n }\n\n /**\n * @dev start an ICO\n * @param _avatar The Avatar's of the organization\n */\n function start(address _avatar) public {\n require(!isActive(_avatar));\n Organization memory org;\n org.paramsHash = getParametersFromController(Avatar(_avatar));\n require(parameters[org.paramsHash].cap != 0);\n org.avatarContractICO = new MirrorContractICO(Avatar(_avatar), this);\n organizationsICOInfo[_avatar] = org;\n }\n\n /**\n * @dev Allowing admin to halt an ICO.\n * @param _avatar The Avatar's of the organization\n */\n function haltICO(address _avatar) public {\n require(msg.sender == parameters[organizationsICOInfo[_avatar].paramsHash].admin);\n organizationsICOInfo[_avatar].isHalted = true;\n }\n\n /**\n * @dev Allowing admin to reopen an ICO.\n * @param _avatar The Avatar's of the organization\n */\n function resumeICO(address _avatar) public {\n require(msg.sender == parameters[organizationsICOInfo[_avatar].paramsHash].admin);\n organizationsICOInfo[_avatar].isHalted = false;\n }\n\n /**\n * @dev Check is an ICO is active (halted is still considered active). Active ICO:\n * 1. The organization is registered.\n * 2. The ICO didn't reach it's cap yet.\n * 3. The current block isn't bigger than the \"endBlock\" & Smaller then the \"startBlock\"\n * @param _avatar The Avatar's of the organization\n * @return bool which represents a successful of the function\n */\n function isActive(address _avatar) public view returns(bool) {\n Organization memory org = organizationsICOInfo[_avatar];\n Parameters memory params = parameters[org.paramsHash];\n\n if (org.totalEthRaised >= params.cap) {\n return false;\n }\n if (block.number >= params.endBlock) {\n return false;\n }\n if (block.number <= params.startBlock) {\n return false;\n }\n return true;\n }\n\n /**\n * @dev Donating ethers to get tokens.\n * If the donation is higher than the remaining ethers in the \"cap\",\n * The donator will get the change in ethers.\n * @param _avatar The Avatar's of the organization.\n * @param _beneficiary The donator's address - which will receive the ICO's tokens.\n * @return uint number of tokens minted for the donation.\n */\n function donate(Avatar _avatar, address _beneficiary) public payable returns(uint) {\n Organization memory org = organizationsICOInfo[_avatar];\n Parameters memory params = parameters[org.paramsHash];\n\n // Check ICO is active:\n require(isActive(_avatar));\n\n // Check ICO is not halted:\n require(!org.isHalted);\n\n\n uint incomingEther;\n uint change;\n\n // Compute how much tokens to buy:\n if ( msg.value > (params.cap).sub(org.totalEthRaised) ) {\n incomingEther = (params.cap).sub(org.totalEthRaised);\n change = (msg.value).sub(incomingEther);\n } else {\n incomingEther = msg.value;\n }\n\n uint tokens = incomingEther.mul(params.price);\n // Update total raised, call event and return amount of tokens bought:\n organizationsICOInfo[_avatar].totalEthRaised += incomingEther;\n // Send ether to the defined address, mint, and send change to beneficiary:\n params.beneficiary.transfer(incomingEther);\n\n require(ControllerInterface(_avatar.owner()).mintTokens(tokens, _beneficiary,address(_avatar)));\n if (change != 0) {\n _beneficiary.transfer(change);\n }\n emit DonationReceived(_avatar, _beneficiary, incomingEther, tokens);\n return tokens;\n }\n}\n", "sourcePath": "/Users/oren/daostack/daostack2/daostack/contracts/universalSchemes/SimpleICO.sol", "ast": { "absolutePath": "/Users/oren/daostack/daostack2/daostack/contracts/universalSchemes/SimpleICO.sol", "exportedSymbols": { "MirrorContractICO": [ 10195 ], "SimpleICO": [ 10622 ] }, "id": 10623, "nodeType": "SourceUnit", "nodes": [ { "id": 10142, "literals": [ "solidity", "^", "0.4", ".25" ], "nodeType": "PragmaDirective", "src": "0:24:32" }, { "absolutePath": "/Users/oren/daostack/daostack2/daostack/contracts/universalSchemes/UniversalScheme.sol", "file": "./UniversalScheme.sol", "id": 10143, "nodeType": "ImportDirective", "scope": 10623, "sourceUnit": 10669, "src": "26:31:32", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/ownership/Ownable.sol", "file": "openzeppelin-solidity/contracts/ownership/Ownable.sol", "id": 10144, "nodeType": "ImportDirective", "scope": 10623, "sourceUnit": 20878, "src": "58:63:32", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/math/SafeMath.sol", "file": "openzeppelin-solidity/contracts/math/SafeMath.sol", "id": 10145, "nodeType": "ImportDirective", "scope": 10623, "sourceUnit": 20792, "src": "122:59:32", "symbolAliases": [], "unitAlias": "" }, { "absolutePath": "openzeppelin-solidity/contracts/lifecycle/Destructible.sol", "file": "openzeppelin-solidity/contracts/lifecycle/Destructible.sol", "id": 10146, "nodeType": "ImportDirective", "scope": 10623, "sourceUnit": 20698, "src": "182:68:32", "symbolAliases": [], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 10147, "name": "Destructible", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 20697, "src": "399:12:32", "typeDescriptions": { "typeIdentifier": "t_contract$_Destructible_$20697", "typeString": "contract Destructible" } }, "id": 10148, "nodeType": "InheritanceSpecifier", "src": "399:12:32" } ], "contractDependencies": [ 20697, 20877 ], "contractKind": "contract", "documentation": "@title An avatar contract for ICO.\n@dev Allow people to donate by simply sending ether to an address.", "fullyImplemented": true, "id": 10195, "linearizedBaseContracts": [ 10195, 20697, 20877 ], "name": "MirrorContractICO", "nodeType": "ContractDefinition", "nodes": [ { "constant": false, "id": 10150, "name": "organization", "nodeType": "VariableDeclaration", "scope": 10195, "src": "418:26:32", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" }, "typeName": { "contractScope": null, "id": 10149, "name": "Avatar", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 333, "src": "418:6:32", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" } }, "value": null, "visibility": "public" }, { "constant": false, "id": 10152, "name": "simpleICO", "nodeType": "VariableDeclaration", "scope": 10195, "src": "491:26:32", "stateVariable": true, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" }, "typeName": { "contractScope": null, "id": 10151, "name": "SimpleICO", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 10622, "src": "491:9:32", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" } }, "value": null, "visibility": "public" }, { "body": { "id": 10167, "nodeType": "Block", "src": "789:77:32", "statements": [ { "expression": { "argumentTypes": null, "id": 10161, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 10159, "name": "organization", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10150, "src": "799:12:32", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "id": 10160, "name": "_organization", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10154, "src": "814:13:32", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" } }, "src": "799:28:32", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" } }, "id": 10162, "nodeType": "ExpressionStatement", "src": "799:28:32" }, { "expression": { "argumentTypes": null, "id": 10165, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftHandSide": { "argumentTypes": null, "id": 10163, "name": "simpleICO", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10152, "src": "837:9:32", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" } }, "nodeType": "Assignment", "operator": "=", "rightHandSide": { "argumentTypes": null, "id": 10164, "name": "_simpleICO", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10156, "src": "849:10:32", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" } }, "src": "837:22:32", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" } }, "id": 10166, "nodeType": "ExpressionStatement", "src": "837:22:32" } ] }, "documentation": "@dev Constructor, setting the organization and ICO scheme.\n@param _organization The organization's avatar.\n@param _simpleICO The ICO Scheme.", "id": 10168, "implemented": true, "isConstructor": true, "isDeclaredConst": false, "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { "id": 10157, "nodeType": "ParameterList", "parameters": [ { "constant": false, "id": 10154, "name": "_organization", "nodeType": "VariableDeclaration", "scope": 10168, "src": "738:20:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" }, "typeName": { "contractScope": null, "id": 10153, "name": "Avatar", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 333, "src": "738:6:32", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 10156, "name": "_simpleICO", "nodeType": "VariableDeclaration", "scope": 10168, "src": "760:20:32", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" }, "typeName": { "contractScope": null, "id": 10155, "name": "SimpleICO", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 10622, "src": "760:9:32", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" } }, "value": null, "visibility": "internal" } ], "src": "737:44:32" }, "payable": false, "returnParameters": { "id": 10158, "nodeType": "ParameterList", "parameters": [], "src": "789:0:32" }, "scope": 10195, "src": "726:140:32", "stateMutability": "nonpayable", "superFunction": null, "visibility": "public" }, { "body": { "id": 10193, "nodeType": "Block", "src": "1050:210:32", "statements": [ { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 10175, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 10172, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 21549, "src": "1110:3:32", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 10173, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1110:9:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 10174, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1123:1:32", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1110:14:32", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 10171, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 21552, 21553 ], "referencedDeclaration": 21552, "src": "1102:7:32", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 10176, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1102:23:32", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 10177, "nodeType": "ExpressionStatement", "src": "1102:23:32" }, { "expression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "commonType": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "id": 10190, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "leftExpression": { "argumentTypes": null, "arguments": [ { "argumentTypes": null, "id": 10185, "name": "organization", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10150, "src": "1222:12:32", "typeDescriptions": { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" } }, { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 10186, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 21549, "src": "1236:3:32", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 10187, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "sender", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1236:10:32", "typeDescriptions": { "typeIdentifier": "t_address", "typeString": "address" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_contract$_Avatar_$333", "typeString": "contract Avatar" }, { "typeIdentifier": "t_address", "typeString": "address" } ], "arguments": [ { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 10182, "name": "msg", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 21549, "src": "1211:3:32", "typeDescriptions": { "typeIdentifier": "t_magic_message", "typeString": "msg" } }, "id": 10183, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1211:9:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_uint256", "typeString": "uint256" } ], "expression": { "argumentTypes": null, "expression": { "argumentTypes": null, "id": 10179, "name": "simpleICO", "nodeType": "Identifier", "overloadedDeclarations": [], "referencedDeclaration": 10152, "src": "1188:9:32", "typeDescriptions": { "typeIdentifier": "t_contract$_SimpleICO_$10622", "typeString": "contract SimpleICO" } }, "id": 10180, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "donate", "nodeType": "MemberAccess", "referencedDeclaration": 10621, "src": "1188:16:32", "typeDescriptions": { "typeIdentifier": "t_function_external_payable$_t_contract$_Avatar_$333_$_t_address_$returns$_t_uint256_$", "typeString": "function (contract Avatar,address) payable external returns (uint256)" } }, "id": 10181, "isConstant": false, "isLValue": false, "isPure": false, "lValueRequested": false, "memberName": "value", "nodeType": "MemberAccess", "referencedDeclaration": null, "src": "1188:22:32", "typeDescriptions": { "typeIdentifier": "t_function_setvalue_nonpayable$_t_uint256_$returns$_t_function_external_payable$_t_contract$_Avatar_$333_$_t_address_$returns$_t_uint256_$value_$", "typeString": "function (uint256) returns (function (contract Avatar,address) payable external returns (uint256))" } }, "id": 10184, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1188:33:32", "typeDescriptions": { "typeIdentifier": "t_function_external_payable$_t_contract$_Avatar_$333_$_t_address_$returns$_t_uint256_$value", "typeString": "function (contract Avatar,address) payable external returns (uint256)" } }, "id": 10188, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1188:59:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "nodeType": "BinaryOperation", "operator": "!=", "rightExpression": { "argumentTypes": null, "hexValue": "30", "id": 10189, "isConstant": false, "isLValue": false, "isPure": true, "kind": "number", "lValueRequested": false, "nodeType": "Literal", "src": "1251:1:32", "subdenomination": null, "typeDescriptions": { "typeIdentifier": "t_rational_0_by_1", "typeString": "int_const 0" }, "value": "0" }, "src": "1188:64:32", "typeDescriptions": { "typeIdentifier": "t_bool", "typeString": "bool" } } ], "expression": { "argumentTypes": [ { "typeIdentifier": "t_bool", "typeString": "bool" } ], "id": 10178, "name": "require", "nodeType": "Identifier", "overloadedDeclarations": [ 21552, 21553 ], "referencedDeclaration": 21552, "src": "1180:7:32", "typeDescriptions": { "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", "typeString": "function (bool) pure" } }, "id": 10191, "isConstant": false, "isLValue": false, "isPure": false, "kind": "functionCall", "lValueRequested": false, "names": [], "nodeType": "FunctionCall", "src": "1180:73:32", "typeDescriptions": { "typeIdentifier": "t_tuple$__$", "typeString": "tuple()" } }, "id": 10192, "nodeType": "ExpressionStatement", "src": "1180:73:32" } ] }, "documentation": "@dev Fallback function, when ether is sent it will donate to the ICO.\nThe ether will be returned if the donation is failed.", "id": 10194, "implemented": true, "isConstructor": false, "isDeclaredConst": false, "modifiers": [], "name": "", "nodeType": "FunctionDefinition", "parameters": { "id": 10169, "nodeType": "ParameterList", "parameters": [], "src": "1032:2:32" }, "payable": true, "returnParameters": { "id": 10170, "nodeType": "ParameterList", "parameters": [], "src": "1050:0:32" }, "scope": 10195, "src": "1023:237:32", "stateMutability": "payable", "superFunction": null, "visibility": "public" } ], "scope": 10623, "src": "369:893:32" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 10196, "name": "UniversalScheme", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 10668, "src": "1413:15:32", "typeDescriptions": { "typeIdentifier": "t_contract$_UniversalScheme_$10668", "typeString": "contract UniversalScheme" } }, "id": 10197, "nodeType": "InheritanceSpecifier", "src": "1413:15:32" } ], "contractDependencies": [ 10195, 10668, 10687, 20877 ], "contractKind": "contract", "documentation": "@title SimpleICO scheme.\n@dev A universal scheme to allow organizations to open a simple ICO and get donations.", "fullyImplemented": true, "id": 10622, "linearizedBaseContracts": [ 10622, 10668, 10687, 20877 ], "name": "SimpleICO", "nodeType": "ContractDefinition", "nodes": [ { "id": 10200, "libraryName": { "contractScope": null, "id": 10198, "name": "SafeMath", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 20791, "src": "1441:8:32", "typeDescriptions": { "typeIdentifier": "t_contract$_SafeMath_$20791", "typeString": "library SafeMath" } }, "nodeType": "UsingForDirective", "src": "1435:24:32", "typeName": { "id": 10199, "name": "uint", "nodeType": "ElementaryTypeName", "src": "1454:4:32", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256"