Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x81dCc6246Fe261035FFeE91CD975FAf3D3f3375F
Balance 0 ETH
Nonce 1
Code Size 21870 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

21870 bytes
0x6080604052600436106101f9576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806302c891c5146101fb57806305528715146102365780630c7ac7b61461026357806321cea538146102f357806322b52d6614610375578063246c76df146103a057806324baacc7146103cd578063311a6c56146103fa578063325df18814610431578063460478381461045e57806356858619146105c957806368c76ffd1461062a5780636c0b7e71146106d65780636cc6cde1146107015780636cf39c2b1461075857806377b9fda81461079957806383c4b7a3146107c457806384e3a3111461082f5780638a9bb02a1461085a5780639244c7041461093c578063953d6651146109535780639543c9fd14610980578063965394ab146109ad5780639b3ac998146109d85780639c15d1a214610a03578063a3c595c914610a2e578063a446ff5714610b23578063ad73349e14610b43578063b512570014610bdf578063b6cd08c614610c0a578063b6dc775414610c45578063ba7079ca14610c70578063bb0b86ff14610cf9578063c4bd851914610d24578063cc2bcdb414610d4f578063ce1d8ab214610d7c578063d5f3948814610da7578063d661dd3114610dfe578063dc17bbdb14610e29578063f730c07f14610e6a578063f8d18b0414610e95575b005b34801561020757600080fd5b50610234600480360381019080803590602001908201803590602001919091929391929390505050610ed6565b005b34801561024257600080fd5b506102616004803603810190808035906020019092919050505061105a565b005b34801561026f57600080fd5b5061027861112d565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156102b857808201518184015260208101905061029d565b50505050905090810190601f1680156102e55780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156102ff57600080fd5b5061031e600480360381019080803590602001909291905050506111cb565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b83811015610361578082015181840152602081019050610346565b505050509050019250505060405180910390f35b34801561038157600080fd5b5061038a611249565b6040518082815260200191505060405180910390f35b3480156103ac57600080fd5b506103cb6004803603810190808035906020019092919050505061124f565b005b3480156103d957600080fd5b506103f860048036038101908080359060200190929190505050611322565b005b34801561040657600080fd5b5061042f60048036038101908080359060200190929190803590602001909291905050506113f5565b005b34801561043d57600080fd5b5061045c6004803603810190808035906020019092919050505061169b565b005b6105c76004803603810190808035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929080359060200190820180359060200190808060200260200160405190810160405280939291908181526020018383602002808284378201915050505050509192919290803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061176e565b005b3480156105d557600080fd5b50610628600480360381019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190803590602001909291905050506124c7565b005b34801561063657600080fd5b5061067f6004803603810190808035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612853565b6040518080602001828103825283818151815260200191508051906020019060200280838360005b838110156106c25780820151818401526020810190506106a7565b505050509050019250505060405180910390f35b3480156106e257600080fd5b506106eb612967565b6040518082815260200191505060405180910390f35b34801561070d57600080fd5b50610716612977565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561076457600080fd5b5061079760048036038101908080359060200190929190803590602001909291908035906020019092919050505061299c565b005b3480156107a557600080fd5b506107ae612d44565b6040518082815260200191505060405180910390f35b3480156107d057600080fd5b506107ef60048036038101908080359060200190929190505050612d4a565b6040518086815260200185815260200184815260200183600281111561081157fe5b60ff1681526020018281526020019550505050505060405180910390f35b34801561083b57600080fd5b50610844612d9c565b6040518082815260200191505060405180910390f35b34801561086657600080fd5b5061088f6004803603810190808035906020019092919080359060200190929190505050612da2565b604051808060200180602001858152602001848152602001838103835287818151815260200191508051906020019060200280838360005b838110156108e25780820151818401526020810190506108c7565b50505050905001838103825286818151815260200191508051906020019060200280838360005b83811015610924578082015181840152602081019050610909565b50505050905001965050505050505060405180910390f35b34801561094857600080fd5b50610951612f11565b005b34801561095f57600080fd5b5061097e60048036038101908080359060200190929190505050613635565b005b34801561098c57600080fd5b506109ab600480360381019080803590602001909291905050506137c6565b005b3480156109b957600080fd5b506109c2613899565b6040518082815260200191505060405180910390f35b3480156109e457600080fd5b506109ed61389f565b6040518082815260200191505060405180910390f35b348015610a0f57600080fd5b50610a186138a5565b6040518082815260200191505060405180910390f35b348015610a3a57600080fd5b50610a6360048036038101908080359060200190929190803590602001909291905050506138ab565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018060200183151515158152602001828103825284818151815260200191508051906020019080838360005b83811015610ae5578082015181840152602081019050610aca565b50505050905090810190601f168015610b125780820380516001836020036101000a031916815260200191505b509550505050505060405180910390f35b610b41600480360381019080803590602001909291905050506139e4565b005b348015610b4f57600080fd5b50610b6e60048036038101908080359060200190929190505050614633565b604051808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001868152602001856000191660001916815260200184815260200183151515158152602001828152602001965050505050505060405180910390f35b348015610beb57600080fd5b50610bf46146ab565b6040518082815260200191505060405180910390f35b348015610c1657600080fd5b50610c436004803603810190808035906020019092919080356000191690602001909291905050506146de565b005b348015610c5157600080fd5b50610c5a614b54565b6040518082815260200191505060405180910390f35b348015610c7c57600080fd5b50610cf7600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050614b61565b005b348015610d0557600080fd5b50610d0e614d43565b6040518082815260200191505060405180910390f35b348015610d3057600080fd5b50610d39614d49565b6040518082815260200191505060405180910390f35b348015610d5b57600080fd5b50610d7a60048036038101908080359060200190929190505050614d4f565b005b348015610d8857600080fd5b50610d91614e22565b6040518082815260200191505060405180910390f35b348015610db357600080fd5b50610dbc614e28565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610e0a57600080fd5b50610e13614e4e565b6040518082815260200191505060405180910390f35b348015610e3557600080fd5b50610e5460048036038101908080359060200190929190505050614e54565b6040518082815260200191505060405180910390f35b348015610e7657600080fd5b50610e7f614e86565b6040518082815260200191505060405180910390f35b348015610ea157600080fd5b50610ec060048036038101908080359060200190929190505050614e8c565b6040518082815260200191505060405180910390f35b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610fc1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260388152602001807f43616e206f6e6c792062652063616c6c6564206f6e636520627920746865206481526020017f65706c6f796572206f662074686520636f6e74726163742e000000000000000081525060400191505060405180910390fd5b6000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060007f61606860eb6c87306811e2695215385101daab53bd6ab4e9f9049aead9363c7d8383604051808060200182810382528484828181526020019250808284378201915050935050505060405180910390a25050565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16141515611123576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b80600a8190555050565b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111c35780601f10611198576101008083540402835291602001916111c3565b820191906000526020600020905b8154815290600101906020018083116111a657829003601f168201915b505050505081565b60606000600e838154811015156111de57fe5b906000526020600020906008020190508060030180548060200260200160405190810160405280929190818152602001828054801561123c57602002820191906000526020600020905b815481526020019060010190808311611228575b5050505050915050919050565b60065481565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16141515611318576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8060078190555050565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415156113eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8060048190555050565b6000600e6001600e805490500381548110151561140e57fe5b906000526020600020906008020190506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611508576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001807f4d7573742062652063616c6c6564206279207468652061726269747261746f7281526020017f2e0000000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6001600281111561151557fe5b8160050160009054906101000a900460ff16600281111561153257fe5b1415156115cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001807f54686520646973707574652068617320616c7265616479206265656e2072657381526020017f6f6c7665642e000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8060030180549050821115151561164c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f52756c696e67206973206f7574206f6620626f756e64732e000000000000000081525060200191505060405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600c5414151561168b57611686836001600c5401614ebe565b611696565b6116958383614ebe565b5b505050565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16141515611764576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8060098190555050565b600080611779615136565b6000806060600080600080600e6001600e805490500381548110151561179b57fe5b90600052602060002090600802016007015490506117c48160055461505590919063ffffffff16565b600b5442031115151561183f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f5375626d697373696f6e2074696d652068617320656e6465642e00000000000081525060200191505060405180910390fd5b8d518f51141515611904576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260448152602001807f496e636f727265637420696e7075742e2054617267657420616e642076616c7581526020017f6520617272617973206d757374206265206f66207468652073616d65206c656e81526020017f6774682e0000000000000000000000000000000000000000000000000000000081525060600191505060405180910390fd5b8b518f511415156119c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260478152602001807f496e636f727265637420696e7075742e2054617267657420616e64206461746181526020017f73697a6520617272617973206d757374206265206f66207468652073616d652081526020017f6c656e6774682e0000000000000000000000000000000000000000000000000081525060600191505060405180910390fd5b600e6001600e80549050038154811015156119e057fe5b90600052602060002090600802019950600d808054809190600101611a059190615159565b815481101515611a1157fe5b90600052602060002090600702019850338960000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f7434ea960016040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004018080602001828103825283818154600181600116156101000203166002900481526020019150805460018160011615610100020316600290048015611b575780601f10611b2c57610100808354040283529160200191611b57565b820191906000526020600020905b815481529060010190602001808311611b3a57829003601f168201915b505092505050602060405180830381600087803b158015611b7757600080fd5b505af1158015611b8b573d6000803e3d6000fd5b505050506040513d6020811015611ba157600080fd5b810190808051906020019092919050505060045401896001018190555088600101543410151515611c60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001807f5375626d697373696f6e206465706f736974206d75737420626520706169642081526020017f696e2066756c6c2e00000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600095505b8e518610156121c8578b86815181101515611c7c57fe5b906020019060200201516040519080825280601f01601f191660200182016040528015611cb85781602001602082028038833980820191505090505b50945088600201896002018054809190600101611cd5919061518b565b815481101515611ce157fe5b906000526020600020906004020193508e86815181101515611cff57fe5b906020019060200201518460000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508d86815181101515611d5957fe5b906020019060200201518460010181905550600092505b8b86815181101515611d7e57fe5b90602001906020020151831015611e35578c838801815181101515611d9f57fe5b9060200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000028584815181101515611df857fe5b9060200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508280600101935050611d70565b84846002019080519060200190611e4d9291906151bd565b508b86815181101515611e5c57fe5b90602001906020020151870196508360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16846001015485600201604051602001808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140183815260200182805460018160011615610100020316600290048015611f3d5780601f10611f1b576101008083540402835291820191611f3d565b820191906000526020600020905b815481529060010190602001808311611f29575b505093505050506040516020818303038152906040526040518082805190602001908083835b602083101515611f885780518252602082019150602081019050602083039250611f63565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020886002600381101515611fc457fe5b60200201906000191690816000191681525050876001600381101515611fe657fe5b602002015160019004886002600381101515611ffe57fe5b602002015160019004101515156120a3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001807f546865207472616e73616374696f6e732061726520696e20696e636f7272656381526020017f74206f726465722e00000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8760026003811015156120b257fe5b60200201518860006003811015156120c657fe5b60200201516040516020018083600019166000191681526020018260001916600019168152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831015156121365780518252602082019150602081019050602083039250612111565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902088600060038110151561217257fe5b6020020190600019169081600019168152505087600260038110151561219457fe5b60200201518860016003811015156121a857fe5b602002019060001916908160001916815250508580600101965050611c65565b8960060160008960006003811015156121dd57fe5b60200201516000191660001916815260200190815260200160002060009054906101000a900460ff161515156122a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001807f5468652073616d65206c6973742077617320616c7265616479207375626d697481526020017f746564206561726c6965722e000000000000000000000000000000000000000081525060400191505060405180910390fd5b60018a60060160008a60006003811015156122b857fe5b60200201516000191660001916815260200190815260200160002060006101000a81548160ff0219169083151502179055508760006003811015156122f957fe5b602002015189600301816000191690555042896004018190555088600101548a60040160008282540192505081905550896003016001600d8054905003908060018154018082558091505090600182039060005260206000200160009091929091909150555060018a60030180549050141561238d57612384600b544261509690919063ffffffff16565b8a600701819055505b3373ffffffffffffffffffffffffffffffffffffffff166001600d80549050037f1a700b4f7df255aaf8c91c8b05abf0eab596e467dc17ef76fe4afc12541012486001600e80549050038e6040518083815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561241e578082015181840152602081019050612403565b50505050905090810190601f16801561244b5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a388600101543403915060008211156124a2573373ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f19350505050505b8860010154600360008282540192505081905550505050505050505050505050505050565b6000806000600e868154811015156124db57fe5b9060005260206000209060080201925082600001858154811015156124fc57fe5b9060005260206000209060050201915060028081111561251857fe5b8360050160009054906101000a900460ff16600281111561253557fe5b1415156125aa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f53657373696f6e2068617320616e206f6e676f696e6720646973707574652e0081525060200191505060405180910390fd5b81600101600085815260200190815260200160002060009054906101000a900460ff16151561262d578160030160008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008581526020019081526020016000205490506127a1565b60008360010154148061266757508160010160006001856001015403815260200190815260200160002060009054906101000a900460ff16155b156126ef57600082600401541161267f5760006126e8565b816004015482600201548360030160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600087815260200190815260200160002054028115156126e657fe5b045b90506127a0565b836001846001015403141561279f576000826000016000868152602001908152602001600020541161272257600061279c565b8160000160008581526020019081526020016000205482600201548360030160008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000878152602001908152602001600020540281151561279a57fe5b045b90505b5b5b60008260030160008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000868152602001908152602001600020819055508673ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f19350505050506128448160035461509690919063ffffffff16565b60038190555050505050505050565b60606000806000600e8781548110151561286957fe5b90600052602060002090600802019250826000018681548110151561288a57fe5b9060005260206000209060050201915082600301805490506040519080825280602002602001820160405280156128d05781602001602082028038833980820191505090505b509350600090505b835181101561295d578160030160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082815260200190815260200160002054848281518110151561294257fe5b906020019060200201818152505080806001019150506128d8565b5050509392505050565b60006001600e8054905003905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806000600d888154811015156129b357fe5b906000526020600020906007020194508460050160009054906101000a900460ff161515612a6f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260288152602001807f43616e27742065786563757465206c6973742074686174207761736e2774206181526020017f7070726f7665642e00000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6006548560060154420311151515612b15576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001807f54696d6520746f206578656375746520746865207472616e73616374696f6e2081526020017f6c69737420686173207061737365642e0000000000000000000000000000000081525060400191505060405180910390fd5b8693505b846002018054905084108015612b3b57506000861480612b3a575085870184105b5b15612d3a578460020184815481101515612b5157fe5b90600052602060002090600402019250612b696146ab565b91508260030160009054906101000a900460ff16158015612b8e575081836001015411155b15612d2d578260000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360010154846002016040518082805460018160011615610100020316600290048015612c3c5780601f10612c1157610100808354040283529160200191612c3c565b820191906000526020600020905b815481529060010190602001808311612c1f57829003601f168201915b505091505060006040518083038185875af1925050509050600115158115151415612d2c578260030160009054906101000a900460ff16151515612d0e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602b8152602001807f54686973207472616e73616374696f6e2068617320616c72656164792062656581526020017f6e2065786563757465642e00000000000000000000000000000000000000000081525060400191505060405180910390fd5b60018360030160006101000a81548160ff0219169083151502179055505b5b8380600101945050612b19565b5050505050505050565b60035481565b600e81815481101515612d5957fe5b90600052602060002090600802016000915090508060010154908060020154908060040154908060050160009054906101000a900460ff16908060070154905085565b600c5481565b6060806000806000806000600e89815481101515612dbc57fe5b906000526020600020906008020192508260000188815481101515612ddd57fe5b906000526020600020906005020191508260030180549050604051908082528060200260200182016040528015612e235781602001602082028038833980820191505090505b5096508260030180549050604051908082528060200260200182016040528015612e5c5781602001602082028038833980820191505090505b509550600090505b8260030180549050811015612ef757816000016000828152602001908152602001600020548782815181101515612e9757fe5b906020019060200201818152505081600101600082815260200190815260200160002060009054906101000a900460ff168682815181101515612ed657fe5b90602001906020020190151590811515815250508080600101915050612e64565b816002015494508160040154935050505092959194509250565b6000806000806000600e6001600e8054905003815481101515612f3057fe5b9060005260206000209060080201600701549050612f598160055461505590919063ffffffff16565b600b544203111515612ff9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001807f417070726f76616c2074696d6520686173206e6f74207374617274656420796581526020017f742e00000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b600e6001600e805490500381548110151561301057fe5b906000526020600020906008020194506000600281111561302d57fe5b8560050160009054906101000a900460ff16600281111561304a57fe5b1415156130e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260378152602001807f43616e277420617070726f7665207472616e73616374696f6e206c697374207781526020017f68696c652064697370757465206973206163746976652e00000000000000000081525060400191505060405180910390fd5b60008560030180549050141561313c5742600b8190555060028560050160006101000a81548160ff0219169083600281111561311d57fe5b0217905550600e8054809190600101613136919061523d565b5061362e565b60018560030180549050141561327a57600d85600301600081548110151561316057fe5b906000526020600020015481548110151561317757fe5b9060005260206000209060070201935060018460050160006101000a81548160ff02191690831515021790555042846006018190555084600401549250600085600401819055508360000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f193505050505042600b8190555060028560050160006101000a81548160ff0219169083600281111561324057fe5b0217905550600e8054809190600101613259919061523d565b5061326f8360035461509690919063ffffffff16565b60038190555061362d565b60018560050160006101000a81548160ff0219169083600281111561329b57fe5b02179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f7434ea960016040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180806020018281038252838181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156133935780601f1061336857610100808354040283529160200191613393565b820191906000526020600020905b81548152906001019060200180831161337657829003601f168201915b505092505050602060405180830381600087803b1580156133b357600080fd5b505af11580156133c7573d6000803e3d6000fd5b505050506040513d60208110156133dd57600080fd5b810190808051906020019092919050505091506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c13517e183876003018054905060016040518463ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180838152602001806020018281038252838181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156134f25780601f106134c7576101008083540402835291602001916134f2565b820191906000526020600020905b8154815290600101906020018083116134d557829003601f168201915b505093505050506020604051808303818588803b15801561351257600080fd5b505af1158015613526573d6000803e3d6000fd5b50505050506040513d602081101561353d57600080fd5b8101908080519060200190929190505050856002018190555084600001805480919060010161356c919061526f565b5061358482866004015461509690919063ffffffff16565b85600401819055506135a18260035461509690919063ffffffff16565b60038190555084600201546000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f74baab670a4015ab2f1b467c5252a96141a2573f2908e58a92081e80d3cfde3d60006001600e8054905003604051808381526020018281526020019250505060405180910390a35b5b5050505050565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff161415156136fe576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6000600e6001600e805490500381548110151561371757fe5b90600052602060002090600802016007015490506137408160055461505590919063ffffffff16565b600b544203111515156137bb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f5375626d697373696f6e2074696d652068617320656e6465642e00000000000081525060200191505060405180910390fd5b816005819055505050565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614151561388f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8060088190555050565b600a5481565b60095481565b60075481565b60008060606000806000600d888154811015156138c457fe5b9060005260206000209060070201915081600201878154811015156138e557fe5b906000526020600020906004020190508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff168160010154826002018360030160009054906101000a900460ff16818054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156139ca5780601f1061399f576101008083540402835291602001916139ca565b820191906000526020600020905b8154815290600101906020018083116139ad57829003601f168201915b505050505091509550955095509550505092959194509250565b600080600080600080600080600080600e6001600e8054905003815481101515613a0a57fe5b9060005260206000209060080201995060018a60030180549050038b11151515613a9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601e8152602001807f5375626d697373696f6e4944206973206f7574206f6620626f756e64732e000081525060200191505060405180910390fd5b60016002811115613aa957fe5b8a60050160009054906101000a900460ff166002811115613ac657fe5b141515613b3b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260158152602001807f4e6f206469737075746520746f2061707065616c2e000000000000000000000081525060200191505060405180910390fd5b60016002811115613b4857fe5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166310f169e88c600201546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b158015613bdc57600080fd5b505af1158015613bf0573d6000803e3d6000fd5b505050506040513d6020811015613c0657600080fd5b81019080805190602001909291905050506002811115613c2257fe5b141515613c97576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f44697370757465206973206e6f742061707065616c61626c652e00000000000081525060200191505060405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663afe15cfb8b600201546040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808281526020019150506040805180830381600087803b158015613d2a57600080fd5b505af1158015613d3e573d6000803e3d6000fd5b505050506040513d6040811015613d5457600080fd5b81019080805190602001909291908051906020019092919050505098509850884210158015613d8257508742105b1515613e1c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001807f41707065616c2066656573206d75737420626520706169642077697468696e2081526020017f7468652061707065616c20706572696f642e000000000000000000000000000081525060400191505060405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16631c3db16d8b600201546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050602060405180830381600087803b158015613eb057600080fd5b505af1158015613ec4573d6000803e3d6000fd5b505050506040513d6020811015613eda57600080fd5b8101908080519060200190929190505050965060018b01871415613f02576009549550613fc9565b6000871415613f15576008549550613fc8565b6002898903811515613f2357fe5b04894203101515613fc2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603e8152602001807f546865206c6f736572206d7573742070617920647572696e672074686520666981526020017f7273742068616c66206f66207468652061707065616c20706572696f642e000081525060400191505060405180910390fd5b600a5495505b5b8960000160018b6000018054905003815481101515613fe457fe5b906000526020600020906005020194508460010160008c815260200190815260200160002060009054906101000a900460ff161515156140b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001807f41707065616c206665652068617320616c7265616479206265656e207061696481526020017f2e0000000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f23f16e68b6002015460016040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180838152602001806020018281038252838181546001816001161561010002031660029004815260200191508054600181600116156101000203166002900480156141b05780601f10614185576101008083540402835291602001916141b0565b820191906000526020600020905b81548152906001019060200180831161419357829003601f168201915b50509350505050602060405180830381600087803b1580156141d157600080fd5b505af11580156141e5573d6000803e3d6000fd5b505050506040513d60208110156141fb57600080fd5b8101908080519060200190929190505050935061424061271061422788876150b590919063ffffffff16565b81151561423057fe5b048561505590919063ffffffff16565b92506142733461426e8760000160008f8152602001908152602001600020548661509690919063ffffffff16565b615113565b8092508193505050818560030160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008d815260200190815260200160002060008282540192505081905550818560000160008d815260200190815260200160002060008282540192505081905550828560000160008d8152602001908152602001600020541015156143cb5760018560010160008d815260200190815260200160002060006101000a81548160ff0219169083151502179055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600c54141561437c578a600c819055505b8460000160008c81526020019081526020016000205485600201600082825401925050819055508460000160008c81526020019081526020016000205485600401600082825401925050819055505b3373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f1935050505050816003600082825401925050819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600c541415801561444557508a600c5414155b801561447057508460010160008c815260200190815260200160002060009054906101000a900460ff165b15614626577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600c819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166349912f88858c6002015460016040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808381526020018060200182810382528381815460018160011615610100020316600290048152602001915080546001816001161561010002031660029004801561459b5780601f106145705761010080835404028352916020019161459b565b820191906000526020600020905b81548152906001019060200180831161457e57829003601f168201915b505093505050506000604051808303818588803b1580156145bb57600080fd5b505af11580156145cf573d6000803e3d6000fd5b50505050508960000180548091906001016145ea919061526f565b5061460284866002015461509690919063ffffffff16565b856002018190555061461f8460035461509690919063ffffffff16565b6003819055505b5050505050505050505050565b600d8181548110151561464257fe5b90600052602060002090600702016000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060030154908060040154908060050160009054906101000a900460ff16908060060154905086565b60006146d96003543073ffffffffffffffffffffffffffffffffffffffff163161509690919063ffffffff16565b905090565b600080600e6001600e80549050038154811015156146f857fe5b90600052602060002090600802019150600d826003018581548110151561471b57fe5b906000526020600020015481548110151561473257fe5b90600052602060002090600702019050600260055481151561475057fe5b04600b54420311151515614818576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252604f8152602001807f4c697374732063616e2062652077697468647261776e206f6e6c7920696e207481526020017f68652066697273742068616c66206f662074686520696e697469616c2073756281526020017f6d697373696f6e20706572696f642e000000000000000000000000000000000081525060600191505060405180910390fd5b82600019168160030154600019161415156148c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001807f50726f7669646564206861736820646f65736e277420636f72726573706f6e6481526020017f2077697468207375626d697373696f6e2049442e00000000000000000000000081525060400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156149ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260308152602001807f43616e277420776974686472617720746865206c69737420637265617465642081526020017f627920736f6d656f6e6520656c73652e0000000000000000000000000000000081525060400191505060405180910390fd5b6007548160040154420311151515614a2e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f5769746864726177696e672074696d6520686173207061737365642e0000000081525060200191505060405180910390fd5b816003016001836003018054905003815481101515614a4957fe5b90600052602060002001548260030185815481101515614a6557fe5b90600052602060002001819055506000826006016000856000191660001916815260200190815260200160002060006101000a81548160ff02191690831515021790555081600301805480919060019003614ac091906152a1565b50614adc8160010154836004015461509690919063ffffffff16565b82600401819055503373ffffffffffffffffffffffffffffffffffffffff166108fc82600101549081150290604051600060405180830381858888f19350505050158015614b2e573d6000803e3d6000fd5b50614b48816001015460035461509690919063ffffffff16565b60038190555050505050565b6000600d80549050905090565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16141515614c2a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b6000600e6001600e8054905003815481101515614c4357fe5b9060005260206000209060080201600701549050614c6c8160055461505590919063ffffffff16565b600b54420311151515614ce7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601a8152602001807f5375626d697373696f6e2074696d652068617320656e6465642e00000000000081525060200191505060405180910390fd5b826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508160019080519060200190614d3d9291906151bd565b50505050565b60045481565b60055481565b3373ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16141515614e18576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c792074686520676f7665726e6f722063616e206578656375746520746881526020017f69732e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b8060068190555050565b60085481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61271081565b600080600d83815481101515614e6657fe5b906000526020600020906007020190508060020180549050915050919050565b600b5481565b600080600e83815481101515614e9e57fe5b906000526020600020906008020190508060000180549050915050919050565b600080600e6001600e8054905003815481101515614ed857fe5b90600052602060002090600802019150600083141515614fb457600d8260030160018503815481101515614f0857fe5b9060005260206000200154815481101515614f1f57fe5b9060005260206000209060070201905060018160050160006101000a81548160ff0219169083151502179055504281600601819055508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc83600401549081150290604051600060405180830381858888f19350505050505b614fcd826004015460035461509690919063ffffffff16565b600381905550600082600401819055507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600c8190555042600b8190555060028260050160006101000a81548160ff0219169083600281111561502c57fe5b0217905550828260010181905550600e805480919060010161504e919061523d565b5050505050565b60008082840190508381101561508b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61508d565b805b91505092915050565b6000828211156150a957600090506150af565b81830390505b92915050565b60008060008414156150ca576000915061510c565b82840290508284828115156150db57fe5b0414615107577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff615109565b805b91505b5092915050565b600080838311156151265783915061512f565b82915082840390505b9250929050565b606060405190810160405280600390602082028038833980820191505090505090565b8154818355818111156151865760070281600702836000526020600020918201910161518591906152cd565b5b505050565b8154818355818111156151b8576004028160040283600052602060002091820191016151b79190615357565b5b505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106151fe57805160ff191683800117855561522c565b8280016001018555821561522c579182015b8281111561522b578251825591602001919060010190615210565b5b50905061523991906153c9565b5090565b81548183558181111561526a5760080281600802836000526020600020918201910161526991906153ee565b5b505050565b81548183558181111561529c5760050281600502836000526020600020918201910161529b9190615461565b5b505050565b8154818355818111156152c8578183600052602060002091820191016152c791906153c9565b5b505050565b61535491905b8082111561535057600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff0219169055600182016000905560028201600061531b9190615491565b600382016000905560048201600090556005820160006101000a81549060ff02191690556006820160009055506007016152d3565b5090565b90565b6153c691905b808211156153c257600080820160006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905560018201600090556002820160006153a591906154b5565b6003820160006101000a81549060ff02191690555060040161535d565b5090565b90565b6153eb91905b808211156153e75760008160009055506001016153cf565b5090565b90565b61545e91905b8082111561545a576000808201600061540d91906154fd565b6001820160009055600282016000905560038201600061542d9190615521565b60048201600090556005820160006101000a81549060ff02191690556007820160009055506008016153f4565b5090565b90565b61548e91905b8082111561548a5760006002820160009055600482016000905550600501615467565b5090565b90565b50805460008255600402906000526020600020908101906154b29190615357565b50565b50805460018160011615610100020316600290046000825580601f106154db57506154fa565b601f0160209004906000526020600020908101906154f991906153c9565b5b50565b508054600082556005029060005260206000209081019061551e9190615461565b50565b508054600082559060005260206000209081019061553f91906153c9565b505600a165627a7a72305820d472e7f6ab530eec22004585c54aa33872fb5155dcfe0f56642e4a43219e2eb00029

Verified Source Code Partial Match

Compiler: v0.4.25+commit.59dbf8f1 EVM: byzantium Optimization: No
KlerosGovernor.sol 811 lines
library CappedMath {
    uint constant private UINT_MAX = 2**256 - 1;

    /**
     * @dev Adds two unsigned integers, returns 2^256 - 1 on overflow.
     */
    function addCap(uint _a, uint _b) internal pure returns (uint) {
        uint c = _a + _b;
        return c >= _a ? c : UINT_MAX;
    }

    /**
     * @dev Subtracts two integers, returns 0 on underflow.
     */
    function subCap(uint _a, uint _b) internal pure returns (uint) {
        if (_b > _a)
            return 0;
        else
            return _a - _b;
    }

    /**
     * @dev Multiplies two unsigned integers, returns 2^256 - 1 on overflow.
     */
    function mulCap(uint _a, uint _b) internal pure returns (uint) {
        // Gas optimization: this is cheaper than requiring '_a' not being zero, but the
        // benefit is lost if '_b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
        if (_a == 0)
            return 0;

        uint c = _a * _b;
        return c / _a == _b ? c : UINT_MAX;
    }
}

/** @title Arbitrator
 *  Arbitrator abstract contract.
 *  When developing arbitrator contracts we need to:
 *  -Define the functions for dispute creation (createDispute) and appeal (appeal). Don't forget to store the arbitrated contract and the disputeID (which should be unique, use nbDisputes).
 *  -Define the functions for cost display (arbitrationCost and appealCost).
 *  -Allow giving rulings. For this a function must call arbitrable.rule(disputeID, ruling).
 */
contract Arbitrator {

    enum DisputeStatus {Waiting, Appealable, Solved}

    modifier requireArbitrationFee(bytes _extraData) {
        require(msg.value >= arbitrationCost(_extraData), "Not enough ETH to cover arbitration costs.");
        _;
    }
    modifier requireAppealFee(uint _disputeID, bytes _extraData) {
        require(msg.value >= appealCost(_disputeID, _extraData), "Not enough ETH to cover appeal costs.");
        _;
    }

    /** @dev To be raised when a dispute is created.
     *  @param _disputeID ID of the dispute.
     *  @param _arbitrable The contract which created the dispute.
     */
    event DisputeCreation(uint indexed _disputeID, Arbitrable indexed _arbitrable);

    /** @dev To be raised when a dispute can be appealed.
     *  @param _disputeID ID of the dispute.
     */
    event AppealPossible(uint indexed _disputeID, Arbitrable indexed _arbitrable);

    /** @dev To be raised when the current ruling is appealed.
     *  @param _disputeID ID of the dispute.
     *  @param _arbitrable The contract which created the dispute.
     */
    event AppealDecision(uint indexed _disputeID, Arbitrable indexed _arbitrable);

    /** @dev Create a dispute. Must be called by the arbitrable contract.
     *  Must be paid at least arbitrationCost(_extraData).
     *  @param _choices Amount of choices the arbitrator can make in this dispute.
     *  @param _extraData Can be used to give additional info on the dispute to be created.
     *  @return disputeID ID of the dispute created.
     */
    function createDispute(uint _choices, bytes _extraData) public requireArbitrationFee(_extraData) payable returns(uint disputeID) {}

    /** @dev Compute the cost of arbitration. It is recommended not to increase it often, as it can be highly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
     *  @param _extraData Can be used to give additional info on the dispute to be created.
     *  @return fee Amount to be paid.
     */
    function arbitrationCost(bytes _extraData) public view returns(uint fee);

    /** @dev Appeal a ruling. Note that it has to be called before the arbitrator contract calls rule.
     *  @param _disputeID ID of the dispute to be appealed.
     *  @param _extraData Can be used to give extra info on the appeal.
     */
    function appeal(uint _disputeID, bytes _extraData) public requireAppealFee(_disputeID,_extraData) payable {
        emit AppealDecision(_disputeID, Arbitrable(msg.sender));
    }

    /** @dev Compute the cost of appeal. It is recommended not to increase it often, as it can be higly time and gas consuming for the arbitrated contracts to cope with fee augmentation.
     *  @param _disputeID ID of the dispute to be appealed.
     *  @param _extraData Can be used to give additional info on the dispute to be created.
     *  @return fee Amount to be paid.
     */
    function appealCost(uint _disputeID, bytes _extraData) public view returns(uint fee);

    /** @dev Compute the start and end of the dispute's current or next appeal period, if possible.
     *  @param _disputeID ID of the dispute.
     *  @return The start and end of the period.
     */
    function appealPeriod(uint _disputeID) public view returns(uint start, uint end) {}

    /** @dev Return the status of a dispute.
     *  @param _disputeID ID of the dispute to rule.
     *  @return status The status of the dispute.
     */
    function disputeStatus(uint _disputeID) public view returns(DisputeStatus status);

    /** @dev Return the current ruling of a dispute. This is useful for parties to know if they should appeal.
     *  @param _disputeID ID of the dispute.
     *  @return ruling The ruling which has been given or the one which will be given if there is no appeal.
     */
    function currentRuling(uint _disputeID) public view returns(uint ruling);
}

/** @title IArbitrable
 *  Arbitrable interface.
 *  When developing arbitrable contracts, we need to:
 *  -Define the action taken when a ruling is received by the contract. We should do so in executeRuling.
 *  -Allow dispute creation. For this a function must:
 *      -Call arbitrator.createDispute.value(_fee)(_choices,_extraData);
 *      -Create the event Dispute(_arbitrator,_disputeID,_rulingOptions);
 */
interface IArbitrable {
    /** @dev To be emmited when meta-evidence is submitted.
     *  @param _metaEvidenceID Unique identifier of meta-evidence.
     *  @param _evidence A link to the meta-evidence JSON.
     */
    event MetaEvidence(uint indexed _metaEvidenceID, string _evidence);

    /** @dev To be emmited when a dispute is created to link the correct meta-evidence to the disputeID
     *  @param _arbitrator The arbitrator of the contract.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _metaEvidenceID Unique identifier of meta-evidence.
     *  @param _evidenceGroupID Unique identifier of the evidence group that is linked to this dispute.
     */
    event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID, uint _evidenceGroupID);

    /** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations).
     *  @param _arbitrator The arbitrator of the contract.
     *  @param _evidenceGroupID Unique identifier of the evidence group the evidence belongs to.
     *  @param _party The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party.
     *  @param _evidence A URI to the evidence JSON file whose name should be its keccak256 hash followed by .json.
     */
    event Evidence(Arbitrator indexed _arbitrator, uint indexed _evidenceGroupID, address indexed _party, string _evidence);

    /** @dev To be raised when a ruling is given.
     *  @param _arbitrator The arbitrator giving the ruling.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling The ruling which was given.
     */
    event Ruling(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling);

    /** @dev Give a ruling for a dispute. Must be called by the arbitrator.
     *  The purpose of this function is to ensure that the address calling it has the right to rule on the contract.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision".
     */
    function rule(uint _disputeID, uint _ruling) public;
}

/** @title Arbitrable
 *  Arbitrable abstract contract.
 *  When developing arbitrable contracts, we need to:
 *  -Define the action taken when a ruling is received by the contract. We should do so in executeRuling.
 *  -Allow dispute creation. For this a function must:
 *      -Call arbitrator.createDispute.value(_fee)(_choices,_extraData);
 *      -Create the event Dispute(_arbitrator,_disputeID,_rulingOptions);
 */
contract Arbitrable is IArbitrable {
    Arbitrator public arbitrator;
    bytes public arbitratorExtraData; // Extra data to require particular dispute and appeal behaviour.

    modifier onlyArbitrator {require(msg.sender == address(arbitrator), "Can only be called by the arbitrator."); _;}

    /** @dev Constructor. Choose the arbitrator.
     *  @param _arbitrator The arbitrator of the contract.
     *  @param _arbitratorExtraData Extra data for the arbitrator.
     */
    constructor(Arbitrator _arbitrator, bytes _arbitratorExtraData) public {
        arbitrator = _arbitrator;
        arbitratorExtraData = _arbitratorExtraData;
    }

    /** @dev Give a ruling for a dispute. Must be called by the arbitrator.
     *  The purpose of this function is to ensure that the address calling it has the right to rule on the contract.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision".
     */
    function rule(uint _disputeID, uint _ruling) public onlyArbitrator {
        emit Ruling(Arbitrator(msg.sender),_disputeID,_ruling);

        executeRuling(_disputeID,_ruling);
    }


    /** @dev Execute a ruling of a dispute.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Not able/wanting to make a decision".
     */
    function executeRuling(uint _disputeID, uint _ruling) internal;
}

contract KlerosGovernor is Arbitrable {
    using CappedMath for uint;

    /* *** Contract variables *** */
    enum Status {NoDispute, DisputeCreated, Resolved}

    struct Session {
        Round[] rounds; // Tracks each appeal round of a dispute.
        uint ruling; // The ruling that was given in this session, if any.
        uint disputeID; // ID given to the dispute of the session, if any.
        uint[] submittedLists; // Tracks all lists that were submitted in a session. submittedLists[submissionID].
        uint sumDeposit; // Sum of all submission deposits in a session (minus arbitration fees). This is used to calculate the reward.
        Status status; // Status of a session.
        mapping(bytes32 => bool) alreadySubmitted; // Indicates whether or not the transaction list was already submitted in order to catch duplicates. alreadySubmitted[listHash].
        uint durationOffset; // Time in seconds that prolongs the submission period after the first submission, to give other submitters time to react.
    }

    struct Transaction {
        address target; // The address to call.
        uint value; // Value paid by governor contract that will be used as msg.value in the execution.
        bytes data; // Calldata of the transaction.
        bool executed; // Whether the transaction was already executed or not.
    }

    struct Submission {
        address submitter; // The one who submits the list.
        uint deposit; // Value of the deposit paid upon submission of the list.
        Transaction[] txs; // Transactions stored in the list. txs[_transactionIndex].
        bytes32 listHash; // A hash chain of all transactions stored in the list. This is used as a unique identifier.
        uint submissionTime; // The time when the list was submitted.
        bool approved; // Whether the list was approved for execution or not.
        uint approvalTime; // The time when the list was approved.
    }

    struct Round {
        mapping (uint => uint) paidFees; // Tracks the fees paid by each side in this round. paidFees[submissionID].
        mapping (uint => bool) hasPaid; // True when the side has fully paid its fees, false otherwise. hasPaid[submissionID].
        uint feeRewards; // Sum of reimbursable fees and stake rewards available to the parties that made contributions to the side that ultimately wins a dispute.
        mapping(address => mapping (uint => uint)) contributions; // Maps contributors to their contributions for each side. contributions[address][submissionID].
        uint successfullyPaid; // Sum of all successfully paid fees paid by all sides.
    }

    uint constant NO_SHADOW_WINNER = uint(-1); // The value that indicates that no one has successfully paid appeal fees in a current round. It's the largest integer and not 0, because 0 can be a valid submission index.

    address public deployer; // The address of the deployer of the contract.

    uint public reservedETH; // Sum of contract's submission deposits and appeal fees. These funds are not to be used in the execution of transactions.

    uint public submissionBaseDeposit; // The base deposit in wei that needs to be paid in order to submit the list.
    uint public submissionTimeout; // Time in seconds allowed for submitting the lists. Once it's passed the contract enters the approval period.
    uint public executionTimeout; // Time in seconds allowed for the execution of approved lists.
    uint public withdrawTimeout; // Time in seconds allowed to withdraw a submitted list.
    uint public sharedMultiplier; // Multiplier for calculating the appeal fee that must be paid by each side in the case where there is no winner/loser (e.g. when the arbitrator ruled "refuse to arbitrate").
    uint public winnerMultiplier; // Multiplier for calculating the appeal fee of the party that won the previous round.
    uint public loserMultiplier; // Multiplier for calculating the appeal fee of the party that lost the previous round.
    uint public constant MULTIPLIER_DIVISOR = 10000; // Divisor parameter for multipliers.

    uint public lastApprovalTime; // The time of the last approval of a transaction list.
    uint public shadowWinner; // Submission index of the first list that paid appeal fees. If it stays the only list that paid appeal fees, it will win regardless of the final ruling.

    Submission[] public submissions; // Stores all created transaction lists. submissions[_listID].
    Session[] public sessions; // Stores all submitting sessions. sessions[_session].

    /* *** Modifiers *** */
    modifier duringSubmissionPeriod() {
        uint offset = sessions[sessions.length - 1].durationOffset;
        require(now - lastApprovalTime <= submissionTimeout.addCap(offset), "Submission time has ended.");
        _;
    }
    modifier duringApprovalPeriod() {
        uint offset = sessions[sessions.length - 1].durationOffset;
        require(now - lastApprovalTime > submissionTimeout.addCap(offset), "Approval time has not started yet.");
        _;
    }
    modifier onlyByGovernor() {require(address(this) == msg.sender, "Only the governor can execute this."); _;}

    /* *** Events *** */
    /** @dev Emitted when a new list is submitted.
     *  @param _listID The index of the transaction list in the array of lists.
     *  @param _submitter The address that submitted the list.
     *  @param _session The number of the current session.
     *  @param _description The string in CSV format that contains labels of list's transactions.
     *  Note that the submitter may give bad descriptions of correct actions, but this is to be seen as UI enhancement, not a critical feature and that would play against him in case of dispute.
     */
    event ListSubmitted(uint indexed _listID, address indexed _submitter, uint _session, string _description);

    /** @dev Constructor.
     *  @param _arbitrator The arbitrator of the contract. It should support appealPeriod.
     *  @param _extraData Extra data for the arbitrator.
     *  @param _submissionBaseDeposit The base deposit required for submission.
     *  @param _submissionTimeout Time in seconds allocated for submitting transaction list.
     *  @param _executionTimeout Time in seconds after approval that allows to execute transactions of the approved list.
     *  @param _withdrawTimeout Time in seconds after submission that allows to withdraw submitted list.
     *  @param _sharedMultiplier Multiplier of the appeal cost that submitters has to pay for a round when there is no winner/loser in the previous round. In basis points.
     *  @param _winnerMultiplier Multiplier of the appeal cost that the winner has to pay for a round. In basis points.
     *  @param _loserMultiplier Multiplier of the appeal cost that the loser has to pay for a round. In basis points.
     */
    constructor (
        Arbitrator _arbitrator,
        bytes _extraData,
        uint _submissionBaseDeposit,
        uint _submissionTimeout,
        uint _executionTimeout,
        uint _withdrawTimeout,
        uint _sharedMultiplier,
        uint _winnerMultiplier,
        uint _loserMultiplier
    ) public Arbitrable(_arbitrator, _extraData) {
        lastApprovalTime = now;
        submissionBaseDeposit = _submissionBaseDeposit;
        submissionTimeout = _submissionTimeout;
        executionTimeout = _executionTimeout;
        withdrawTimeout = _withdrawTimeout;
        sharedMultiplier = _sharedMultiplier;
        winnerMultiplier = _winnerMultiplier;
        loserMultiplier = _loserMultiplier;
        shadowWinner = NO_SHADOW_WINNER;
        sessions.length++;
        deployer = msg.sender;
    }

    /** @dev Sets the meta evidence. Can only be called once.
     *  @param _metaEvidence The URI of the meta evidence file.
     */
    function setMetaEvidence(string _metaEvidence) external {
        require(msg.sender == deployer, "Can only be called once by the deployer of the contract.");
        deployer = address(0);
        emit MetaEvidence(0, _metaEvidence);
    }

    /** @dev Changes the value of the base deposit required for submitting a list.
     *  @param _submissionBaseDeposit The new value of the base deposit, in wei.
     */
    function changeSubmissionDeposit(uint _submissionBaseDeposit) public onlyByGovernor {
        submissionBaseDeposit = _submissionBaseDeposit;
    }

    /** @dev Changes the time allocated for submission.
     *  @param _submissionTimeout The new duration of the submission period, in seconds.
     */
    function changeSubmissionTimeout(uint _submissionTimeout) public onlyByGovernor duringSubmissionPeriod {
        submissionTimeout = _submissionTimeout;
    }

    /** @dev Changes the time allocated for list's execution.
     *  @param _executionTimeout The new duration of the execution timeout, in seconds.
     */
    function changeExecutionTimeout(uint _executionTimeout) public onlyByGovernor {
        executionTimeout = _executionTimeout;
    }

    /** @dev Changes the time allowed for list withdrawal.
     *  @param _withdrawTimeout The new duration of withdraw period, in seconds.
     */
    function changeWithdrawTimeout(uint _withdrawTimeout) public onlyByGovernor {
        withdrawTimeout = _withdrawTimeout;
    }

    /** @dev Changes the proportion of appeal fees that must be added to appeal cost when there is no winner or loser.
     *  @param _sharedMultiplier The new shared multiplier value in basis points.
     */
    function changeSharedMultiplier(uint _sharedMultiplier) public onlyByGovernor {
        sharedMultiplier = _sharedMultiplier;
    }

    /** @dev Changes the proportion of appeal fees that must be added to appeal cost for the winning party.
     *  @param _winnerMultiplier The new winner multiplier value in basis points.
     */
    function changeWinnerMultiplier(uint _winnerMultiplier) public onlyByGovernor {
        winnerMultiplier = _winnerMultiplier;
    }

    /** @dev Changes the proportion of appeal fees that must be added to appeal cost for the losing party.
     *  @param _loserMultiplier The new loser multiplier value in basis points.
     */
    function changeLoserMultiplier(uint _loserMultiplier) public onlyByGovernor {
        loserMultiplier = _loserMultiplier;
    }

    /** @dev Changes the arbitrator of the contract.
     *  @param _arbitrator The new trusted arbitrator.
     *  @param _arbitratorExtraData The extra data used by the new arbitrator.
     */
    function changeArbitrator(Arbitrator _arbitrator, bytes _arbitratorExtraData) public onlyByGovernor duringSubmissionPeriod {
        arbitrator = _arbitrator;
        arbitratorExtraData = _arbitratorExtraData;
    }

    /** @dev Creates transaction list based on input parameters and submits it for potential approval and execution.
     *  Transactions must be ordered by their hash.
     *  @param _target List of addresses to call.
     *  @param _value List of values required for respective addresses.
     *  @param _data Concatenated calldata of all transactions of this list.
     *  @param _dataSize List of lengths in bytes required to split calldata for its respective targets.
     *  @param _description String in CSV format that describes list's transactions.
     */
    function submitList (address[] _target, uint[] _value, bytes _data, uint[] _dataSize, string _description) public payable duringSubmissionPeriod {
        require(_target.length == _value.length, "Incorrect input. Target and value arrays must be of the same length.");
        require(_target.length == _dataSize.length, "Incorrect input. Target and datasize arrays must be of the same length.");
        Session storage session = sessions[sessions.length - 1];
        Submission storage submission = submissions[submissions.length++];
        submission.submitter = msg.sender;
        // Do the assignment first to avoid creating a new variable and bypass a 'stack too deep' error.
        submission.deposit = submissionBaseDeposit + arbitrator.arbitrationCost(arbitratorExtraData);
        require(msg.value >= submission.deposit, "Submission deposit must be paid in full.");
        // Using an array to get around the stack limit.
        // 0 - List hash.
        // 1 - Previous transaction hash.
        // 2 - Current transaction hash.
        bytes32[3] memory hashes;
        uint readingPosition;
        for (uint i = 0; i < _target.length; i++) {
            bytes memory readData = new bytes(_dataSize[i]);
            Transaction storage transaction = submission.txs[submission.txs.length++];
            transaction.target = _target[i];
            transaction.value = _value[i];
            for (uint j = 0; j < _dataSize[i]; j++) {
                readData[j] = _data[readingPosition + j];
            }
            transaction.data = readData;
            readingPosition += _dataSize[i];
            hashes[2] = keccak256(abi.encodePacked(transaction.target, transaction.value, transaction.data));
            require(uint(hashes[2]) >= uint(hashes[1]), "The transactions are in incorrect order.");
            hashes[0] = keccak256(abi.encodePacked(hashes[2], hashes[0]));
            hashes[1] = hashes[2];
        }
        require(!session.alreadySubmitted[hashes[0]], "The same list was already submitted earlier.");
        session.alreadySubmitted[hashes[0]] = true;
        submission.listHash = hashes[0];
        submission.submissionTime = now;
        session.sumDeposit += submission.deposit;
        session.submittedLists.push(submissions.length - 1);
        if (session.submittedLists.length == 1)
            session.durationOffset = now.subCap(lastApprovalTime);

        emit ListSubmitted(submissions.length - 1, msg.sender, sessions.length - 1, _description);

        uint remainder = msg.value - submission.deposit;
        if (remainder > 0)
            msg.sender.send(remainder);

        reservedETH += submission.deposit;
    }

    /** @dev Withdraws submitted transaction list. Reimburses submission deposit.
     *  Withdrawal is only possible during the first half of the submission period and during withdrawPeriod seconds after the submission is made.
     *  @param _submissionID Submission's index in the array of submitted lists of the current sesssion.
     *  @param _listHash Hash of a withdrawing list.
     */
    function withdrawTransactionList(uint _submissionID, bytes32 _listHash) public {
        Session storage session = sessions[sessions.length - 1];
        Submission storage submission = submissions[session.submittedLists[_submissionID]];
        require(now - lastApprovalTime <= submissionTimeout / 2, "Lists can be withdrawn only in the first half of the initial submission period.");
        // This require statement is an extra check to prevent _submissionID linking to the wrong list because of index swap during withdrawal.
        require(submission.listHash == _listHash, "Provided hash doesn't correspond with submission ID.");
        require(submission.submitter == msg.sender, "Can't withdraw the list created by someone else.");
        require(now - submission.submissionTime <= withdrawTimeout, "Withdrawing time has passed.");
        session.submittedLists[_submissionID] = session.submittedLists[session.submittedLists.length - 1];
        session.alreadySubmitted[_listHash] = false;
        session.submittedLists.length--;
        session.sumDeposit = session.sumDeposit.subCap(submission.deposit);
        msg.sender.transfer(submission.deposit);

        reservedETH = reservedETH.subCap(submission.deposit);
    }

    /** @dev Approves a transaction list or creates a dispute if more than one list was submitted. TRUSTED.
     *  If nothing was submitted changes session.
     */
    function executeSubmissions() public duringApprovalPeriod {
        Session storage session = sessions[sessions.length - 1];
        require(session.status == Status.NoDispute, "Can't approve transaction list while dispute is active.");
        if (session.submittedLists.length == 0) {
            lastApprovalTime = now;
            session.status = Status.Resolved;
            sessions.length++;
        } else if (session.submittedLists.length == 1) {
            Submission storage submission = submissions[session.submittedLists[0]];
            submission.approved = true;
            submission.approvalTime = now;
            uint sumDeposit = session.sumDeposit;
            session.sumDeposit = 0;
            submission.submitter.send(sumDeposit);
            lastApprovalTime = now;
            session.status = Status.Resolved;
            sessions.length++;

            reservedETH = reservedETH.subCap(sumDeposit);
        } else {
            session.status = Status.DisputeCreated;
            uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);
            session.disputeID = arbitrator.createDispute.value(arbitrationCost)(session.submittedLists.length, arbitratorExtraData);
            session.rounds.length++;
            session.sumDeposit = session.sumDeposit.subCap(arbitrationCost);

            reservedETH = reservedETH.subCap(arbitrationCost);
            emit Dispute(arbitrator, session.disputeID, 0, sessions.length - 1);
        }
    }

    /** @dev Takes up to the total amount required to fund a side of an appeal. Reimburses the rest. Creates an appeal if at least two lists are funded. TRUSTED.
     *  @param _submissionID Submission's index in the array of submitted lists of the current sesssion. Note that submissionID can be swapped with an ID of a withdrawn list in submission period.
     */
    function fundAppeal(uint _submissionID) public payable {
        Session storage session = sessions[sessions.length - 1];
        require(_submissionID <= session.submittedLists.length - 1, "SubmissionID is out of bounds.");
        require(session.status == Status.DisputeCreated, "No dispute to appeal.");
        require(arbitrator.disputeStatus(session.disputeID) == Arbitrator.DisputeStatus.Appealable, "Dispute is not appealable.");
        (uint appealPeriodStart, uint appealPeriodEnd) = arbitrator.appealPeriod(session.disputeID);
        require(
            now >= appealPeriodStart && now < appealPeriodEnd,
            "Appeal fees must be paid within the appeal period."
        );

        uint winner = arbitrator.currentRuling(session.disputeID);
        uint multiplier;
        // Unlike in submittedLists, in arbitrator "0" is reserved for "refuse to arbitrate" option. So we need to add 1 to map submission IDs with choices correctly.
        if (winner == _submissionID + 1) {
            multiplier = winnerMultiplier;
        } else if (winner == 0) {
            multiplier = sharedMultiplier;
        } else {
            require(now - appealPeriodStart < (appealPeriodEnd - appealPeriodStart)/2, "The loser must pay during the first half of the appeal period.");
            multiplier = loserMultiplier;
        }

        Round storage round = session.rounds[session.rounds.length - 1];
        require(!round.hasPaid[_submissionID], "Appeal fee has already been paid.");
        uint appealCost = arbitrator.appealCost(session.disputeID, arbitratorExtraData);
        uint totalCost = appealCost.addCap((appealCost.mulCap(multiplier)) / MULTIPLIER_DIVISOR);

        // Take up to the amount necessary to fund the current round at the current costs.
        uint contribution; // Amount contributed.
        uint remainingETH; // Remaining ETH to send back.
        (contribution, remainingETH) = calculateContribution(msg.value, totalCost.subCap(round.paidFees[_submissionID]));
        round.contributions[msg.sender][_submissionID] += contribution;
        round.paidFees[_submissionID] += contribution;
        // Add contribution to reward when the fee funding is successful, otherwise it can be withdrawn later.
        if (round.paidFees[_submissionID] >= totalCost) {
            round.hasPaid[_submissionID] = true;
            if (shadowWinner == NO_SHADOW_WINNER)
                shadowWinner = _submissionID;

            round.feeRewards += round.paidFees[_submissionID];
            round.successfullyPaid += round.paidFees[_submissionID];
        }

        // Reimburse leftover ETH.
        msg.sender.send(remainingETH);
        reservedETH += contribution;

        if (shadowWinner != NO_SHADOW_WINNER && shadowWinner != _submissionID && round.hasPaid[_submissionID]) {
            shadowWinner = NO_SHADOW_WINNER;
            arbitrator.appeal.value(appealCost)(session.disputeID, arbitratorExtraData);
            session.rounds.length++;
            round.feeRewards = round.feeRewards.subCap(appealCost);
            reservedETH = reservedETH.subCap(appealCost);
        }
    }

    /** @dev Returns the contribution value and remainder from available ETH and required amount.
     *  @param _available The amount of ETH available for the contribution.
     *  @param _requiredAmount The amount of ETH required for the contribution.
     *  @return taken The amount of ETH taken.
     *  @return remainder The amount of ETH left from the contribution.
     */
    function calculateContribution(uint _available, uint _requiredAmount)
        internal
        pure
        returns(uint taken, uint remainder)
    {
        if (_requiredAmount > _available)
            taken = _available;
        else {
            taken = _requiredAmount;
            remainder = _available - _requiredAmount;
        }
    }

    /** @dev Sends the fee stake rewards and reimbursements proportional to the contributions made to the winner of a dispute. Reimburses contributions if there is no winner.
     *  @param _beneficiary The address that made contributions to a request.
     *  @param _session The session from which to withdraw.
     *  @param _round The round from which to withdraw.
     *  @param _submissionID Submission's index in the array of submitted lists of the session which the beneficiary contributed to.
     */
    function withdrawFeesAndRewards(address _beneficiary, uint _session, uint _round, uint _submissionID) public {
        Session storage session = sessions[_session];
        Round storage round = session.rounds[_round];
        require(session.status == Status.Resolved, "Session has an ongoing dispute.");
        uint reward;
        // Allow to reimburse if funding of the round was unsuccessful.
        if (!round.hasPaid[_submissionID]) {
            reward = round.contributions[_beneficiary][_submissionID];
        } else if (session.ruling == 0 || !round.hasPaid[session.ruling - 1]) {
            // Reimburse unspent fees proportionally if there is no winner and loser. Also applies to the situation where the ultimate winner didn't pay appeal fees fully.
            reward = round.successfullyPaid > 0
                ? (round.contributions[_beneficiary][_submissionID] * round.feeRewards) / round.successfullyPaid
                : 0;
        } else if (session.ruling - 1 == _submissionID) {
            // Reward the winner. Subtract 1 from ruling to sync submissionID with arbitrator's choice.
            reward = round.paidFees[_submissionID] > 0
                ? (round.contributions[_beneficiary][_submissionID] * round.feeRewards) / round.paidFees[_submissionID]
                : 0;
        }
        round.contributions[_beneficiary][_submissionID] = 0;

        _beneficiary.send(reward); // It is the user responsibility to accept ETH.
        reservedETH = reservedETH.subCap(reward);
    }

    /** @dev Gives a ruling for a dispute. Must be called by the arbitrator.
     *  The purpose of this function is to ensure that the address calling it has the right to rule on the contract.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Refuse to arbitrate".
     */
    function rule(uint _disputeID, uint _ruling) public {
        Session storage session = sessions[sessions.length - 1];
        require(msg.sender == address(arbitrator), "Must be called by the arbitrator.");
        require(session.status == Status.DisputeCreated, "The dispute has already been resolved.");
        require(_ruling <= session.submittedLists.length, "Ruling is out of bounds.");

        if (shadowWinner != NO_SHADOW_WINNER)
            executeRuling(_disputeID, shadowWinner + 1);
        else
            executeRuling(_disputeID, _ruling);
    }

    /** @dev Executes a ruling of a dispute.
     *  @param _disputeID ID of the dispute in the Arbitrator contract.
     *  @param _ruling Ruling given by the arbitrator. Note that 0 is reserved for "Refuse to arbitrate".
     *  If the final ruling is "0" nothing is approved and deposits will stay locked in the contract.
     */
    function executeRuling(uint _disputeID, uint _ruling) internal {
        Session storage session = sessions[sessions.length - 1];
        if (_ruling != 0) {
            Submission storage submission = submissions[session.submittedLists[_ruling - 1]];
            submission.approved = true;
            submission.approvalTime = now;
            submission.submitter.send(session.sumDeposit);
        }
        // If the ruiling is "0" the reserved funds of this session become expendable.
        reservedETH = reservedETH.subCap(session.sumDeposit);

        session.sumDeposit = 0;
        shadowWinner = NO_SHADOW_WINNER;
        lastApprovalTime = now;
        session.status = Status.Resolved;
        session.ruling = _ruling;
        sessions.length++;
    }

    /** @dev Executes selected transactions of the list. UNTRUSTED.
     *  @param _listID The index of the transaction list in the array of lists.
     *  @param _cursor Index of the transaction from which to start executing.
     *  @param _count Number of transactions to execute. Executes until the end if set to "0" or number higher than number of transactions in the list.
     */
    function executeTransactionList(uint _listID, uint _cursor, uint _count) public {
        Submission storage submission = submissions[_listID];
        require(submission.approved, "Can't execute list that wasn't approved.");
        require(now - submission.approvalTime <= executionTimeout, "Time to execute the transaction list has passed.");
        for (uint i = _cursor; i < submission.txs.length && (_count == 0 || i < _cursor + _count); i++) {
            Transaction storage transaction = submission.txs[i];
            uint expendableFunds = getExpendableFunds();
            if (!transaction.executed && transaction.value <= expendableFunds) {
                bool callResult = transaction.target.call.value(transaction.value)(transaction.data); // solium-disable-line security/no-call-value
                // An extra check to prevent re-entrancy through target call.
                if (callResult == true) {
                    require(!transaction.executed, "This transaction has already been executed.");
                    transaction.executed = true;
                }
            }
        }
    }

    /** @dev Fallback function to receive funds for the execution of transactions.
     */
    function () public payable {}

    /** @dev Gets the sum of contract funds that are used for the execution of transactions.
     *  @return Contract balance without reserved ETH.
     */
    function getExpendableFunds() public view returns (uint) {
        return address(this).balance.subCap(reservedETH);
    }

    /** @dev Gets the info of the specified transaction in the specified list.
     *  @param _listID The index of the transaction list in the array of lists.
     *  @param _transactionIndex The index of the transaction.
     *  @return The transaction info.
     */
    function getTransactionInfo(uint _listID, uint _transactionIndex)
        public
        view
        returns (
            address target,
            uint value,
            bytes data,
            bool executed
        )
    {
        Submission storage submission = submissions[_listID];
        Transaction storage transaction = submission.txs[_transactionIndex];
        return (
            transaction.target,
            transaction.value,
            transaction.data,
            transaction.executed
        );
    }

    /** @dev Gets the contributions made by a party for a given round of a session.
     *  Note that this function is O(n), where n is the number of submissions in the session. This could exceed the gas limit, therefore this function should only be used for interface display and not by other contracts.
     *  @param _session The ID of the session.
     *  @param _round The position of the round.
     *  @param _contributor The address of the contributor.
     *  @return The contributions.
     */
    function getContributions(
        uint _session,
        uint _round,
        address _contributor
    ) public view returns(uint[] contributions) {
        Session storage session = sessions[_session];
        Round storage round = session.rounds[_round];

        contributions = new uint[](session.submittedLists.length);
        for (uint i = 0; i < contributions.length; i++) {
            contributions[i] = round.contributions[_contributor][i];
        }
    }

    /** @dev Gets the information on a round of a session.
     *  Note that this function is O(n), where n is the number of submissions in the session. This could exceed the gas limit, therefore this function should only be used for interface display and not by other contracts.
     *  @param _session The ID of the session.
     *  @param _round The round to be queried.
     *  @return The round information.
     */
    function getRoundInfo(uint _session, uint _round)
        public
        view
        returns (
            uint[] paidFees,
            bool[] hasPaid,
            uint feeRewards,
            uint successfullyPaid
        )
    {
        Session storage session = sessions[_session];
        Round storage round = session.rounds[_round];
        paidFees = new uint[](session.submittedLists.length);
        hasPaid = new bool[](session.submittedLists.length);

        for (uint i = 0; i < session.submittedLists.length; i++) {
            paidFees[i] = round.paidFees[i];
            hasPaid[i] = round.hasPaid[i];
        }

        feeRewards = round.feeRewards;
        successfullyPaid = round.successfullyPaid;
    }

    /** @dev Gets the array of submitted lists in the session.
     *  Note that this function is O(n), where n is the number of submissions in the session. This could exceed the gas limit, therefore this function should only be used for interface display and not by other contracts.
     *  @param _session The ID of the session.
     *  @return submittedLists Indexes of lists that were submitted during the session.
     */
    function getSubmittedLists(uint _session) public view returns (uint[] submittedLists) {
        Session storage session = sessions[_session];
        submittedLists = session.submittedLists;
    }

    /** @dev Gets the number of transactions in the list.
     *  @param _listID The index of the transaction list in the array of lists.
     *  @return txCount The number of transactions in the list.
     */
    function getNumberOfTransactions(uint _listID) public view returns (uint txCount) {
        Submission storage submission = submissions[_listID];
        return submission.txs.length;
    }

    /** @dev Gets the number of lists created in contract's lifetime.
     *  @return The number of created lists.
     */
    function getNumberOfCreatedLists() public view returns (uint) {
        return submissions.length;
    }

    /** @dev Gets the number of the ongoing session.
     *  @return The number of the ongoing session.
     */
    function getCurrentSessionNumber() public view returns (uint) {
        return sessions.length - 1;
    }

    /** @dev Gets the number rounds in ongoing session.
     *  @return The number of rounds in session.
     */
    function getSessionRoundsNumber(uint _session) public view returns (uint) {
        Session storage session = sessions[_session];
        return session.rounds.length;
    }
}

Read Contract

MULTIPLIER_DIVISOR 0xd661dd31 → uint256
arbitrator 0x6cc6cde1 → address
arbitratorExtraData 0x0c7ac7b6 → bytes
deployer 0xd5f39488 → address
executionTimeout 0x22b52d66 → uint256
getContributions 0x68c76ffd → uint256[]
getCurrentSessionNumber 0x6c0b7e71 → uint256
getExpendableFunds 0xb5125700 → uint256
getNumberOfCreatedLists 0xb6dc7754 → uint256
getNumberOfTransactions 0xdc17bbdb → uint256
getRoundInfo 0x8a9bb02a → uint256[], bool[], uint256, uint256
getSessionRoundsNumber 0xf8d18b04 → uint256
getSubmittedLists 0x21cea538 → uint256[]
getTransactionInfo 0xa3c595c9 → address, uint256, bytes, bool
lastApprovalTime 0xf730c07f → uint256
loserMultiplier 0x965394ab → uint256
reservedETH 0x77b9fda8 → uint256
sessions 0x83c4b7a3 → uint256, uint256, uint256, uint8, uint256
shadowWinner 0x84e3a311 → uint256
sharedMultiplier 0xce1d8ab2 → uint256
submissionBaseDeposit 0xbb0b86ff → uint256
submissionTimeout 0xc4bd8519 → uint256
submissions 0xad73349e → address, uint256, bytes32, uint256, bool, uint256
winnerMultiplier 0x9b3ac998 → uint256
withdrawTimeout 0x9c15d1a2 → uint256

Write Contract 16 functions

These functions modify contract state and require a wallet transaction to execute.

changeArbitrator 0xba7079ca
address _arbitrator
bytes _arbitratorExtraData
changeExecutionTimeout 0xcc2bcdb4
uint256 _executionTimeout
changeLoserMultiplier 0x05528715
uint256 _loserMultiplier
changeSharedMultiplier 0x9543c9fd
uint256 _sharedMultiplier
changeSubmissionDeposit 0x24baacc7
uint256 _submissionBaseDeposit
changeSubmissionTimeout 0x953d6651
uint256 _submissionTimeout
changeWinnerMultiplier 0x325df188
uint256 _winnerMultiplier
changeWithdrawTimeout 0x246c76df
uint256 _withdrawTimeout
executeSubmissions 0x9244c704
No parameters
executeTransactionList 0x6cf39c2b
uint256 _listID
uint256 _cursor
uint256 _count
fundAppeal 0xa446ff57
uint256 _submissionID
rule 0x311a6c56
uint256 _disputeID
uint256 _ruling
setMetaEvidence 0x02c891c5
string _metaEvidence
submitList 0x46047838
address[] _target
uint256[] _value
bytes _data
uint256[] _dataSize
string _description
withdrawFeesAndRewards 0x56858619
address _beneficiary
uint256 _session
uint256 _round
uint256 _submissionID
withdrawTransactionList 0xb6cd08c6
uint256 _submissionID
bytes32 _listHash

Recent Transactions

No transactions found for this address