@edgefund/core
Version:
EdgeFund Core contracts and tests
1,128 lines • 324 kB
JSON
{
"contractName": "CoinToss",
"abi": [
{
"constant": true,
"inputs": [],
"name": "bankroll",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "MAXIMUM_PASSED_BLOCKS",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "counter",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "MINIMUM_PASSED_BLOCKS",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "maximumBetSize",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"name": "coinTosses",
"outputs": [
{
"name": "user",
"type": "address"
},
{
"name": "block",
"type": "uint256"
},
{
"name": "isHeads",
"type": "bool"
},
{
"name": "amount",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"payable": true,
"stateMutability": "payable",
"type": "fallback"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"name": "user",
"type": "address"
},
{
"indexed": false,
"name": "isHeads",
"type": "bool"
},
{
"indexed": false,
"name": "amount",
"type": "uint256"
}
],
"name": "betPlaced",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"name": "isHeads",
"type": "bool"
}
],
"name": "CoinTossed",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"name": "bankRoll",
"type": "uint256"
}
],
"name": "bankRollFunded",
"type": "event"
},
{
"constant": false,
"inputs": [
{
"name": "betIsHeads",
"type": "bool"
}
],
"name": "placeBet",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "betId",
"type": "uint256"
},
{
"name": "resutBlockHash",
"type": "bytes32"
}
],
"name": "getResultForBet",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "pure",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "getMaxPassedBlocks",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "pure",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "betId",
"type": "uint256"
}
],
"name": "resolveBet",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "fund",
"outputs": [],
"payable": true,
"stateMutability": "payable",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "kill",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
],
"bytecode": "0x6080604052600080556000600155600060025534801561001e57600080fd5b5060048054600160a060020a031916331790556107e0806100406000396000f3006080604052600436106100b95763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663096a377881146101015780630c657eb0146101105780631e87e2881461013757806341c0e1b51461014c5780634c36c36e1461016157806361bc221a146101795780636426d2ff1461018e5780636a987336146101bd57806385dcb05c146101d25780638b3f8aef146101e7578063ad248913146101fc578063b60d428814610244575b600080543401908190556002900460025560005460408051918252517f38af9d7dab39de55be062f56ff186cb58a453fd0cf0f81122deac2222be19d4a9181900360200190a1005b61010e600435151561024c565b005b34801561011c57600080fd5b50610125610384565b60408051918252519081900360200190f35b34801561014357600080fd5b5061012561038a565b34801561015857600080fd5b5061010e61038f565b34801561016d57600080fd5b5061010e6004356103ff565b34801561018557600080fd5b50610125610690565b34801561019a57600080fd5b506101a9600435602435610696565b604080519115158252519081900360200190f35b3480156101c957600080fd5b50610125610726565b3480156101de57600080fd5b5061012561072b565b3480156101f357600080fd5b50610125610730565b34801561020857600080fd5b50610214600435610736565b60408051600160a060020a0390951685526020850193909352901515838301526060830152519081900360800190f35b61010e61076c565b6002543411156102a6576040805160e560020a62461bcd02815260206004820152600e60248201527f42657420697320746f6f20626967000000000000000000000000000000000000604482015290519081900360640190fd5b6040805160808082018352338083526005430160208085019182528615158587018181523460608089018281526001805460009081526003808952908d90209b518c5473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909116178c5597518b820155935160028b01805460ff1916911515919091179055519890950197909755548751908152918201939093528086019290925281019290925291517f706752a3648ca2ba13f1c7abdd321e0fde82cbba41cebacc1e5d7509b0546592929181900390910190a1506001805481019055565b60005481565b60ff81565b600454600160a060020a031633146103f1576040805160e560020a62461bcd02815260206004820152601c60248201527f596f7520646f206e6f74206f776e207468697320636f6e747261637400000000604482015290519081900360640190fd5b600454600160a060020a0316ff5b600081815260036020526040812080549091908190600160a060020a03163314610473576040805160e560020a62461bcd02815260206004820152601a60248201527f596f7520646964206e6f7420706c616365207468697320626574000000000000604482015290519081900360640190fd5b60018301544310156104cf576040805160e560020a62461bcd02815260206004820152601d60248201527f4e6f7420656e6f75676820626c6f636b73206861766520706173736564000000604482015290519081900360640190fd5b30600160a060020a0316636a9873366040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561052657600080fd5b505af115801561053a573d6000803e3d6000fd5b505050506040513d602081101561055057600080fd5b50516001840154014311156105af576040805160e560020a62461bcd02815260206004820152601d60248201527f4e6f7420656e6f75676820626c6f636b73206861766520706173736564000000604482015290519081900360640190fd5b6105be84846001015440610696565b600284015490925060ff161515821515141561060f57506003820154604051600290910290339082156108fc029083906000818181858888f1935050505015801561060d573d6000803e3d6000fd5b505b60408051858152831515602082015281517fce5cec4a2ff2aafde5f1d2b55d71e4b6d686505eeb629a44b1b795dea01ac248929181900390910190a150505060009081526003602081905260408220805473ffffffffffffffffffffffffffffffffffffffff191681556001810183905560028101805460ff191690550155565b60015481565b604080516020808201849052818301859052825180830384018152606090920192839052815160009384938493909282918401908083835b602083106106ed5780518252601f1990920191602091820191016106ce565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091206001161598975050505050505050565b60ff90565b600581565b60025481565b60036020819052600091825260409091208054600182015460028301549290930154600160a060020a03909116929160ff169084565b600080543401908190556002900460025560005460408051918252517f38af9d7dab39de55be062f56ff186cb58a453fd0cf0f81122deac2222be19d4a9181900360200190a15600a165627a7a7230582016884f449f8bee4e530f550e288d123385654cbb7673f5a260fd157967030aef0029",
"deployedBytecode": "0x6080604052600436106100b95763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663096a377881146101015780630c657eb0146101105780631e87e2881461013757806341c0e1b51461014c5780634c36c36e1461016157806361bc221a146101795780636426d2ff1461018e5780636a987336146101bd57806385dcb05c146101d25780638b3f8aef146101e7578063ad248913146101fc578063b60d428814610244575b600080543401908190556002900460025560005460408051918252517f38af9d7dab39de55be062f56ff186cb58a453fd0cf0f81122deac2222be19d4a9181900360200190a1005b61010e600435151561024c565b005b34801561011c57600080fd5b50610125610384565b60408051918252519081900360200190f35b34801561014357600080fd5b5061012561038a565b34801561015857600080fd5b5061010e61038f565b34801561016d57600080fd5b5061010e6004356103ff565b34801561018557600080fd5b50610125610690565b34801561019a57600080fd5b506101a9600435602435610696565b604080519115158252519081900360200190f35b3480156101c957600080fd5b50610125610726565b3480156101de57600080fd5b5061012561072b565b3480156101f357600080fd5b50610125610730565b34801561020857600080fd5b50610214600435610736565b60408051600160a060020a0390951685526020850193909352901515838301526060830152519081900360800190f35b61010e61076c565b6002543411156102a6576040805160e560020a62461bcd02815260206004820152600e60248201527f42657420697320746f6f20626967000000000000000000000000000000000000604482015290519081900360640190fd5b6040805160808082018352338083526005430160208085019182528615158587018181523460608089018281526001805460009081526003808952908d90209b518c5473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03909116178c5597518b820155935160028b01805460ff1916911515919091179055519890950197909755548751908152918201939093528086019290925281019290925291517f706752a3648ca2ba13f1c7abdd321e0fde82cbba41cebacc1e5d7509b0546592929181900390910190a1506001805481019055565b60005481565b60ff81565b600454600160a060020a031633146103f1576040805160e560020a62461bcd02815260206004820152601c60248201527f596f7520646f206e6f74206f776e207468697320636f6e747261637400000000604482015290519081900360640190fd5b600454600160a060020a0316ff5b600081815260036020526040812080549091908190600160a060020a03163314610473576040805160e560020a62461bcd02815260206004820152601a60248201527f596f7520646964206e6f7420706c616365207468697320626574000000000000604482015290519081900360640190fd5b60018301544310156104cf576040805160e560020a62461bcd02815260206004820152601d60248201527f4e6f7420656e6f75676820626c6f636b73206861766520706173736564000000604482015290519081900360640190fd5b30600160a060020a0316636a9873366040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561052657600080fd5b505af115801561053a573d6000803e3d6000fd5b505050506040513d602081101561055057600080fd5b50516001840154014311156105af576040805160e560020a62461bcd02815260206004820152601d60248201527f4e6f7420656e6f75676820626c6f636b73206861766520706173736564000000604482015290519081900360640190fd5b6105be84846001015440610696565b600284015490925060ff161515821515141561060f57506003820154604051600290910290339082156108fc029083906000818181858888f1935050505015801561060d573d6000803e3d6000fd5b505b60408051858152831515602082015281517fce5cec4a2ff2aafde5f1d2b55d71e4b6d686505eeb629a44b1b795dea01ac248929181900390910190a150505060009081526003602081905260408220805473ffffffffffffffffffffffffffffffffffffffff191681556001810183905560028101805460ff191690550155565b60015481565b604080516020808201849052818301859052825180830384018152606090920192839052815160009384938493909282918401908083835b602083106106ed5780518252601f1990920191602091820191016106ce565b5181516020939093036101000a600019018019909116921691909117905260405192018290039091206001161598975050505050505050565b60ff90565b600581565b60025481565b60036020819052600091825260409091208054600182015460028301549290930154600160a060020a03909116929160ff169084565b600080543401908190556002900460025560005460408051918252517f38af9d7dab39de55be062f56ff186cb58a453fd0cf0f81122deac2222be19d4a9181900360200190a15600a165627a7a7230582016884f449f8bee4e530f550e288d123385654cbb7673f5a260fd157967030aef0029",
"sourceMap": "304:2849:0:-;;;571:1;548:24;;600:1;578:23;;636:1;607:30;;868:60;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;903:5:0;:18;;-1:-1:-1;;;;;;903:18:0;911:10;903:18;;;304:2849;;;;;;",
"deployedSourceMap": "304:2849:0:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2903:8;:21;;2915:9;2903:21;;;;;2962:1;;2951:12;2934:14;:29;2994:8;;2979:24;;;;;;;;;;;;;;;;304:2849;934:383;;;;;;;;;;548:24;;8:9:-1;5:2;;;30:1;27;20:12;5:2;548:24:0;;;;;;;;;;;;;;;;;;;;442:48;;8:9:-1;5:2;;;30:1;27;20:12;5:2;442:48:0;;;;3016:135;;8:9:-1;5:2;;;30:1;27;20:12;5:2;3016:135:0;;;;2040:657;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;2040:657:0;;;;;578:23;;8:9:-1;5:2;;;30:1;27;20:12;5:2;578:23:0;;;;1323:260;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;1323:260:0;;;;;;;;;;;;;;;;;;;;;;;;;1928:106;;8:9:-1;5:2;;;30:1;27;20:12;5:2;1928:106:0;;;;496:46;;8:9:-1;5:2;;;30:1;27;20:12;5:2;496:46:0;;;;607:30;;8:9:-1;5:2;;;30:1;27;20:12;5:2;607:30:0;;;;644:39;;8:9:-1;5:2;;;30:1;27;20:12;5:2;-1:-1;644:39:0;;;;;;;;;-1:-1:-1;;;;;644:39:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2703:153;;;;934:383;1020:14;;1007:9;:27;;999:54;;;;;-1:-1:-1;;;;;999:54:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;1086:135;;;;;;;;;1104:10;1086:135;;;541:1;1128:12;:36;1086:135;;;;;;;;;;;;;;;;1202:9;1086:135;;;;;;;1075:7;;;-1:-1:-1;1064:19:0;;;:10;:19;;;;;;;:157;;;;-1:-1:-1;;1064:157:0;-1:-1:-1;;;;;1064:157:0;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1064:157:0;;;;;;;;;;;;;;;;;;;1247:7;1237:53;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;1301:7:0;:9;;;;;;934:383::o;548:24::-;;;;:::o;442:48::-;487:3;442:48;:::o;3016:135::-;3077:5;;-1:-1:-1;;;;;3077:5:0;3063:10;:19;3054:61;;;;;-1:-1:-1;;;;;3054:61:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;3138:5;;-1:-1:-1;;;;;3138:5:0;3125:19;2040:657;2093:17;2113;;;:10;:17;;;;;2163:9;;2113:17;;2093;;;-1:-1:-1;;;;;2163:9:0;2149:10;:23;2141:62;;;;;-1:-1:-1;;;;;2141:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;2237:10;;;;2221:12;:26;;2213:68;;;;;-1:-1:-1;;;;;2213:68:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;2329:4;-1:-1:-1;;;;;2329:23:0;;:25;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;2329:25:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2329:25:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;2329:25:0;2316:10;;;;:38;2299:12;:56;;2291:98;;;;;-1:-1:-1;;;;;2291:98:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;2415:45;2431:5;2448:4;:10;;;2438:21;2415:15;:45::i;:::-;2486:12;;;;2400:60;;-1:-1:-1;2486:12:0;;2475:23;;;;;;2471:144;;;-1:-1:-1;2528:11:0;;;;2577:27;;2542:1;2528:15;;;;2577:10;;:27;;;;;2528:15;;2577:27;;;;2528:15;2577:10;:27;;;;;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2577:27:0;2471:144;2630:26;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;2673:17:0;;;;:10;:17;;;;;;;2666:24;;-1:-1:-1;;2666:24:0;;;;;;;;;;;;;;-1:-1:-1;;2666:24:0;;;;;2040:657::o;578:23::-;;;;:::o;1323:260::-;1457:39;;;;;;;;;;;;;;;;;;26:21:-1;;;22:32;;6:49;;1457:39:0;;;;;;;;1447:50;;1405:4;;;;;;1457:39;;;;1447:50;;;;1457:39;1447:50;36:153:-1;66:2;58:11;;36:153;;176:10;;164:23;;-1:-1;;139:12;;;;98:2;89:12;;;;114;36:153;;;299:10;344;;263:2;259:12;;;;254:3;250:22;-1:-1;;246:30;311:9;;295:26;;;340:21;;377:20;;;;365:33;;1447:50:0;;;;;;;;;;1524:23;;1565:11;;;-1:-1:-1;;;;;;;;1323:260:0:o;1928:106::-;487:3;1928:106;:::o;496:46::-;541:1;496:46;:::o;607:30::-;;;;:::o;644:39::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;644:39:0;;;;;;;;;:::o;2703:153::-;2749:8;:21;;2761:9;2749:21;;;;;2808:1;;2797:12;2780:14;:29;2840:8;;2825:24;;;;;;;;;;;;;;;;2703:153::o",
"source": "pragma solidity ^0.4.24;\n\n/* This contract exists only to prove our testing methodology is fit for purpose\n * this will represent a very simple betting function (coin toss) which will be\n * tested with the helper functions that have been created to move the block\n * number, and timestamp forward.\n **/\ncontract CoinToss\n{\n struct Toss\n {\n address user;\n uint block;\n bool isHeads;\n uint amount;\n }\n\n uint public constant MAXIMUM_PASSED_BLOCKS = 255;\n uint public constant MINIMUM_PASSED_BLOCKS = 5;\n uint public bankroll = 0;\n uint public counter = 0;\n uint public maximumBetSize = 0;\n\n mapping(uint => Toss) public coinTosses;\n\n address owner;\n\n event betPlaced(uint id, address user, bool isHeads, uint amount);\n event CoinTossed(uint id, bool isHeads);\n event bankRollFunded(uint bankRoll);\n\n constructor() public\n {\n owner = msg.sender;\n }\n\n function placeBet (bool betIsHeads) public payable\n {\n require(msg.value <= maximumBetSize, \"Bet is too big\");\n\n coinTosses[counter] = Toss(\n msg.sender,\n block.number + MINIMUM_PASSED_BLOCKS,\n betIsHeads,\n msg.value\n );\n\n emit betPlaced(counter, msg.sender, betIsHeads, msg.value);\n\n counter++;\n }\n\n function getResultForBet(uint betId, bytes32 resutBlockHash) public pure returns (bool)\n {\n bytes32 hashedValue = keccak256(abi.encodePacked(resutBlockHash, betId));\n uint256 result = uint32(hashedValue) % 2;\n\n return result == 0;\n }\n\n /* This function exists only to get around a quirk with Solidity inheritance\n * It appears that overriding a constant is ignored when consumed in a sub-class\n * but overriding a function is not ignored. This behaviour should be investigated\n * further to ensure this is anot a security liability for this contract.\n */\n function getMaxPassedBlocks() public pure returns (uint)\n {\n return MAXIMUM_PASSED_BLOCKS;\n }\n\n function resolveBet(uint betId) public\n {\n Toss storage toss = coinTosses[betId];\n\n require(msg.sender == toss.user, \"You did not place this bet\");\n require(block.number >= toss.block, \"Not enough blocks have passed\");\n require(block.number <= (toss.block + this.getMaxPassedBlocks()), \"Not enough blocks have passed\");\n\n bool isHeads = getResultForBet(betId, blockhash(toss.block));\n\n if (isHeads == toss.isHeads) {\n uint payout = toss.amount * 2; // no house edge...\n msg.sender.transfer(payout);\n }\n\n emit CoinTossed(betId, isHeads);\n delete coinTosses[betId];\n }\n\n function fund () payable public\n {\n bankroll += msg.value;\n maximumBetSize = bankroll / 2;\n\n emit bankRollFunded(bankroll);\n }\n\n function () payable public\n {\n bankroll += msg.value;\n maximumBetSize = bankroll / 2;\n\n emit bankRollFunded(bankroll);\n }\n\n function kill () public\n {\n require (msg.sender == owner, \"You do not own this contract\");\n selfdestruct(owner);\n }\n}\n",
"sourcePath": "/Users/garethoates/Developer/Blockchain/EdgeFund/edgefund-core/contracts/CoinToss.sol",
"ast": {
"absolutePath": "/Users/garethoates/Developer/Blockchain/EdgeFund/edgefund-core/contracts/CoinToss.sol",
"exportedSymbols": {
"CoinToss": [
282
]
},
"id": 283,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1,
"literals": [
"solidity",
"^",
"0.4",
".24"
],
"nodeType": "PragmaDirective",
"src": "0:25:0"
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"id": 282,
"linearizedBaseContracts": [
282
],
"name": "CoinToss",
"nodeType": "ContractDefinition",
"nodes": [
{
"canonicalName": "CoinToss.Toss",
"id": 10,
"members": [
{
"constant": false,
"id": 3,
"name": "user",
"nodeType": "VariableDeclaration",
"scope": 10,
"src": "354:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 2,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "354:7:0",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 5,
"name": "block",
"nodeType": "VariableDeclaration",
"scope": 10,
"src": "376:10:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 4,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "376:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 7,
"name": "isHeads",
"nodeType": "VariableDeclaration",
"scope": 10,
"src": "396:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 6,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "396:4:0",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 9,
"name": "amount",
"nodeType": "VariableDeclaration",
"scope": 10,
"src": "418:11:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 8,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "418:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"name": "Toss",
"nodeType": "StructDefinition",
"scope": 282,
"src": "328:108:0",
"visibility": "public"
},
{
"constant": true,
"id": 13,
"name": "MAXIMUM_PASSED_BLOCKS",
"nodeType": "VariableDeclaration",
"scope": 282,
"src": "442:48:0",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 11,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "442:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "323535",
"id": 12,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "487:3:0",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_255_by_1",
"typeString": "int_const 255"
},
"value": "255"
},
"visibility": "public"
},
{
"constant": true,
"id": 16,
"name": "MINIMUM_PASSED_BLOCKS",
"nodeType": "VariableDeclaration",
"scope": 282,
"src": "496:46:0",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 14,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "496:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "35",
"id": 15,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "541:1:0",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_5_by_1",
"typeString": "int_const 5"
},
"value": "5"
},
"visibility": "public"
},
{
"constant": false,
"id": 19,
"name": "bankroll",
"nodeType": "VariableDeclaration",
"scope": 282,
"src": "548:24:0",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 17,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "548:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "30",
"id": 18,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "571:1:0",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"visibility": "public"
},
{
"constant": false,
"id": 22,
"name": "counter",
"nodeType": "VariableDeclaration",
"scope": 282,
"src": "578:23:0",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 20,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "578:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "30",
"id": 21,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "600:1:0",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"visibility": "public"
},
{
"constant": false,
"id": 25,
"name": "maximumBetSize",
"nodeType": "VariableDeclaration",
"scope": 282,
"src": "607:30:0",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 23,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "607:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"hexValue": "30",
"id": 24,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "636:1:0",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"visibility": "public"
},
{
"constant": false,
"id": 29,
"name": "coinTosses",
"nodeType": "VariableDeclaration",
"scope": 282,
"src": "644:39:0",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Toss_$10_storage_$",
"typeString": "mapping(uint256 => struct CoinToss.Toss)"
},
"typeName": {
"id": 28,
"keyType": {
"id": 26,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "652:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Mapping",
"src": "644:21:0",
"typeDescriptions": {
"typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_Toss_$10_storage_$",
"typeString": "mapping(uint256 => struct CoinToss.Toss)"
},
"valueType": {
"contractScope": null,
"id": 27,
"name": "Toss",
"nodeType": "UserDefinedTypeName",
"referencedDeclaration": 10,
"src": "660:4:0",
"typeDescriptions": {
"typeIdentifier": "t_struct$_Toss_$10_storage_ptr",
"typeString": "struct CoinToss.Toss"
}
}
},
"value": null,
"visibility": "public"
},
{
"constant": false,
"id": 31,
"name": "owner",
"nodeType": "VariableDeclaration",
"scope": 282,
"src": "690:13:0",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 30,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "690:7:0",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"anonymous": false,
"documentation": null,
"id": 41,
"name": "betPlaced",
"nodeType": "EventDefinition",
"parameters": {
"id": 40,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 33,
"indexed": false,
"name": "id",
"nodeType": "VariableDeclaration",
"scope": 41,
"src": "726:7:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 32,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "726:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 35,
"indexed": false,
"name": "user",
"nodeType": "VariableDeclaration",
"scope": 41,
"src": "735:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
},
"typeName": {
"id": 34,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "735:7:0",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 37,
"indexed": false,
"name": "isHeads",
"nodeType": "VariableDeclaration",
"scope": 41,
"src": "749:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 36,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "749:4:0",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 39,
"indexed": false,
"name": "amount",
"nodeType": "VariableDeclaration",
"scope": 41,
"src": "763:11:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 38,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "763:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "725:50:0"
},
"src": "710:66:0"
},
{
"anonymous": false,
"documentation": null,
"id": 47,
"name": "CoinTossed",
"nodeType": "EventDefinition",
"parameters": {
"id": 46,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 43,
"indexed": false,
"name": "id",
"nodeType": "VariableDeclaration",
"scope": 47,
"src": "798:7:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 42,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "798:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
},
{
"constant": false,
"id": 45,
"indexed": false,
"name": "isHeads",
"nodeType": "VariableDeclaration",
"scope": 47,
"src": "807:12:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
},
"typeName": {
"id": 44,
"name": "bool",
"nodeType": "ElementaryTypeName",
"src": "807:4:0",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "797:23:0"
},
"src": "781:40:0"
},
{
"anonymous": false,
"documentation": null,
"id": 51,
"name": "bankRollFunded",
"nodeType": "EventDefinition",
"parameters": {
"id": 50,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 49,
"indexed": false,
"name": "bankRoll",
"nodeType": "VariableDeclaration",
"scope": 51,
"src": "847:13:0",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 48,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "847:4:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "846:15:0"
},
"src": "826:36:0"
},
{
"body": {
"id": 59,
"nodeType": "Block",
"src": "893:35:0",
"statements": [
{
"expression": {
"argumentTypes": null,
"id": 57,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 54,
"name": "owner",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 31,
"src": "903:5:0",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 55,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 689,
"src": "911:3:0",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 56,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "sender",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "911:10:0",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"src": "903:18:0",
"typeDescriptions": {
"typeIdentifier": "t_address",
"typeString": "address"
}
},
"id": 58,
"nodeType": "ExpressionStatement",
"src": "903:18:0"
}
]
},
"documentation": null,
"id": 60,
"implemented": true,
"isConstructor": true,
"isDeclaredConst": false,
"modifiers": [],
"name": "",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 52,
"nodeType": "ParameterList",
"parameters": [],
"src": "879:2:0"
},
"payable": false,
"returnParameters": {
"id": 53,
"nodeType": "ParameterList",
"parameters": [],
"src": "893:0:0"
},
"scope": 282,
"src": "868:60:0",
"stateMutability": "nonpayable",
"superFunction": null,
"visibility": "public"
},
{
"body": {
"id": 101,
"nodeType": "Block",
"src": "989:328:0",
"statements": [
{
"expression": {
"argumentTypes": null,
"arguments": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 69,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 66,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 689,
"src": "1007:3:0",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 67,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"memberName": "value",
"nodeType": "MemberAccess",
"referencedDeclaration": null,
"src": "1007:9:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<=",
"rightExpression": {
"argumentTypes": null,
"id": 68,
"name": "maximumBetSize",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 25,
"src": "1020:14:0",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "1007:27:0",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
{
"argumentTypes": null,
"hexValue": "42657420697320746f6f20626967",
"id": 70,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "string",
"lValueRequested": false,
"nodeType": "Literal",
"src": "1036:16:0",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_stringliteral_dc962989068353d3566c266af447431e205a91ff877ef02df25e89f93722e5ed",
"typeString": "literal_string \"Bet is too big\""
},
"value": "Bet is too big"
}
],
"expression": {
"argumentTypes": [
{
"typeIdentifier": "t_bool",
"typeString": "bool"
},
{
"typeIdentifier": "t_stringliteral_dc962989068353d3566c266af447431e205a91ff877ef02df25e89f93722e5ed",
"typeString": "literal_string \"Bet is too bi