ETH Price: $3,416.93 (+3.04%)

Contract

0xD91E45416bfbBEc6e2D1ae4aC83b788A21Acf583
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Owner Transfer E...133060302021-09-27 5:41:411184 days ago1632721301IN
Etheroll: Old Contract 4
0 ETH0.0049443100
Owner Transfer E...133060272021-09-27 5:40:091184 days ago1632721209IN
Etheroll: Old Contract 4
0 ETH0.0046404100
Owner Transfer E...133060172021-09-27 5:38:311184 days ago1632721111IN
Etheroll: Old Contract 4
0 ETH0.0046404100
Owner Transfer E...133060082021-09-27 5:36:321184 days ago1632720992IN
Etheroll: Old Contract 4
0 ETH0.0046404100
Owner Update Con...133060072021-09-27 5:36:081184 days ago1632720968IN
Etheroll: Old Contract 4
0 ETH0.0028903100
Owner Transfer E...133059952021-09-27 5:32:241184 days ago1632720744IN
Etheroll: Old Contract 4
0 ETH0.0046404100
Owner Update Con...133059902021-09-27 5:31:191184 days ago1632720679IN
Etheroll: Old Contract 4
0 ETH0.0028903100
Player Roll Dice55926862018-05-11 2:50:212419 days ago1526007021IN
Etheroll: Old Contract 4
0.1 ETH0.000090334
Player Roll Dice53603872018-04-01 10:22:262458 days ago1522578146IN
Etheroll: Old Contract 4
0.003 ETH0.000022581
Player Roll Dice53603842018-04-01 10:22:092458 days ago1522578129IN
Etheroll: Old Contract 4
0.0035 ETH0.000045162
Player Roll Dice53419092018-03-29 8:20:362461 days ago1522311636IN
Etheroll: Old Contract 4
0.004 ETH0.000022581
Player Roll Dice51766352018-03-01 10:15:412489 days ago1519899341IN
Etheroll: Old Contract 4
0.1 ETH0.000203249
Player Roll Dice51425232018-02-23 14:41:172495 days ago1519396877IN
Etheroll: Old Contract 4
0.5 ETH0.000090334
Player Roll Dice51287382018-02-21 6:21:192497 days ago1519194079IN
Etheroll: Old Contract 4
0.5 ETH0.0002258310
Player Roll Dice51286982018-02-21 6:11:322497 days ago1519193492IN
Etheroll: Old Contract 4
0.5 ETH0.0002258310
Player Roll Dice51238732018-02-20 10:17:162498 days ago1519121836IN
Etheroll: Old Contract 4
0.1 ETH0.0002258310
Player Roll Dice51172872018-02-19 7:13:422499 days ago1519024422IN
Etheroll: Old Contract 4
0.1 ETH0.000090334
Player Roll Dice51164952018-02-19 3:58:142500 days ago1519012694IN
Etheroll: Old Contract 4
0.1 ETH0.000180668
Player Roll Dice51164822018-02-19 3:55:462500 days ago1519012546IN
Etheroll: Old Contract 4
0.1 ETH0.000180668
Player Roll Dice51164492018-02-19 3:50:102500 days ago1519012210IN
Etheroll: Old Contract 4
0.1 ETH0.00009714.3
Player Roll Dice51164472018-02-19 3:49:542500 days ago1519012194IN
Etheroll: Old Contract 4
0.1 ETH0.000067743
Player Roll Dice51163122018-02-19 3:17:482500 days ago1519010268IN
Etheroll: Old Contract 4
0.1 ETH0.000022581
Player Roll Dice51028982018-02-16 21:39:142502 days ago1518817154IN
Etheroll: Old Contract 4
0.25 ETH0.000005640.25
Player Roll Dice51014092018-02-16 15:26:362502 days ago1518794796IN
Etheroll: Old Contract 4
0.1 ETH0.000045162
Player Withdraw ...50975672018-02-16 0:14:292503 days ago1518740069IN
Etheroll: Old Contract 4
0 ETH0.000028521
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
133060302021-09-27 5:41:411184 days ago1632721301
Etheroll: Old Contract 4
1.12896389 ETH
51255332018-02-20 17:04:582498 days ago1519146298
Etheroll: Old Contract 4
0.1 ETH
51253312018-02-20 16:13:372498 days ago1519143217
Etheroll: Old Contract 4
0.1 ETH
51250812018-02-20 15:09:542498 days ago1519139394
Etheroll: Old Contract 4
0.1 ETH
51248432018-02-20 14:11:282498 days ago1519135888
Etheroll: Old Contract 4
0.1 ETH
51245652018-02-20 13:05:222498 days ago1519131922
Etheroll: Old Contract 4
0.1 ETH
51243092018-02-20 12:05:212498 days ago1519128321
Etheroll: Old Contract 4
0.1 ETH
51243042018-02-20 12:04:472498 days ago1519128287
Etheroll: Old Contract 4
0.1 ETH
51240862018-02-20 11:08:432498 days ago1519124923
Etheroll: Old Contract 4
0.1 ETH
51238172018-02-20 10:05:582498 days ago1519121158
Etheroll: Old Contract 4
0.1 ETH
51236562018-02-20 9:24:052498 days ago1519118645
Etheroll: Old Contract 4
0.1 ETH
51234582018-02-20 8:32:082498 days ago1519115528
Etheroll: Old Contract 4
0.1 ETH
51231322018-02-20 7:06:532498 days ago1519110413
Etheroll: Old Contract 4
0.1 ETH
51231292018-02-20 7:06:192498 days ago1519110379
Etheroll: Old Contract 4
0.1 ETH
51228952018-02-20 6:06:242498 days ago1519106784
Etheroll: Old Contract 4
0.1 ETH
51226432018-02-20 5:06:332499 days ago1519103193
Etheroll: Old Contract 4
0.1 ETH
51226342018-02-20 5:04:552499 days ago1519103095
Etheroll: Old Contract 4
0.1 ETH
51224032018-02-20 4:10:162499 days ago1519099816
Etheroll: Old Contract 4
0.1 ETH
51221532018-02-20 3:04:462499 days ago1519095886
Etheroll: Old Contract 4
0.1 ETH
51219032018-02-20 2:04:472499 days ago1519092287
Etheroll: Old Contract 4
0.1 ETH
51216622018-02-20 1:05:402499 days ago1519088740
Etheroll: Old Contract 4
0.1 ETH
51214112018-02-20 0:05:122499 days ago1519085112
Etheroll: Old Contract 4
0.1 ETH
51211732018-02-19 23:05:362499 days ago1519081536
Etheroll: Old Contract 4
0.1 ETH
51211692018-02-19 23:04:552499 days ago1519081495
Etheroll: Old Contract 4
0.1 ETH
51210482018-02-19 22:36:102499 days ago1519079770
Etheroll: Old Contract 4
0.1 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Etheroll

Compiler Version
v0.4.18+commit.9cf6e910

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2017-10-25
*/

pragma solidity ^0.4.18;

// <ORACLIZE_API>
/*
Copyright (c) 2015-2016 Oraclize SRL
Copyright (c) 2016 Oraclize LTD



Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:



The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.



THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

contract OraclizeI {
    address public cbAddress;
    function query(uint _timestamp, string _datasource, string _arg) payable returns (bytes32 _id);
    function query_withGasLimit(uint _timestamp, string _datasource, string _arg, uint _gaslimit) payable returns (bytes32 _id);
    function query2(uint _timestamp, string _datasource, string _arg1, string _arg2) payable returns (bytes32 _id);
    function query2_withGasLimit(uint _timestamp, string _datasource, string _arg1, string _arg2, uint _gaslimit) payable returns (bytes32 _id);
    function queryN(uint _timestamp, string _datasource, bytes _argN) payable returns (bytes32 _id);
    function queryN_withGasLimit(uint _timestamp, string _datasource, bytes _argN, uint _gaslimit) payable returns (bytes32 _id);
    function getPrice(string _datasource) returns (uint _dsprice);
    function getPrice(string _datasource, uint gaslimit) returns (uint _dsprice);
    function useCoupon(string _coupon);
    function setProofType(byte _proofType);
    function setConfig(bytes32 _config);
    function setCustomGasPrice(uint _gasPrice);
    function randomDS_getSessionPubKeyHash() returns(bytes32);
}
contract OraclizeAddrResolverI {
    function getAddress() returns (address _addr);
}
contract usingOraclize {
    uint constant day = 60*60*24;
    uint constant week = 60*60*24*7;
    uint constant month = 60*60*24*30;
    byte constant proofType_NONE = 0x00;
    byte constant proofType_TLSNotary = 0x10;
    byte constant proofType_Android = 0x20;
    byte constant proofType_Ledger = 0x30;
    byte constant proofType_Native = 0xF0;
    byte constant proofStorage_IPFS = 0x01;
    uint8 constant networkID_auto = 0;
    uint8 constant networkID_mainnet = 1;
    uint8 constant networkID_testnet = 2;
    uint8 constant networkID_morden = 2;
    uint8 constant networkID_consensys = 161;

    OraclizeAddrResolverI OAR;

    OraclizeI oraclize;
    modifier oraclizeAPI {
        if((address(OAR)==0)||(getCodeSize(address(OAR))==0))
            oraclize_setNetwork(networkID_auto);

        if(address(oraclize) != OAR.getAddress())
            oraclize = OraclizeI(OAR.getAddress());

        _;
    }
    modifier coupon(string code){
        oraclize = OraclizeI(OAR.getAddress());
        oraclize.useCoupon(code);
        _;
    }

    function oraclize_setNetwork(uint8 networkID) internal returns(bool){
        if (getCodeSize(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed)>0){ //mainnet
            OAR = OraclizeAddrResolverI(0x1d3B2638a7cC9f2CB3D298A3DA7a90B67E5506ed);
            oraclize_setNetworkName("eth_mainnet");
            return true;
        }
        if (getCodeSize(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1)>0){ //ropsten testnet
            OAR = OraclizeAddrResolverI(0xc03A2615D5efaf5F49F60B7BB6583eaec212fdf1);
            oraclize_setNetworkName("eth_ropsten3");
            return true;
        }
        if (getCodeSize(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e)>0){ //kovan testnet
            OAR = OraclizeAddrResolverI(0xB7A07BcF2Ba2f2703b24C0691b5278999C59AC7e);
            oraclize_setNetworkName("eth_kovan");
            return true;
        }
        if (getCodeSize(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48)>0){ //rinkeby testnet
            OAR = OraclizeAddrResolverI(0x146500cfd35B22E4A392Fe0aDc06De1a1368Ed48);
            oraclize_setNetworkName("eth_rinkeby");
            return true;
        }
        if (getCodeSize(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475)>0){ //ethereum-bridge
            OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
            return true;
        }
        if (getCodeSize(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF)>0){ //ether.camp ide
            OAR = OraclizeAddrResolverI(0x20e12A1F859B3FeaE5Fb2A0A32C18F5a65555bBF);
            return true;
        }
        if (getCodeSize(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA)>0){ //browser-solidity
            OAR = OraclizeAddrResolverI(0x51efaF4c8B3C9AfBD5aB9F4bbC82784Ab6ef8fAA);
            return true;
        }
        return false;
    }

    function __callback(bytes32 myid, string result) {
        __callback(myid, result, new bytes(0));
    }
    function __callback(bytes32 myid, string result, bytes proof) {
    }
    
    function oraclize_useCoupon(string code) oraclizeAPI internal {
        oraclize.useCoupon(code);
    }

    function oraclize_getPrice(string datasource) oraclizeAPI internal returns (uint){
        return oraclize.getPrice(datasource);
    }

    function oraclize_getPrice(string datasource, uint gaslimit) oraclizeAPI internal returns (uint){
        return oraclize.getPrice(datasource, gaslimit);
    }
    
    function oraclize_query(string datasource, string arg) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        return oraclize.query.value(price)(0, datasource, arg);
    }
    function oraclize_query(uint timestamp, string datasource, string arg) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        return oraclize.query.value(price)(timestamp, datasource, arg);
    }
    function oraclize_query(uint timestamp, string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        return oraclize.query_withGasLimit.value(price)(timestamp, datasource, arg, gaslimit);
    }
    function oraclize_query(string datasource, string arg, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        return oraclize.query_withGasLimit.value(price)(0, datasource, arg, gaslimit);
    }
    function oraclize_query(string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        return oraclize.query2.value(price)(0, datasource, arg1, arg2);
    }
    function oraclize_query(uint timestamp, string datasource, string arg1, string arg2) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        return oraclize.query2.value(price)(timestamp, datasource, arg1, arg2);
    }
    function oraclize_query(uint timestamp, string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        return oraclize.query2_withGasLimit.value(price)(timestamp, datasource, arg1, arg2, gaslimit);
    }
    function oraclize_query(string datasource, string arg1, string arg2, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        return oraclize.query2_withGasLimit.value(price)(0, datasource, arg1, arg2, gaslimit);
    }
    function oraclize_query(string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        bytes memory args = stra2cbor(argN);
        return oraclize.queryN.value(price)(0, datasource, args);
    }
    function oraclize_query(uint timestamp, string datasource, string[] argN) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        bytes memory args = stra2cbor(argN);
        return oraclize.queryN.value(price)(timestamp, datasource, args);
    }
    function oraclize_query(uint timestamp, string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        bytes memory args = stra2cbor(argN);
        return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit);
    }
    function oraclize_query(string datasource, string[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        bytes memory args = stra2cbor(argN);
        return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit);
    }
    function oraclize_query(string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](1);
        dynargs[0] = args[0];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[1] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](1);
        dynargs[0] = args[0];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](1);
        dynargs[0] = args[0];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, string[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](1);
        dynargs[0] = args[0];       
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    
    function oraclize_query(string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[2] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, string[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[3] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, string[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    
    function oraclize_query(string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[4] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, string[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[5] args) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, string[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        string[] memory dynargs = new string[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        bytes memory args = ba2cbor(argN);
        return oraclize.queryN.value(price)(0, datasource, args);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[] argN) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource);
        if (price > 1 ether + tx.gasprice*200000) return 0; // unexpectedly high price
        bytes memory args = ba2cbor(argN);
        return oraclize.queryN.value(price)(timestamp, datasource, args);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        bytes memory args = ba2cbor(argN);
        return oraclize.queryN_withGasLimit.value(price)(timestamp, datasource, args, gaslimit);
    }
    function oraclize_query(string datasource, bytes[] argN, uint gaslimit) oraclizeAPI internal returns (bytes32 id){
        uint price = oraclize.getPrice(datasource, gaslimit);
        if (price > 1 ether + tx.gasprice*gaslimit) return 0; // unexpectedly high price
        bytes memory args = ba2cbor(argN);
        return oraclize.queryN_withGasLimit.value(price)(0, datasource, args, gaslimit);
    }
    function oraclize_query(string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](1);
        dynargs[0] = args[0];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[1] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](1);
        dynargs[0] = args[0];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](1);
        dynargs[0] = args[0];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[1] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](1);
        dynargs[0] = args[0];       
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    
    function oraclize_query(string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[2] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[2] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](2);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[3] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[3] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](3);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    
    function oraclize_query(string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[4] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[4] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](4);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        return oraclize_query(datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[5] args) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(timestamp, datasource, dynargs);
    }
    function oraclize_query(uint timestamp, string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(timestamp, datasource, dynargs, gaslimit);
    }
    function oraclize_query(string datasource, bytes[5] args, uint gaslimit) oraclizeAPI internal returns (bytes32 id) {
        bytes[] memory dynargs = new bytes[](5);
        dynargs[0] = args[0];
        dynargs[1] = args[1];
        dynargs[2] = args[2];
        dynargs[3] = args[3];
        dynargs[4] = args[4];
        return oraclize_query(datasource, dynargs, gaslimit);
    }

    function oraclize_cbAddress() oraclizeAPI internal returns (address){
        return oraclize.cbAddress();
    }
    function oraclize_setProof(byte proofP) oraclizeAPI internal {
        return oraclize.setProofType(proofP);
    }
    function oraclize_setCustomGasPrice(uint gasPrice) oraclizeAPI internal {
        return oraclize.setCustomGasPrice(gasPrice);
    }
    function oraclize_setConfig(bytes32 config) oraclizeAPI internal {
        return oraclize.setConfig(config);
    }
    
    function oraclize_randomDS_getSessionPubKeyHash() oraclizeAPI internal returns (bytes32){
        return oraclize.randomDS_getSessionPubKeyHash();
    }

    function getCodeSize(address _addr) constant internal returns(uint _size) {
        assembly {
            _size := extcodesize(_addr)
        }
    }

    function parseAddr(string _a) internal returns (address){
        bytes memory tmp = bytes(_a);
        uint160 iaddr = 0;
        uint160 b1;
        uint160 b2;
        for (uint i=2; i<2+2*20; i+=2){
            iaddr *= 256;
            b1 = uint160(tmp[i]);
            b2 = uint160(tmp[i+1]);
            if ((b1 >= 97)&&(b1 <= 102)) b1 -= 87;
            else if ((b1 >= 65)&&(b1 <= 70)) b1 -= 55;
            else if ((b1 >= 48)&&(b1 <= 57)) b1 -= 48;
            if ((b2 >= 97)&&(b2 <= 102)) b2 -= 87;
            else if ((b2 >= 65)&&(b2 <= 70)) b2 -= 55;
            else if ((b2 >= 48)&&(b2 <= 57)) b2 -= 48;
            iaddr += (b1*16+b2);
        }
        return address(iaddr);
    }

    function strCompare(string _a, string _b) internal returns (int) {
        bytes memory a = bytes(_a);
        bytes memory b = bytes(_b);
        uint minLength = a.length;
        if (b.length < minLength) minLength = b.length;
        for (uint i = 0; i < minLength; i ++)
            if (a[i] < b[i])
                return -1;
            else if (a[i] > b[i])
                return 1;
        if (a.length < b.length)
            return -1;
        else if (a.length > b.length)
            return 1;
        else
            return 0;
    }

    function indexOf(string _haystack, string _needle) internal returns (int) {
        bytes memory h = bytes(_haystack);
        bytes memory n = bytes(_needle);
        if(h.length < 1 || n.length < 1 || (n.length > h.length))
            return -1;
        else if(h.length > (2**128 -1))
            return -1;
        else
        {
            uint subindex = 0;
            for (uint i = 0; i < h.length; i ++)
            {
                if (h[i] == n[0])
                {
                    subindex = 1;
                    while(subindex < n.length && (i + subindex) < h.length && h[i + subindex] == n[subindex])
                    {
                        subindex++;
                    }
                    if(subindex == n.length)
                        return int(i);
                }
            }
            return -1;
        }
    }

    function strConcat(string _a, string _b, string _c, string _d, string _e) internal returns (string) {
        bytes memory _ba = bytes(_a);
        bytes memory _bb = bytes(_b);
        bytes memory _bc = bytes(_c);
        bytes memory _bd = bytes(_d);
        bytes memory _be = bytes(_e);
        string memory abcde = new string(_ba.length + _bb.length + _bc.length + _bd.length + _be.length);
        bytes memory babcde = bytes(abcde);
        uint k = 0;
        for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i];
        for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i];
        for (i = 0; i < _bc.length; i++) babcde[k++] = _bc[i];
        for (i = 0; i < _bd.length; i++) babcde[k++] = _bd[i];
        for (i = 0; i < _be.length; i++) babcde[k++] = _be[i];
        return string(babcde);
    }

    function strConcat(string _a, string _b, string _c, string _d) internal returns (string) {
        return strConcat(_a, _b, _c, _d, "");
    }

    function strConcat(string _a, string _b, string _c) internal returns (string) {
        return strConcat(_a, _b, _c, "", "");
    }

    function strConcat(string _a, string _b) internal returns (string) {
        return strConcat(_a, _b, "", "", "");
    }

    // parseInt
    function parseInt(string _a) internal returns (uint) {
        return parseInt(_a, 0);
    }

    // parseInt(parseFloat*10^_b)
    function parseInt(string _a, uint _b) internal returns (uint) {
        bytes memory bresult = bytes(_a);
        uint mint = 0;
        bool decimals = false;
        for (uint i=0; i<bresult.length; i++){
            if ((bresult[i] >= 48)&&(bresult[i] <= 57)){
                if (decimals){
                   if (_b == 0) break;
                    else _b--;
                }
                mint *= 10;
                mint += uint(bresult[i]) - 48;
            } else if (bresult[i] == 46) decimals = true;
        }
        if (_b > 0) mint *= 10**_b;
        return mint;
    }

    function uint2str(uint i) internal returns (string){
        if (i == 0) return "0";
        uint j = i;
        uint len;
        while (j != 0){
            len++;
            j /= 10;
        }
        bytes memory bstr = new bytes(len);
        uint k = len - 1;
        while (i != 0){
            bstr[k--] = byte(48 + i % 10);
            i /= 10;
        }
        return string(bstr);
    }
    
    function stra2cbor(string[] arr) internal returns (bytes) {
            uint arrlen = arr.length;

            // get correct cbor output length
            uint outputlen = 0;
            bytes[] memory elemArray = new bytes[](arrlen);
            for (uint i = 0; i < arrlen; i++) {
                elemArray[i] = (bytes(arr[i]));
                outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; //+3 accounts for paired identifier types
            }
            uint ctr = 0;
            uint cborlen = arrlen + 0x80;
            outputlen += byte(cborlen).length;
            bytes memory res = new bytes(outputlen);

            while (byte(cborlen).length > ctr) {
                res[ctr] = byte(cborlen)[ctr];
                ctr++;
            }
            for (i = 0; i < arrlen; i++) {
                res[ctr] = 0x5F;
                ctr++;
                for (uint x = 0; x < elemArray[i].length; x++) {
                    // if there's a bug with larger strings, this may be the culprit
                    if (x % 23 == 0) {
                        uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x;
                        elemcborlen += 0x40;
                        uint lctr = ctr;
                        while (byte(elemcborlen).length > ctr - lctr) {
                            res[ctr] = byte(elemcborlen)[ctr - lctr];
                            ctr++;
                        }
                    }
                    res[ctr] = elemArray[i][x];
                    ctr++;
                }
                res[ctr] = 0xFF;
                ctr++;
            }
            return res;
        }

    function ba2cbor(bytes[] arr) internal returns (bytes) {
            uint arrlen = arr.length;

            // get correct cbor output length
            uint outputlen = 0;
            bytes[] memory elemArray = new bytes[](arrlen);
            for (uint i = 0; i < arrlen; i++) {
                elemArray[i] = (bytes(arr[i]));
                outputlen += elemArray[i].length + (elemArray[i].length - 1)/23 + 3; //+3 accounts for paired identifier types
            }
            uint ctr = 0;
            uint cborlen = arrlen + 0x80;
            outputlen += byte(cborlen).length;
            bytes memory res = new bytes(outputlen);

            while (byte(cborlen).length > ctr) {
                res[ctr] = byte(cborlen)[ctr];
                ctr++;
            }
            for (i = 0; i < arrlen; i++) {
                res[ctr] = 0x5F;
                ctr++;
                for (uint x = 0; x < elemArray[i].length; x++) {
                    // if there's a bug with larger strings, this may be the culprit
                    if (x % 23 == 0) {
                        uint elemcborlen = elemArray[i].length - x >= 24 ? 23 : elemArray[i].length - x;
                        elemcborlen += 0x40;
                        uint lctr = ctr;
                        while (byte(elemcborlen).length > ctr - lctr) {
                            res[ctr] = byte(elemcborlen)[ctr - lctr];
                            ctr++;
                        }
                    }
                    res[ctr] = elemArray[i][x];
                    ctr++;
                }
                res[ctr] = 0xFF;
                ctr++;
            }
            return res;
        }
        
        
    string oraclize_network_name;
    function oraclize_setNetworkName(string _network_name) internal {
        oraclize_network_name = _network_name;
    }
    
    function oraclize_getNetworkName() internal returns (string) {
        return oraclize_network_name;
    }
    
    function oraclize_newRandomDSQuery(uint _delay, uint _nbytes, uint _customGasLimit) internal returns (bytes32){
        if ((_nbytes == 0)||(_nbytes > 32)) throw;
        bytes memory nbytes = new bytes(1);
        nbytes[0] = byte(_nbytes);
        bytes memory unonce = new bytes(32);
        bytes memory sessionKeyHash = new bytes(32);
        bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash();
        assembly {
            mstore(unonce, 0x20)
            mstore(add(unonce, 0x20), xor(blockhash(sub(number, 1)), xor(coinbase, timestamp)))
            mstore(sessionKeyHash, 0x20)
            mstore(add(sessionKeyHash, 0x20), sessionKeyHash_bytes32)
        }
        bytes[3] memory args = [unonce, nbytes, sessionKeyHash]; 
        bytes32 queryId = oraclize_query(_delay, "random", args, _customGasLimit);
        oraclize_randomDS_setCommitment(queryId, sha3(bytes8(_delay), args[1], sha256(args[0]), args[2]));
        return queryId;
    }
    
    function oraclize_randomDS_setCommitment(bytes32 queryId, bytes32 commitment) internal {
        oraclize_randomDS_args[queryId] = commitment;
    }
    
    mapping(bytes32=>bytes32) oraclize_randomDS_args;
    mapping(bytes32=>bool) oraclize_randomDS_sessionKeysHashVerified;

    function verifySig(bytes32 tosignh, bytes dersig, bytes pubkey) internal returns (bool){
        bool sigok;
        address signer;
        
        bytes32 sigr;
        bytes32 sigs;
        
        bytes memory sigr_ = new bytes(32);
        uint offset = 4+(uint(dersig[3]) - 0x20);
        sigr_ = copyBytes(dersig, offset, 32, sigr_, 0);
        bytes memory sigs_ = new bytes(32);
        offset += 32 + 2;
        sigs_ = copyBytes(dersig, offset+(uint(dersig[offset-1]) - 0x20), 32, sigs_, 0);

        assembly {
            sigr := mload(add(sigr_, 32))
            sigs := mload(add(sigs_, 32))
        }
        
        
        (sigok, signer) = safer_ecrecover(tosignh, 27, sigr, sigs);
        if (address(sha3(pubkey)) == signer) return true;
        else {
            (sigok, signer) = safer_ecrecover(tosignh, 28, sigr, sigs);
            return (address(sha3(pubkey)) == signer);
        }
    }

    function oraclize_randomDS_proofVerify__sessionKeyValidity(bytes proof, uint sig2offset) internal returns (bool) {
        bool sigok;
        
        // Step 6: verify the attestation signature, APPKEY1 must sign the sessionKey from the correct ledger app (CODEHASH)
        bytes memory sig2 = new bytes(uint(proof[sig2offset+1])+2);
        copyBytes(proof, sig2offset, sig2.length, sig2, 0);
        
        bytes memory appkey1_pubkey = new bytes(64);
        copyBytes(proof, 3+1, 64, appkey1_pubkey, 0);
        
        bytes memory tosign2 = new bytes(1+65+32);
        tosign2[0] = 1; //role
        copyBytes(proof, sig2offset-65, 65, tosign2, 1);
        bytes memory CODEHASH = hex"fd94fa71bc0ba10d39d464d0d8f465efeef0a2764e3887fcc9df41ded20f505c";
        copyBytes(CODEHASH, 0, 32, tosign2, 1+65);
        sigok = verifySig(sha256(tosign2), sig2, appkey1_pubkey);
        
        if (sigok == false) return false;
        
        
        // Step 7: verify the APPKEY1 provenance (must be signed by Ledger)
        bytes memory LEDGERKEY = hex"7fb956469c5c9b89840d55b43537e66a98dd4811ea0a27224272c2e5622911e8537a2f8e86a46baec82864e98dd01e9ccc2f8bc5dfc9cbe5a91a290498dd96e4";
        
        bytes memory tosign3 = new bytes(1+65);
        tosign3[0] = 0xFE;
        copyBytes(proof, 3, 65, tosign3, 1);
        
        bytes memory sig3 = new bytes(uint(proof[3+65+1])+2);
        copyBytes(proof, 3+65, sig3.length, sig3, 0);
        
        sigok = verifySig(sha256(tosign3), sig3, LEDGERKEY);
        
        return sigok;
    }
    
    modifier oraclize_randomDS_proofVerify(bytes32 _queryId, string _result, bytes _proof) {
        // Step 1: the prefix has to match 'LP\x01' (Ledger Proof version 1)
        if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) throw;
        
        bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName());
        if (proofVerified == false) throw;
        
        _;
    }
    
    function oraclize_randomDS_proofVerify__returnCode(bytes32 _queryId, string _result, bytes _proof) internal returns (uint8){
        // Step 1: the prefix has to match 'LP\x01' (Ledger Proof version 1)
        if ((_proof[0] != "L")||(_proof[1] != "P")||(_proof[2] != 1)) return 1;
        
        bool proofVerified = oraclize_randomDS_proofVerify__main(_proof, _queryId, bytes(_result), oraclize_getNetworkName());
        if (proofVerified == false) return 2;
        
        return 0;
    }
    
    function matchBytes32Prefix(bytes32 content, bytes prefix) internal returns (bool){
        bool match_ = true;
        
        for (var i=0; i<prefix.length; i++){
            if (content[i] != prefix[i]) match_ = false;
        }
        
        return match_;
    }

    function oraclize_randomDS_proofVerify__main(bytes proof, bytes32 queryId, bytes result, string context_name) internal returns (bool){
        bool checkok;
        
        
        // Step 2: the unique keyhash has to match with the sha256 of (context name + queryId)
        uint ledgerProofLength = 3+65+(uint(proof[3+65+1])+2)+32;
        bytes memory keyhash = new bytes(32);
        copyBytes(proof, ledgerProofLength, 32, keyhash, 0);
        checkok = (sha3(keyhash) == sha3(sha256(context_name, queryId)));
        if (checkok == false) return false;
        
        bytes memory sig1 = new bytes(uint(proof[ledgerProofLength+(32+8+1+32)+1])+2);
        copyBytes(proof, ledgerProofLength+(32+8+1+32), sig1.length, sig1, 0);
        
        
        // Step 3: we assume sig1 is valid (it will be verified during step 5) and we verify if 'result' is the prefix of sha256(sig1)
        checkok = matchBytes32Prefix(sha256(sig1), result);
        if (checkok == false) return false;
        
        
        // Step 4: commitment match verification, sha3(delay, nbytes, unonce, sessionKeyHash) == commitment in storage.
        // This is to verify that the computed args match with the ones specified in the query.
        bytes memory commitmentSlice1 = new bytes(8+1+32);
        copyBytes(proof, ledgerProofLength+32, 8+1+32, commitmentSlice1, 0);
        
        bytes memory sessionPubkey = new bytes(64);
        uint sig2offset = ledgerProofLength+32+(8+1+32)+sig1.length+65;
        copyBytes(proof, sig2offset-64, 64, sessionPubkey, 0);
        
        bytes32 sessionPubkeyHash = sha256(sessionPubkey);
        if (oraclize_randomDS_args[queryId] == sha3(commitmentSlice1, sessionPubkeyHash)){ //unonce, nbytes and sessionKeyHash match
            delete oraclize_randomDS_args[queryId];
        } else return false;
        
        
        // Step 5: validity verification for sig1 (keyhash and args signed with the sessionKey)
        bytes memory tosign1 = new bytes(32+8+1+32);
        copyBytes(proof, ledgerProofLength, 32+8+1+32, tosign1, 0);
        checkok = verifySig(sha256(tosign1), sig1, sessionPubkey);
        if (checkok == false) return false;
        
        // verify if sessionPubkeyHash was verified already, if not.. let's do it!
        if (oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] == false){
            oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash] = oraclize_randomDS_proofVerify__sessionKeyValidity(proof, sig2offset);
        }
        
        return oraclize_randomDS_sessionKeysHashVerified[sessionPubkeyHash];
    }

    
    // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license
    function copyBytes(bytes from, uint fromOffset, uint length, bytes to, uint toOffset) internal returns (bytes) {
        uint minLength = length + toOffset;

        if (to.length < minLength) {
            // Buffer too small
            throw; // Should be a better way?
        }

        // NOTE: the offset 32 is added to skip the `size` field of both bytes variables
        uint i = 32 + fromOffset;
        uint j = 32 + toOffset;

        while (i < (32 + fromOffset + length)) {
            assembly {
                let tmp := mload(add(from, i))
                mstore(add(to, j), tmp)
            }
            i += 32;
            j += 32;
        }

        return to;
    }
    
    // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license
    // Duplicate Solidity's ecrecover, but catching the CALL return value
    function safer_ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal returns (bool, address) {
        // We do our own memory management here. Solidity uses memory offset
        // 0x40 to store the current end of memory. We write past it (as
        // writes are memory extensions), but don't update the offset so
        // Solidity will reuse it. The memory used here is only needed for
        // this context.

        // FIXME: inline assembly can't access return values
        bool ret;
        address addr;

        assembly {
            let size := mload(0x40)
            mstore(size, hash)
            mstore(add(size, 32), v)
            mstore(add(size, 64), r)
            mstore(add(size, 96), s)

            // NOTE: we can reuse the request memory because we deal with
            //       the return code
            ret := call(3000, 1, 0, size, 128, size, 32)
            addr := mload(size)
        }
  
        return (ret, addr);
    }

    // the following function has been written by Alex Beregszaszi (@axic), use it under the terms of the MIT license
    function ecrecovery(bytes32 hash, bytes sig) internal returns (bool, address) {
        bytes32 r;
        bytes32 s;
        uint8 v;

        if (sig.length != 65)
          return (false, 0);

        // The signature format is a compact form of:
        //   {bytes32 r}{bytes32 s}{uint8 v}
        // Compact means, uint8 is not padded to 32 bytes.
        assembly {
            r := mload(add(sig, 32))
            s := mload(add(sig, 64))

            // Here we are loading the last 32 bytes. We exploit the fact that
            // 'mload' will pad with zeroes if we overread.
            // There is no 'mload8' to do this, but that would be nicer.
            v := byte(0, mload(add(sig, 96)))

            // Alternative solution:
            // 'byte' is not working due to the Solidity parser, so lets
            // use the second best option, 'and'
            // v := and(mload(add(sig, 65)), 255)
        }

        // albeit non-transactional signatures are not specified by the YP, one would expect it
        // to match the YP range of [27, 28]
        //
        // geth uses [0, 1] and some clients have followed. This might change, see:
        //  https://github.com/ethereum/go-ethereum/issues/2053
        if (v < 27)
          v += 27;

        if (v != 27 && v != 28)
            return (false, 0);

        return safer_ecrecover(hash, v, r, s);
    }
        
}
// </ORACLIZE_API>

/*
 * @title String & slice utility library for Solidity contracts.
 * @author Nick Johnson <[email protected]>
 *
 * @dev Functionality in this library is largely implemented using an
 *      abstraction called a 'slice'. A slice represents a part of a string -
 *      anything from the entire string to a single character, or even no
 *      characters at all (a 0-length slice). Since a slice only has to specify
 *      an offset and a length, copying and manipulating slices is a lot less
 *      expensive than copying and manipulating the strings they reference.
 *
 *      To further reduce gas costs, most functions on slice that need to return
 *      a slice modify the original one instead of allocating a new one; for
 *      instance, `s.split(".")` will return the text up to the first '.',
 *      modifying s to only contain the remainder of the string after the '.'.
 *      In situations where you do not want to modify the original slice, you
 *      can make a copy first with `.copy()`, for example:
 *      `s.copy().split(".")`. Try and avoid using this idiom in loops; since
 *      Solidity has no memory management, it will result in allocating many
 *      short-lived slices that are later discarded.
 *
 *      Functions that return two slices come in two versions: a non-allocating
 *      version that takes the second slice as an argument, modifying it in
 *      place, and an allocating version that allocates and returns the second
 *      slice; see `nextRune` for example.
 *
 *      Functions that have to copy string data will return strings rather than
 *      slices; these can be cast back to slices for further processing if
 *      required.
 *
 *      For convenience, some functions are provided with non-modifying
 *      variants that create a new slice and return both; for instance,
 *      `s.splitNew('.')` leaves s unmodified, and returns two values
 *      corresponding to the left and right parts of the string.
 */
library strings {
    struct slice {
        uint _len;
        uint _ptr;
    }

    function memcpy(uint dest, uint src, uint len) private {
        // Copy word-length chunks while possible
        for(; len >= 32; len -= 32) {
            assembly {
                mstore(dest, mload(src))
            }
            dest += 32;
            src += 32;
        }

        // Copy remaining bytes
        uint mask = 256 ** (32 - len) - 1;
        assembly {
            let srcpart := and(mload(src), not(mask))
            let destpart := and(mload(dest), mask)
            mstore(dest, or(destpart, srcpart))
        }
    }

    /*
     * @dev Returns a slice containing the entire string.
     * @param self The string to make a slice from.
     * @return A newly allocated slice containing the entire string.
     */
    function toSlice(string self) internal returns (slice) {
        uint ptr;
        assembly {
            ptr := add(self, 0x20)
        }
        return slice(bytes(self).length, ptr);
    }

    /*
     * @dev Returns the length of a null-terminated bytes32 string.
     * @param self The value to find the length of.
     * @return The length of the string, from 0 to 32.
     */
    function len(bytes32 self) internal returns (uint) {
        uint ret;
        if (self == 0)
            return 0;
        if (self & 0xffffffffffffffffffffffffffffffff == 0) {
            ret += 16;
            self = bytes32(uint(self) / 0x100000000000000000000000000000000);
        }
        if (self & 0xffffffffffffffff == 0) {
            ret += 8;
            self = bytes32(uint(self) / 0x10000000000000000);
        }
        if (self & 0xffffffff == 0) {
            ret += 4;
            self = bytes32(uint(self) / 0x100000000);
        }
        if (self & 0xffff == 0) {
            ret += 2;
            self = bytes32(uint(self) / 0x10000);
        }
        if (self & 0xff == 0) {
            ret += 1;
        }
        return 32 - ret;
    }

    /*
     * @dev Returns a slice containing the entire bytes32, interpreted as a
     *      null-termintaed utf-8 string.
     * @param self The bytes32 value to convert to a slice.
     * @return A new slice containing the value of the input argument up to the
     *         first null.
     */
    function toSliceB32(bytes32 self) internal returns (slice ret) {
        // Allocate space for `self` in memory, copy it there, and point ret at it
        assembly {
            let ptr := mload(0x40)
            mstore(0x40, add(ptr, 0x20))
            mstore(ptr, self)
            mstore(add(ret, 0x20), ptr)
        }
        ret._len = len(self);
    }

    /*
     * @dev Returns a new slice containing the same data as the current slice.
     * @param self The slice to copy.
     * @return A new slice containing the same data as `self`.
     */
    function copy(slice self) internal returns (slice) {
        return slice(self._len, self._ptr);
    }

    /*
     * @dev Copies a slice to a new string.
     * @param self The slice to copy.
     * @return A newly allocated string containing the slice's text.
     */
    function toString(slice self) internal returns (string) {
        var ret = new string(self._len);
        uint retptr;
        assembly { retptr := add(ret, 32) }

        memcpy(retptr, self._ptr, self._len);
        return ret;
    }

    /*
     * @dev Returns the length in runes of the slice. Note that this operation
     *      takes time proportional to the length of the slice; avoid using it
     *      in loops, and call `slice.empty()` if you only need to know whether
     *      the slice is empty or not.
     * @param self The slice to operate on.
     * @return The length of the slice in runes.
     */
    function len(slice self) internal returns (uint) {
        // Starting at ptr-31 means the LSB will be the byte we care about
        var ptr = self._ptr - 31;
        var end = ptr + self._len;
        for (uint len = 0; ptr < end; len++) {
            uint8 b;
            assembly { b := and(mload(ptr), 0xFF) }
            if (b < 0x80) {
                ptr += 1;
            } else if(b < 0xE0) {
                ptr += 2;
            } else if(b < 0xF0) {
                ptr += 3;
            } else if(b < 0xF8) {
                ptr += 4;
            } else if(b < 0xFC) {
                ptr += 5;
            } else {
                ptr += 6;
            }
        }
        return len;
    }

    /*
     * @dev Returns true if the slice is empty (has a length of 0).
     * @param self The slice to operate on.
     * @return True if the slice is empty, False otherwise.
     */
    function empty(slice self) internal returns (bool) {
        return self._len == 0;
    }

    /*
     * @dev Returns a positive number if `other` comes lexicographically after
     *      `self`, a negative number if it comes before, or zero if the
     *      contents of the two slices are equal. Comparison is done per-rune,
     *      on unicode codepoints.
     * @param self The first slice to compare.
     * @param other The second slice to compare.
     * @return The result of the comparison.
     */
    function compare(slice self, slice other) internal returns (int) {
        uint shortest = self._len;
        if (other._len < self._len)
            shortest = other._len;

        var selfptr = self._ptr;
        var otherptr = other._ptr;
        for (uint idx = 0; idx < shortest; idx += 32) {
            uint a;
            uint b;
            assembly {
                a := mload(selfptr)
                b := mload(otherptr)
            }
            if (a != b) {
                // Mask out irrelevant bytes and check again
                uint mask = ~(2 ** (8 * (32 - shortest + idx)) - 1);
                var diff = (a & mask) - (b & mask);
                if (diff != 0)
                    return int(diff);
            }
            selfptr += 32;
            otherptr += 32;
        }
        return int(self._len) - int(other._len);
    }

    /*
     * @dev Returns true if the two slices contain the same text.
     * @param self The first slice to compare.
     * @param self The second slice to compare.
     * @return True if the slices are equal, false otherwise.
     */
    function equals(slice self, slice other) internal returns (bool) {
        return compare(self, other) == 0;
    }

    /*
     * @dev Extracts the first rune in the slice into `rune`, advancing the
     *      slice to point to the next rune and returning `self`.
     * @param self The slice to operate on.
     * @param rune The slice that will contain the first rune.
     * @return `rune`.
     */
    function nextRune(slice self, slice rune) internal returns (slice) {
        rune._ptr = self._ptr;

        if (self._len == 0) {
            rune._len = 0;
            return rune;
        }

        uint len;
        uint b;
        // Load the first byte of the rune into the LSBs of b
        assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) }
        if (b < 0x80) {
            len = 1;
        } else if(b < 0xE0) {
            len = 2;
        } else if(b < 0xF0) {
            len = 3;
        } else {
            len = 4;
        }

        // Check for truncated codepoints
        if (len > self._len) {
            rune._len = self._len;
            self._ptr += self._len;
            self._len = 0;
            return rune;
        }

        self._ptr += len;
        self._len -= len;
        rune._len = len;
        return rune;
    }

    /*
     * @dev Returns the first rune in the slice, advancing the slice to point
     *      to the next rune.
     * @param self The slice to operate on.
     * @return A slice containing only the first rune from `self`.
     */
    function nextRune(slice self) internal returns (slice ret) {
        nextRune(self, ret);
    }

    /*
     * @dev Returns the number of the first codepoint in the slice.
     * @param self The slice to operate on.
     * @return The number of the first codepoint in the slice.
     */
    function ord(slice self) internal returns (uint ret) {
        if (self._len == 0) {
            return 0;
        }

        uint word;
        uint len;
        uint div = 2 ** 248;

        // Load the rune into the MSBs of b
        assembly { word:= mload(mload(add(self, 32))) }
        var b = word / div;
        if (b < 0x80) {
            ret = b;
            len = 1;
        } else if(b < 0xE0) {
            ret = b & 0x1F;
            len = 2;
        } else if(b < 0xF0) {
            ret = b & 0x0F;
            len = 3;
        } else {
            ret = b & 0x07;
            len = 4;
        }

        // Check for truncated codepoints
        if (len > self._len) {
            return 0;
        }

        for (uint i = 1; i < len; i++) {
            div = div / 256;
            b = (word / div) & 0xFF;
            if (b & 0xC0 != 0x80) {
                // Invalid UTF-8 sequence
                return 0;
            }
            ret = (ret * 64) | (b & 0x3F);
        }

        return ret;
    }

    /*
     * @dev Returns the keccak-256 hash of the slice.
     * @param self The slice to hash.
     * @return The hash of the slice.
     */
    function keccak(slice self) internal returns (bytes32 ret) {
        assembly {
            ret := sha3(mload(add(self, 32)), mload(self))
        }
    }

    /*
     * @dev Returns true if `self` starts with `needle`.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return True if the slice starts with the provided text, false otherwise.
     */
    function startsWith(slice self, slice needle) internal returns (bool) {
        if (self._len < needle._len) {
            return false;
        }

        if (self._ptr == needle._ptr) {
            return true;
        }

        bool equal;
        assembly {
            let len := mload(needle)
            let selfptr := mload(add(self, 0x20))
            let needleptr := mload(add(needle, 0x20))
            equal := eq(sha3(selfptr, len), sha3(needleptr, len))
        }
        return equal;
    }

    /*
     * @dev If `self` starts with `needle`, `needle` is removed from the
     *      beginning of `self`. Otherwise, `self` is unmodified.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return `self`
     */
    function beyond(slice self, slice needle) internal returns (slice) {
        if (self._len < needle._len) {
            return self;
        }

        bool equal = true;
        if (self._ptr != needle._ptr) {
            assembly {
                let len := mload(needle)
                let selfptr := mload(add(self, 0x20))
                let needleptr := mload(add(needle, 0x20))
                equal := eq(sha3(selfptr, len), sha3(needleptr, len))
            }
        }

        if (equal) {
            self._len -= needle._len;
            self._ptr += needle._len;
        }

        return self;
    }

    /*
     * @dev Returns true if the slice ends with `needle`.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return True if the slice starts with the provided text, false otherwise.
     */
    function endsWith(slice self, slice needle) internal returns (bool) {
        if (self._len < needle._len) {
            return false;
        }

        var selfptr = self._ptr + self._len - needle._len;

        if (selfptr == needle._ptr) {
            return true;
        }

        bool equal;
        assembly {
            let len := mload(needle)
            let needleptr := mload(add(needle, 0x20))
            equal := eq(sha3(selfptr, len), sha3(needleptr, len))
        }

        return equal;
    }

    /*
     * @dev If `self` ends with `needle`, `needle` is removed from the
     *      end of `self`. Otherwise, `self` is unmodified.
     * @param self The slice to operate on.
     * @param needle The slice to search for.
     * @return `self`
     */
    function until(slice self, slice needle) internal returns (slice) {
        if (self._len < needle._len) {
            return self;
        }

        var selfptr = self._ptr + self._len - needle._len;
        bool equal = true;
        if (selfptr != needle._ptr) {
            assembly {
                let len := mload(needle)
                let needleptr := mload(add(needle, 0x20))
                equal := eq(sha3(selfptr, len), sha3(needleptr, len))
            }
        }

        if (equal) {
            self._len -= needle._len;
        }

        return self;
    }

    // Returns the memory address of the first byte of the first occurrence of
    // `needle` in `self`, or the first byte after `self` if not found.
    function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private returns (uint) {
        uint ptr;
        uint idx;

        if (needlelen <= selflen) {
            if (needlelen <= 32) {
                // Optimized assembly for 68 gas per byte on short strings
                assembly {
                    let mask := not(sub(exp(2, mul(8, sub(32, needlelen))), 1))
                    let needledata := and(mload(needleptr), mask)
                    let end := add(selfptr, sub(selflen, needlelen))
                    ptr := selfptr
                    loop:
                    jumpi(exit, eq(and(mload(ptr), mask), needledata))
                    ptr := add(ptr, 1)
                    jumpi(loop, lt(sub(ptr, 1), end))
                    ptr := add(selfptr, selflen)
                    exit:
                }
                return ptr;
            } else {
                // For long needles, use hashing
                bytes32 hash;
                assembly { hash := sha3(needleptr, needlelen) }
                ptr = selfptr;
                for (idx = 0; idx <= selflen - needlelen; idx++) {
                    bytes32 testHash;
                    assembly { testHash := sha3(ptr, needlelen) }
                    if (hash == testHash)
                        return ptr;
                    ptr += 1;
                }
            }
        }
        return selfptr + selflen;
    }

    // Returns the memory address of the first byte after the last occurrence of
    // `needle` in `self`, or the address of `self` if not found.
    function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private returns (uint) {
        uint ptr;

        if (needlelen <= selflen) {
            if (needlelen <= 32) {
                // Optimized assembly for 69 gas per byte on short strings
                assembly {
                    let mask := not(sub(exp(2, mul(8, sub(32, needlelen))), 1))
                    let needledata := and(mload(needleptr), mask)
                    ptr := add(selfptr, sub(selflen, needlelen))
                    loop:
                    jumpi(ret, eq(and(mload(ptr), mask), needledata))
                    ptr := sub(ptr, 1)
                    jumpi(loop, gt(add(ptr, 1), selfptr))
                    ptr := selfptr
                    jump(exit)
                    ret:
                    ptr := add(ptr, needlelen)
                    exit:
                }
                return ptr;
            } else {
                // For long needles, use hashing
                bytes32 hash;
                assembly { hash := sha3(needleptr, needlelen) }
                ptr = selfptr + (selflen - needlelen);
                while (ptr >= selfptr) {
                    bytes32 testHash;
                    assembly { testHash := sha3(ptr, needlelen) }
                    if (hash == testHash)
                        return ptr + needlelen;
                    ptr -= 1;
                }
            }
        }
        return selfptr;
    }

    /*
     * @dev Modifies `self` to contain everything from the first occurrence of
     *      `needle` to the end of the slice. `self` is set to the empty slice
     *      if `needle` is not found.
     * @param self The slice to search and modify.
     * @param needle The text to search for.
     * @return `self`.
     */
    function find(slice self, slice needle) internal returns (slice) {
        uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
        self._len -= ptr - self._ptr;
        self._ptr = ptr;
        return self;
    }

    /*
     * @dev Modifies `self` to contain the part of the string from the start of
     *      `self` to the end of the first occurrence of `needle`. If `needle`
     *      is not found, `self` is set to the empty slice.
     * @param self The slice to search and modify.
     * @param needle The text to search for.
     * @return `self`.
     */
    function rfind(slice self, slice needle) internal returns (slice) {
        uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
        self._len = ptr - self._ptr;
        return self;
    }

    /*
     * @dev Splits the slice, setting `self` to everything after the first
     *      occurrence of `needle`, and `token` to everything before it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and `token` is set to the entirety of `self`.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @param token An output parameter to which the first token is written.
     * @return `token`.
     */
    function split(slice self, slice needle, slice token) internal returns (slice) {
        uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr);
        token._ptr = self._ptr;
        token._len = ptr - self._ptr;
        if (ptr == self._ptr + self._len) {
            // Not found
            self._len = 0;
        } else {
            self._len -= token._len + needle._len;
            self._ptr = ptr + needle._len;
        }
        return token;
    }

    /*
     * @dev Splits the slice, setting `self` to everything after the first
     *      occurrence of `needle`, and returning everything before it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and the entirety of `self` is returned.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @return The part of `self` up to the first occurrence of `delim`.
     */
    function split(slice self, slice needle) internal returns (slice token) {
        split(self, needle, token);
    }

    /*
     * @dev Splits the slice, setting `self` to everything before the last
     *      occurrence of `needle`, and `token` to everything after it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and `token` is set to the entirety of `self`.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @param token An output parameter to which the first token is written.
     * @return `token`.
     */
    function rsplit(slice self, slice needle, slice token) internal returns (slice) {
        uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr);
        token._ptr = ptr;
        token._len = self._len - (ptr - self._ptr);
        if (ptr == self._ptr) {
            // Not found
            self._len = 0;
        } else {
            self._len -= token._len + needle._len;
        }
        return token;
    }

    /*
     * @dev Splits the slice, setting `self` to everything before the last
     *      occurrence of `needle`, and returning everything after it. If
     *      `needle` does not occur in `self`, `self` is set to the empty slice,
     *      and the entirety of `self` is returned.
     * @param self The slice to split.
     * @param needle The text to search for in `self`.
     * @return The part of `self` after the last occurrence of `delim`.
     */
    function rsplit(slice self, slice needle) internal returns (slice token) {
        rsplit(self, needle, token);
    }

    /*
     * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`.
     * @param self The slice to search.
     * @param needle The text to search for in `self`.
     * @return The number of occurrences of `needle` found in `self`.
     */
    function count(slice self, slice needle) internal returns (uint count) {
        uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len;
        while (ptr <= self._ptr + self._len) {
            count++;
            ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len;
        }
    }

    /*
     * @dev Returns True if `self` contains `needle`.
     * @param self The slice to search.
     * @param needle The text to search for in `self`.
     * @return True if `needle` is found in `self`, false otherwise.
     */
    function contains(slice self, slice needle) internal returns (bool) {
        return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr;
    }

    /*
     * @dev Returns a newly allocated string containing the concatenation of
     *      `self` and `other`.
     * @param self The first slice to concatenate.
     * @param other The second slice to concatenate.
     * @return The concatenation of the two strings.
     */
    function concat(slice self, slice other) internal returns (string) {
        var ret = new string(self._len + other._len);
        uint retptr;
        assembly { retptr := add(ret, 32) }
        memcpy(retptr, self._ptr, self._len);
        memcpy(retptr + self._len, other._ptr, other._len);
        return ret;
    }

    /*
     * @dev Joins an array of slices, using `self` as a delimiter, returning a
     *      newly allocated string.
     * @param self The delimiter to use.
     * @param parts A list of slices to join.
     * @return A newly allocated string containing all the slices in `parts`,
     *         joined with `self`.
     */
    function join(slice self, slice[] parts) internal returns (string) {
        if (parts.length == 0)
            return "";

        uint len = self._len * (parts.length - 1);
        for(uint i = 0; i < parts.length; i++)
            len += parts[i]._len;

        var ret = new string(len);
        uint retptr;
        assembly { retptr := add(ret, 32) }

        for(i = 0; i < parts.length; i++) {
            memcpy(retptr, parts[i]._ptr, parts[i]._len);
            retptr += parts[i]._len;
            if (i < parts.length - 1) {
                memcpy(retptr, self._ptr, self._len);
                retptr += self._len;
            }
        }

        return ret;
    }
}


contract DSSafeAddSub {
    function safeToAdd(uint a, uint b) internal returns (bool) {
        return (a + b >= a);
    }
    function safeAdd(uint a, uint b) internal returns (uint) {
        if (!safeToAdd(a, b)) throw;
        return a + b;
    }

    function safeToSubtract(uint a, uint b) internal returns (bool) {
        return (b <= a);
    }

    function safeSub(uint a, uint b) internal returns (uint) {
        if (!safeToSubtract(a, b)) throw;
        return a - b;
    } 
}



contract Etheroll is usingOraclize, DSSafeAddSub {
    
     using strings for *;

    /*
     * checks player profit, bet size and player number is within range
    */
    modifier betIsValid(uint _betSize, uint _playerNumber) {      
        if(((((_betSize * (100-(safeSub(_playerNumber,1)))) / (safeSub(_playerNumber,1))+_betSize))*houseEdge/houseEdgeDivisor)-_betSize > maxProfit || _betSize < minBet || _playerNumber < minNumber || _playerNumber > maxNumber) throw;        
		_;
    }

    /*
     * checks game is currently active
    */
    modifier gameIsActive {
        if(gamePaused == true) throw;
		_;
    }    

    /*
     * checks payouts are currently active
    */
    modifier payoutsAreActive {
        if(payoutsPaused == true) throw;
		_;
    }    

    /*
     * checks only Oraclize address is calling
    */
    modifier onlyOraclize {
        if (msg.sender != oraclize_cbAddress()) throw;
        _;
    }

    /*
     * checks only owner address is calling
    */
    modifier onlyOwner {
         if (msg.sender != owner) throw;
         _;
    }

    /*
     * checks only treasury address is calling
    */
    modifier onlyTreasury {
         if (msg.sender != treasury) throw;
         _;
    }    

    /*
     * game vars
    */ 
    uint constant public maxProfitDivisor = 1000000;
    uint constant public houseEdgeDivisor = 1000;    
    uint constant public maxNumber = 99; 
    uint constant public minNumber = 2;
	bool public gamePaused;
    uint32 public gasForOraclize;
    address public owner;
    bool public payoutsPaused; 
    address public treasury;
    uint public contractBalance;
    uint public houseEdge;     
    uint public maxProfit;   
    uint public maxProfitAsPercentOfHouse;                    
    uint public minBet; 
    //init discontinued contract data         
    int public totalBets = 138472;
    uint public maxPendingPayouts;
    //init discontinued contract data         
    uint public totalWeiWon = 61779454774685332087870;
    //init discontinued contract data  
    uint public totalWeiWagered = 213696169063866525745355;    

    /*
     * player vars
    */
    mapping (bytes32 => address) playerAddress;
    mapping (bytes32 => address) playerTempAddress;
    mapping (bytes32 => bytes32) playerBetId;
    mapping (bytes32 => uint) playerBetValue;
    mapping (bytes32 => uint) playerTempBetValue;       
    mapping (bytes32 => uint) playerDieResult;
    mapping (bytes32 => uint) playerNumber;
    mapping (address => uint) playerPendingWithdrawals;      
    mapping (bytes32 => uint) playerProfit;
    mapping (bytes32 => uint) playerTempReward;           

    /*
     * events
    */
    /* log bets + output to web3 for precise 'payout on win' field in UI */
    event LogBet(bytes32 indexed BetID, address indexed PlayerAddress, uint indexed RewardValue, uint ProfitValue, uint BetValue, uint PlayerNumber);      
    /* output to web3 UI on bet result*/
    /* Status: 0=lose, 1=win, 2=win + failed send, 3=refund, 4=refund + failed send*/
	event LogResult(uint indexed ResultSerialNumber, bytes32 indexed BetID, address indexed PlayerAddress, uint PlayerNumber, uint DiceResult, uint Value, int Status, bytes Proof);   
    /* log manual refunds */
    event LogRefund(bytes32 indexed BetID, address indexed PlayerAddress, uint indexed RefundValue);
    /* log owner transfers */
    event LogOwnerTransfer(address indexed SentToAddress, uint indexed AmountTransferred);               


    /*
     * init
    */
    function Etheroll() {

        owner = msg.sender;
        treasury = msg.sender;
        oraclize_setNetwork(networkID_auto);        
        /* use TLSNotary for oraclize call */
        oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
        /* init 990 = 99% (1% houseEdge)*/
        ownerSetHouseEdge(990);
        /* init 10,000 = 1%  */
        ownerSetMaxProfitAsPercentOfHouse(10000);
        /* init min bet (0.1 ether) */
        ownerSetMinBet(100000000000000000);        
        /* init gas for oraclize */        
        gasForOraclize = 235000;        

    }

    /*
     * public function
     * player submit bet
     * only if game is active & bet is valid can query oraclize and set player vars     
    */
    function playerRollDice(uint rollUnder) public 
        payable
        gameIsActive
        betIsValid(msg.value, rollUnder)
	{       

        /*
        * assign partially encrypted query to oraclize
        * only the apiKey is encrypted 
        * integer query is in plain text
        */               
        bytes32 rngId = oraclize_query("nested", "[URL] ['json(https://api.random.org/json-rpc/1/invoke).result.random[\"serialNumber\",\"data\"]', '\\n{\"jsonrpc\":\"2.0\",\"method\":\"generateSignedIntegers\",\"params\":{\"apiKey\":${[decrypt] BK8UxIEHLaY8JEQDl1sjK73+fDZaze2oRyp3OzgI3Q1Xbz7xFGJ7pKtmKXdyiML5e26HYeoxO4fOFoVQ7iHBVd3Olm0gowJ60oIiC+OfrOB+dsoobaztcFmEKMgh7bLXREL9ORAb7rUD4DVlH4NpxQ4mfkgKvtE=},\"n\":1,\"min\":1,\"max\":100,\"replacement\":true,\"base\":10${[identity] \"}\"},\"id\":1${[identity] \"}\"}']", gasForOraclize);
        	    
        /* map bet id to this oraclize query */
		playerBetId[rngId] = rngId;
        /* map player lucky number to this oraclize query */
		playerNumber[rngId] = rollUnder;
        /* map value of wager to this oraclize query */
        playerBetValue[rngId] = msg.value;
        /* map player address to this oraclize query */
        playerAddress[rngId] = msg.sender;
        /* safely map player profit to this oraclize query */                     
        playerProfit[rngId] = ((((msg.value * (100-(safeSub(rollUnder,1)))) / (safeSub(rollUnder,1))+msg.value))*houseEdge/houseEdgeDivisor)-msg.value;        
        /* safely increase maxPendingPayouts liability - calc all pending payouts under assumption they win */
        maxPendingPayouts = safeAdd(maxPendingPayouts, playerProfit[rngId]);
        /* check contract can payout on win */
        if(maxPendingPayouts >= contractBalance) throw;
        /* provides accurate numbers for web3 and allows for manual refunds in case of no oraclize __callback */
        LogBet(playerBetId[rngId], playerAddress[rngId], safeAdd(playerBetValue[rngId], playerProfit[rngId]), playerProfit[rngId], playerBetValue[rngId], playerNumber[rngId]);          

    }   
             

    /*
    * semi-public function - only oraclize can call
    */
    /*TLSNotary for oraclize call */
	function __callback(bytes32 myid, string result, bytes proof) public   
		onlyOraclize
		payoutsAreActive
	{  

        /* player address mapped to query id does not exist */
        if (playerAddress[myid]==0x0) throw;
        
        /* keep oraclize honest by retrieving the serialNumber from random.org result */
        var sl_result = result.toSlice();
        sl_result.beyond("[".toSlice()).until("]".toSlice());
        uint serialNumberOfResult = parseInt(sl_result.split(', '.toSlice()).toString());          

	    /* map result to player */
        playerDieResult[myid] = parseInt(sl_result.beyond("[".toSlice()).until("]".toSlice()).toString());
        
        /* get the playerAddress for this query id */
        playerTempAddress[myid] = playerAddress[myid];
        /* delete playerAddress for this query id */
        delete playerAddress[myid];

        /* map the playerProfit for this query id */
        playerTempReward[myid] = playerProfit[myid];
        /* set  playerProfit for this query id to 0 */
        playerProfit[myid] = 0; 

        /* safely reduce maxPendingPayouts liability */
        maxPendingPayouts = safeSub(maxPendingPayouts, playerTempReward[myid]);         

        /* map the playerBetValue for this query id */
        playerTempBetValue[myid] = playerBetValue[myid];
        /* set  playerBetValue for this query id to 0 */
        playerBetValue[myid] = 0; 

        /* total number of bets */
        totalBets += 1;

        /* total wagered */
        totalWeiWagered += playerTempBetValue[myid];                                                           

        /*
        * refund
        * if result is 0 result is empty or no proof refund original bet value
        * if refund fails save refund value to playerPendingWithdrawals
        */
        if(playerDieResult[myid]==0 || bytes(result).length == 0 || bytes(proof).length == 0){                                                     

             LogResult(serialNumberOfResult, playerBetId[myid], playerTempAddress[myid], playerNumber[myid], playerDieResult[myid], playerTempBetValue[myid], 3, proof);            

            /*
            * send refund - external call to an untrusted contract
            * if send fails map refund value to playerPendingWithdrawals[address]
            * for withdrawal later via playerWithdrawPendingTransactions
            */
            if(!playerTempAddress[myid].send(playerTempBetValue[myid])){
                LogResult(serialNumberOfResult, playerBetId[myid], playerTempAddress[myid], playerNumber[myid], playerDieResult[myid], playerTempBetValue[myid], 4, proof);              
                /* if send failed let player withdraw via playerWithdrawPendingTransactions */
                playerPendingWithdrawals[playerTempAddress[myid]] = safeAdd(playerPendingWithdrawals[playerTempAddress[myid]], playerTempBetValue[myid]);                        
            }

            return;
        }

        /*
        * pay winner
        * update contract balance to calculate new max bet
        * send reward
        * if send of reward fails save value to playerPendingWithdrawals        
        */
        if(playerDieResult[myid] < playerNumber[myid]){ 

            /* safely reduce contract balance by player profit */
            contractBalance = safeSub(contractBalance, playerTempReward[myid]); 

            /* update total wei won */
            totalWeiWon = safeAdd(totalWeiWon, playerTempReward[myid]);              

            /* safely calculate payout via profit plus original wager */
            playerTempReward[myid] = safeAdd(playerTempReward[myid], playerTempBetValue[myid]); 

            LogResult(serialNumberOfResult, playerBetId[myid], playerTempAddress[myid], playerNumber[myid], playerDieResult[myid], playerTempReward[myid], 1, proof);                            

            /* update maximum profit */
            setMaxProfit();
            
            /*
            * send win - external call to an untrusted contract
            * if send fails map reward value to playerPendingWithdrawals[address]
            * for withdrawal later via playerWithdrawPendingTransactions
            */
            if(!playerTempAddress[myid].send(playerTempReward[myid])){
                LogResult(serialNumberOfResult, playerBetId[myid], playerTempAddress[myid], playerNumber[myid], playerDieResult[myid], playerTempReward[myid], 2, proof);                   
                /* if send failed let player withdraw via playerWithdrawPendingTransactions */
                playerPendingWithdrawals[playerTempAddress[myid]] = safeAdd(playerPendingWithdrawals[playerTempAddress[myid]], playerTempReward[myid]);                               
            }

            return;

        }

        /*
        * no win
        * send 1 wei to a losing bet
        * update contract balance to calculate new max bet
        */
        if(playerDieResult[myid] >= playerNumber[myid]){

            LogResult(serialNumberOfResult, playerBetId[myid], playerTempAddress[myid], playerNumber[myid], playerDieResult[myid], playerTempBetValue[myid], 0, proof);                                

            /*  
            *  safe adjust contractBalance
            *  setMaxProfit
            *  send 1 wei to losing bet
            */
            contractBalance = safeAdd(contractBalance, (playerTempBetValue[myid]-1));                                                                         

            /* update maximum profit */
            setMaxProfit(); 

            /*
            * send 1 wei - external call to an untrusted contract                  
            */
            if(!playerTempAddress[myid].send(1)){
                /* if send failed let player withdraw via playerWithdrawPendingTransactions */                
               playerPendingWithdrawals[playerTempAddress[myid]] = safeAdd(playerPendingWithdrawals[playerTempAddress[myid]], 1);                                
            }                                   

            return;

        }

    }
    
    /*
    * public function
    * in case of a failed refund or win send
    */
    function playerWithdrawPendingTransactions() public 
        payoutsAreActive
        returns (bool)
     {
        uint withdrawAmount = playerPendingWithdrawals[msg.sender];
        playerPendingWithdrawals[msg.sender] = 0;
        /* external call to untrusted contract */
        if (msg.sender.call.value(withdrawAmount)()) {
            return true;
        } else {
            /* if send failed revert playerPendingWithdrawals[msg.sender] = 0; */
            /* player can try to withdraw again later */
            playerPendingWithdrawals[msg.sender] = withdrawAmount;
            return false;
        }
    }

    /* check for pending withdrawals  */
    function playerGetPendingTxByAddress(address addressToCheck) public constant returns (uint) {
        return playerPendingWithdrawals[addressToCheck];
    }

    /*
    * internal function
    * sets max profit
    */
    function setMaxProfit() internal {
        maxProfit = (contractBalance*maxProfitAsPercentOfHouse)/maxProfitDivisor;  
    }   

    /*
    * owner/treasury address only functions
    */
    function ()
        payable
        onlyTreasury
    {
        /* safely update contract balance */
        contractBalance = safeAdd(contractBalance, msg.value);        
        /* update the maximum profit */
        setMaxProfit();
    } 

    /* set gas for oraclize query */
    function ownerSetOraclizeSafeGas(uint32 newSafeGasToOraclize) public 
		onlyOwner
	{
    	gasForOraclize = newSafeGasToOraclize;
    }

    /* only owner adjust contract balance variable (only used for max profit calc) */
    function ownerUpdateContractBalance(uint newContractBalanceInWei) public 
		onlyOwner
    {        
       contractBalance = newContractBalanceInWei;
    }    

    /* only owner address can set houseEdge */
    function ownerSetHouseEdge(uint newHouseEdge) public 
		onlyOwner
    {
        houseEdge = newHouseEdge;
    }

    /* only owner address can set maxProfitAsPercentOfHouse */
    function ownerSetMaxProfitAsPercentOfHouse(uint newMaxProfitAsPercent) public 
		onlyOwner
    {
        /* restrict each bet to a maximum profit of 1% contractBalance */
        if(newMaxProfitAsPercent > 10000) throw;
        maxProfitAsPercentOfHouse = newMaxProfitAsPercent;
        setMaxProfit();
    }

    /* only owner address can set minBet */
    function ownerSetMinBet(uint newMinimumBet) public 
		onlyOwner
    {
        minBet = newMinimumBet;
    }       

    /* only owner address can transfer ether */
    function ownerTransferEther(address sendTo, uint amount) public 
		onlyOwner
    {        
        /* safely update contract balance when sending out funds*/
        contractBalance = safeSub(contractBalance, amount);		
        /* update max profit */
        setMaxProfit();
        if(!sendTo.send(amount)) throw;
        LogOwnerTransfer(sendTo, amount); 
    }

    /* only owner address can do manual refund
    * used only if bet placed + oraclize failed to __callback
    * filter LogBet by address and/or playerBetId:
    * LogBet(playerBetId[rngId], playerAddress[rngId], safeAdd(playerBetValue[rngId], playerProfit[rngId]), playerProfit[rngId], playerBetValue[rngId], playerNumber[rngId]);
    * check the following logs do not exist for playerBetId and/or playerAddress[rngId] before refunding:
    * LogResult or LogRefund
    * if LogResult exists player should use the withdraw pattern playerWithdrawPendingTransactions 
    */
    function ownerRefundPlayer(bytes32 originalPlayerBetId, address sendTo, uint originalPlayerProfit, uint originalPlayerBetValue) public 
		onlyOwner
    {        
        /* safely reduce pendingPayouts by playerProfit[rngId] */
        maxPendingPayouts = safeSub(maxPendingPayouts, originalPlayerProfit);
        /* send refund */
        if(!sendTo.send(originalPlayerBetValue)) throw;
        /* log refunds */
        LogRefund(originalPlayerBetId, sendTo, originalPlayerBetValue);        
    }    

    /* only owner address can set emergency pause #1 */
    function ownerPauseGame(bool newStatus) public 
		onlyOwner
    {
		gamePaused = newStatus;
    }

    /* only owner address can set emergency pause #2 */
    function ownerPausePayouts(bool newPayoutStatus) public 
		onlyOwner
    {
		payoutsPaused = newPayoutStatus;
    } 

    /* only owner address can set treasury address */
    function ownerSetTreasury(address newTreasury) public 
		onlyOwner
	{
        treasury = newTreasury;
    }         

    /* only owner address can set owner address */
    function ownerChangeOwner(address newOwner) public 
		onlyOwner
	{
        owner = newOwner;
    }

    /* only owner address can suicide - emergency */
    function ownerkill() public 
		onlyOwner
	{
		suicide(owner);
	}    


}

Contract Security Audit

Contract ABI

[{"constant":true,"inputs":[],"name":"totalWeiWon","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxProfitAsPercentOfHouse","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newHouseEdge","type":"uint256"}],"name":"ownerSetHouseEdge","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"myid","type":"bytes32"},{"name":"result","type":"string"}],"name":"__callback","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"payoutsPaused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newTreasury","type":"address"}],"name":"ownerSetTreasury","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"myid","type":"bytes32"},{"name":"result","type":"string"},{"name":"proof","type":"bytes"}],"name":"__callback","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"addressToCheck","type":"address"}],"name":"playerGetPendingTxByAddress","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newContractBalanceInWei","type":"uint256"}],"name":"ownerUpdateContractBalance","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxProfitDivisor","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newPayoutStatus","type":"bool"}],"name":"ownerPausePayouts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"ownerChangeOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"minNumber","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newMaxProfitAsPercent","type":"uint256"}],"name":"ownerSetMaxProfitAsPercentOfHouse","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"treasury","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalWeiWagered","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newMinimumBet","type":"uint256"}],"name":"ownerSetMinBet","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newStatus","type":"bool"}],"name":"ownerPauseGame","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"gasForOraclize","outputs":[{"name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"sendTo","type":"address"},{"name":"amount","type":"uint256"}],"name":"ownerTransferEther","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"contractBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"minBet","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"playerWithdrawPendingTransactions","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"maxProfit","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalBets","outputs":[{"name":"","type":"int256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"gamePaused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"originalPlayerBetId","type":"bytes32"},{"name":"sendTo","type":"address"},{"name":"originalPlayerProfit","type":"uint256"},{"name":"originalPlayerBetValue","type":"uint256"}],"name":"ownerRefundPlayer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newSafeGasToOraclize","type":"uint32"}],"name":"ownerSetOraclizeSafeGas","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"ownerkill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"houseEdge","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"rollUnder","type":"uint256"}],"name":"playerRollDice","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"houseEdgeDivisor","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxPendingPayouts","outputs":[{"name":"","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":true,"name":"BetID","type":"bytes32"},{"indexed":true,"name":"PlayerAddress","type":"address"},{"indexed":true,"name":"RewardValue","type":"uint256"},{"indexed":false,"name":"ProfitValue","type":"uint256"},{"indexed":false,"name":"BetValue","type":"uint256"},{"indexed":false,"name":"PlayerNumber","type":"uint256"}],"name":"LogBet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"ResultSerialNumber","type":"uint256"},{"indexed":true,"name":"BetID","type":"bytes32"},{"indexed":true,"name":"PlayerAddress","type":"address"},{"indexed":false,"name":"PlayerNumber","type":"uint256"},{"indexed":false,"name":"DiceResult","type":"uint256"},{"indexed":false,"name":"Value","type":"uint256"},{"indexed":false,"name":"Status","type":"int256"},{"indexed":false,"name":"Proof","type":"bytes"}],"name":"LogResult","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"BetID","type":"bytes32"},{"indexed":true,"name":"PlayerAddress","type":"address"},{"indexed":true,"name":"RefundValue","type":"uint256"}],"name":"LogRefund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"SentToAddress","type":"address"},{"indexed":true,"name":"AmountTransferred","type":"uint256"}],"name":"LogOwnerTransfer","type":"event"}]

606060405262021ce8600c55690d15122a0bff1d7b243e600e55692d407e16f0c22f9f00cb600f5534156200003357600080fd5b60058054602860020a60c860020a0319166501000000000033600160a060020a03169081029190911790915560068054600160a060020a03191690911790556200008c600064010000000062000137810262001e4e1704565b50620000c67f1100000000000000000000000000000000000000000000000000000000000000640100000000620025086200051982021704565b620000e16103de640100000000620006266200074682021704565b620000fc612710640100000000620011c66200077082021704565b6200011d67016345785d8a00006401000000006200121e620007c282021704565b6005805464ffffffff001916630395f800179055620008c0565b60008062000167731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed64010000000062001e4a620007ec82021704565b1115620001e95760008054600160a060020a031916731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed179055620001e060408051908101604052600b81527f6574685f6d61696e6e657400000000000000000000000000000000000000000060208201526401000000006200239b620007f082021704565b50600162000514565b60006200021873c03a2615d5efaf5f49f60b7bb6583eaec212fdf164010000000062001e4a620007ec82021704565b1115620002915760008054600160a060020a03191673c03a2615d5efaf5f49f60b7bb6583eaec212fdf1179055620001e060408051908101604052600c81527f6574685f726f707374656e33000000000000000000000000000000000000000060208201526401000000006200239b620007f082021704565b6000620002c073b7a07bcf2ba2f2703b24c0691b5278999c59ac7e64010000000062001e4a620007ec82021704565b1115620003395760008054600160a060020a03191673b7a07bcf2ba2f2703b24c0691b5278999c59ac7e179055620001e060408051908101604052600981527f6574685f6b6f76616e000000000000000000000000000000000000000000000060208201526401000000006200239b620007f082021704565b60006200036873146500cfd35b22e4a392fe0adc06de1a1368ed4864010000000062001e4a620007ec82021704565b1115620003e15760008054600160a060020a03191673146500cfd35b22e4a392fe0adc06de1a1368ed48179055620001e060408051908101604052600b81527f6574685f72696e6b65627900000000000000000000000000000000000000000060208201526401000000006200239b620007f082021704565b600062000410736f485c8bf6fc43ea212e93bbf8ce046c7f1cb47564010000000062001e4a620007ec82021704565b111562000446575060008054600160a060020a031916736f485c8bf6fc43ea212e93bbf8ce046c7f1cb475179055600162000514565b6000620004757320e12a1f859b3feae5fb2a0a32c18f5a65555bbf64010000000062001e4a620007ec82021704565b1115620004ab575060008054600160a060020a0319167320e12a1f859b3feae5fb2a0a32c18f5a65555bbf179055600162000514565b6000620004da7351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa64010000000062001e4a620007ec82021704565b111562000510575060008054600160a060020a0319167351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa179055600162000514565b5060005b919050565b600054600160a060020a031615806200055457506000546200055290600160a060020a031664010000000062001e4a620007ec82021704565b155b15620005765762000574600064010000000062001e4e6200013782021704565b505b60008054600160a060020a0316906338cc483190604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1515620005d957600080fd5b6102c65a03f11515620005eb57600080fd5b5050506040518051600154600160a060020a039081169116149050620006aa5760008054600160a060020a0316906338cc483190604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15156200066e57600080fd5b6102c65a03f115156200068057600080fd5b505050604051805160018054600160a060020a031916600160a060020a0392909216919091179055505b600154600160a060020a031663688dcfd7826040517c010000000000000000000000000000000000000000000000000000000063ffffffff84160281527fff000000000000000000000000000000000000000000000000000000000000009091166004820152602401600060405180830381600087803b15156200072d57600080fd5b6102c65a03f115156200073f57600080fd5b5050505b50565b60055433600160a060020a039081166501000000000090920416146200076b57600080fd5b600855565b60055433600160a060020a039081166501000000000090920416146200079557600080fd5b612710811115620007a557600080fd5b600a81905562000743640100000000620006086200080982021704565b60055433600160a060020a03908116650100000000009092041614620007e757600080fd5b600b55565b3b90565b6002818051620008059291602001906200081b565b5050565b600a54600754620f4240910204600955565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200085e57805160ff19168380011785556200088e565b828001600101855582156200088e579182015b828111156200088e57825182559160200191906001019062000871565b506200089c929150620008a0565b5090565b620008bd91905b808211156200089c5760008155600101620008a7565b90565b6128c080620008d06000396000f30060606040526004361061019d5763ffffffff60e060020a60003504166315c12d4d81146101d157806323214fab146101f6578063268d50fe1461020957806327dc297e1461021f578063301cf6e714610275578063313752421461029c57806338bbfa50146102bb5780633a4f6999146103535780633c314a91146103665780634025b5a81461038557806343c1598d1461039b5780634b7fcee7146103ae5780634f44728d146103c657806355b93031146103e55780635e968a49146103f857806361d027b31461040e578063666f4cad1461043d5780636cdf4c90146104505780636eacd48a146104665780637072a9771461047e5780637ac37d58146104aa5780638b7afe2e146104cc5780638da5cb5b146104df5780639619367d146104f2578063a5f4af3314610505578063b539cd5514610518578063befa1e2f1461052b578063c3de1ab91461053e578063cf832ce214610551578063d207e75714610579578063d263b7eb14610595578063d667dcd7146105a8578063dc6dd152146105bb578063e5c774de146105c6578063ed62f501146105d9575b60065433600160a060020a039081169116146101b857600080fd5b6101c4600754346105ec565b6007556101cf610608565b005b34156101dc57600080fd5b6101e461061a565b60405190815260200160405180910390f35b341561020157600080fd5b6101e4610620565b341561021457600080fd5b6101cf600435610626565b341561022a57600080fd5b6101cf600480359060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061064f95505050505050565b341561028057600080fd5b610288610681565b604051901515815260200160405180910390f35b34156102a757600080fd5b6101cf600160a060020a0360043516610691565b34156102c657600080fd5b6101cf600480359060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496506106d795505050505050565b341561035e57600080fd5b6101e46110b4565b341561037157600080fd5b6101e4600160a060020a03600435166110b9565b341561039057600080fd5b6101cf6004356110d8565b34156103a657600080fd5b6101e4611101565b34156103b957600080fd5b6101cf6004351515611108565b34156103d157600080fd5b6101cf600160a060020a0360043516611160565b34156103f057600080fd5b6101e46111c1565b341561040357600080fd5b6101cf6004356111c6565b341561041957600080fd5b610421611209565b604051600160a060020a03909116815260200160405180910390f35b341561044857600080fd5b6101e4611218565b341561045b57600080fd5b6101cf60043561121e565b341561047157600080fd5b6101cf6004351515611247565b341561048957600080fd5b61049161127e565b60405163ffffffff909116815260200160405180910390f35b34156104b557600080fd5b6101cf600160a060020a036004351660243561128f565b34156104d757600080fd5b6101e4611336565b34156104ea57600080fd5b61042161133c565b34156104fd57600080fd5b6101e4611354565b341561051057600080fd5b61028861135a565b341561052357600080fd5b6101e46113e8565b341561053657600080fd5b6101e46113ee565b341561054957600080fd5b6102886113f4565b341561055c57600080fd5b6101cf600435600160a060020a03602435166044356064356113fd565b341561058457600080fd5b6101cf63ffffffff6004351661149f565b34156105a057600080fd5b6101cf6114e5565b34156105b357600080fd5b6101e4611520565b6101cf600435611526565b34156105d157600080fd5b6101e4611783565b34156105e457600080fd5b6101e4611789565b60006105f8838361178f565b151561060357600080fd5b500190565b600a54600754620f4240910204600955565b600e5481565b600a5481565b60055433600160a060020a0390811665010000000000909204161461064a57600080fd5b600855565b61067d828260006040518059106106635750595b818152601f19601f830116810160200160405290506106d7565b5050565b60055460c860020a900460ff1681565b60055433600160a060020a039081166501000000000090920416146106b557600080fd5b60068054600160a060020a031916600160a060020a0392909216919091179055565b6106df612451565b60006106e9611796565b600160a060020a031633600160a060020a031614151561070857600080fd5b60055460c860020a900460ff1615156001141561072457600080fd5b600085815260106020526040902054600160a060020a0316151561074757600080fd5b61075084611937565b91506107e961079160408051908101604052600181527f5d000000000000000000000000000000000000000000000000000000000000006020820152611937565b6107dd6107d060408051908101604052600181527f5b000000000000000000000000000000000000000000000000000000000000006020820152611937565b859063ffffffff61195f16565b9063ffffffff6119cc16565b5061084661084161083c61082f60408051908101604052600281527f2c200000000000000000000000000000000000000000000000000000000000006020820152611937565b859063ffffffff611a3316565b611a46565b611a94565b90506108d961084161083c61088d60408051908101604052600181527f5d000000000000000000000000000000000000000000000000000000000000006020820152611937565b6107dd6108cc60408051908101604052600181527f5b000000000000000000000000000000000000000000000000000000000000006020820152611937565b879063ffffffff61195f16565b600086815260156020908152604080832093909355601081528282208054601183528484208054600160a060020a03909216600160a060020a0319928316179055815416905560188152828220805460199092529282209081559155600d5490546109449190611aa7565b600d55600085815260136020908152604080832080546014845282852090815590849055600c8054600101905554600f805490910190556015909152902054158061098e57508351155b8061099857508251155b15610c225760008581526011602090815260408083205460128352818420546016845282852054601585528386205460149095529483902054600160a060020a0390921694909386936000805160206126c183398151915293906003908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610a4a578082015183820152602001610a32565b50505050905090810190601f168015610a775780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a460008581526011602090815260408083205460149092529182902054600160a060020a039091169181156108fc02919051600060405180830381858888f193505050501515610c1d5760008581526011602090815260408083205460128352818420546016845282852054601585528386205460149095529483902054600160a060020a0390921694909386936000805160206126c183398151915293906004908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610b7e578082015183820152602001610b66565b50505050905090810190601f168015610bab5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a4600085815260116020908152604080832054600160a060020a031683526017825280832054888452601490925290912054610bf791906105ec565b600086815260116020908152604080832054600160a060020a0316835260179091529020555b6110ad565b6000858152601660209081526040808320546015909252909120541015610f0f57600754600086815260196020526040902054610c5f9190611aa7565b600755600e54600086815260196020526040902054610c7e91906105ec565b600e55600085815260196020908152604080832054601490925290912054610ca691906105ec565b600086815260196020818152604080842085905560118252808420546012835281852054601684528286205460158552958390205494909352600160a060020a031694919386936000805160206126c18339815191529391929091906001908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610d5a578082015183820152602001610d42565b50505050905090810190601f168015610d875780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a4610da0610608565b60008581526011602090815260408083205460199092529182902054600160a060020a039091169181156108fc02919051600060405180830381858888f193505050501515610c1d5760008581526011602090815260408083205460128352818420546016845282852054601585528386205460199095529483902054600160a060020a0390921694909386936000805160206126c183398151915293906002908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610e96578082015183820152602001610e7e565b50505050905090810190601f168015610ec35780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a4600085815260116020908152604080832054600160a060020a031683526017825280832054888452601990925290912054610bf791906105ec565b600085815260166020908152604080832054601590925290912054106110ad57600085815260116020908152604080832054601283528184205460168452828520546015855283862054601490955283862054600160a060020a0390931695919487946000805160206126c1833981519152949293919291908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610fdd578082015183820152602001610fc5565b50505050905090810190601f16801561100a5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a460075460008681526014602052604090205461103b9190600019016105ec565b600755611046610608565b60008581526011602052604080822054600160a060020a0316919060019051600060405180830381858888f193505050501515610c1d57600085815260116020908152604080832054600160a060020a031683526017909152902054610bf79060016105ec565b5050505050565b606381565b600160a060020a0381166000908152601760205260409020545b919050565b60055433600160a060020a039081166501000000000090920416146110fc57600080fd5b600755565b620f424081565b60055433600160a060020a0390811665010000000000909204161461112c57600080fd5b6005805491151560c860020a0279ff0000000000000000000000000000000000000000000000000019909216919091179055565b60055433600160a060020a0390811665010000000000909204161461118457600080fd5b60058054600160a060020a03909216650100000000000278ffffffffffffffffffffffffffffffffffffffff000000000019909216919091179055565b600281565b60055433600160a060020a039081166501000000000090920416146111ea57600080fd5b6127108111156111f957600080fd5b600a819055611206610608565b50565b600654600160a060020a031681565b600f5481565b60055433600160a060020a0390811665010000000000909204161461124257600080fd5b600b55565b60055433600160a060020a0390811665010000000000909204161461126b57600080fd5b6005805460ff1916911515919091179055565b600554610100900463ffffffff1681565b60055433600160a060020a039081166501000000000090920416146112b357600080fd5b6112bf60075482611aa7565b6007556112ca610608565b600160a060020a03821681156108fc0282604051600060405180830381858888f1935050505015156112fb57600080fd5b8082600160a060020a03167f42c501a185f41a8eb77b0a3e7b72a6435ea7aa752f8a1a0a13ca4628495eca9160405160405180910390a35050565b60075481565b600554650100000000009004600160a060020a031681565b600b5481565b600080600560199054906101000a900460ff16151560011515141561137e57600080fd5b50600160a060020a033316600081815260176020526040808220805492905590919082905160006040518083038185876187965a03f192505050156113c657600191506113e4565b600160a060020a033316600090815260176020526040812082905591505b5090565b60095481565b600c5481565b60055460ff1681565b60055433600160a060020a0390811665010000000000909204161461142157600080fd5b61142d600d5483611aa7565b600d55600160a060020a03831681156108fc0282604051600060405180830381858888f19350505050151561146157600080fd5b80600160a060020a038416857f7b6ccf85690b8ce1b7d21a94ca738803a9da7dc74e10140f269efa0d8d6fb85160405160405180910390a450505050565b60055433600160a060020a039081166501000000000090920416146114c357600080fd5b6005805463ffffffff9092166101000264ffffffff0019909216919091179055565b60055433600160a060020a0390811665010000000000909204161461150957600080fd5b600554650100000000009004600160a060020a0316ff5b60085481565b60055460009060ff1615156001141561153e57600080fd5b3482600954826103e860085485611556866001611aa7565b611561876001611aa7565b606403880281151561156f57fe5b04010281151561157b57fe5b0403118061158a5750600b5482105b806115955750600281105b806115a05750606381115b156115aa57600080fd5b6116106040805190810160405280600681526020017f6e657374656400000000000000000000000000000000000000000000000000008152506101e06040519081016040526101b48082526126e16020830139600554610100900463ffffffff16611ac4565b60008181526012602090815260408083208490556016825280832088905560138252808320349081905560109092529091208054600160a060020a03191633600160a060020a0316179055600854919450906103e89082611672886001611aa7565b61167d896001611aa7565b606403340281151561168b57fe5b04010281151561169757fe5b60008681526018602052604090209190049190910390819055600d546116bc916105ec565b600d81905560075490106116cf57600080fd5b6000838152601360209081526040808320546018909252909120546116f491906105ec565b60008481526010602090815260408083205460128352818420546018845282852054601385528386205460169095529483902054600160a060020a039092169490937f1cb5bfc4e69cbacf65c8e05bdb84d7a327bd6bb4c034ff82359aefd7443775c493919290915180848152602001838152602001828152602001935050505060405180910390a450505050565b6103e881565b600d5481565b8101101590565b60008054600160a060020a031615806117c157506000546117bf90600160a060020a0316611e4a565b155b156117d2576117d06000611e4e565b505b60008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561181b57600080fd5b6102c65a03f1151561182c57600080fd5b5050506040518051600154600160a060020a0390811691161490506118cf5760008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561189457600080fd5b6102c65a03f115156118a557600080fd5b505050604051805160018054600160a060020a031916600160a060020a0392909216919091179055505b600154600160a060020a031663c281d19e6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561191757600080fd5b6102c65a03f1151561192857600080fd5b50505060405180519150505b90565b61193f612451565b602082016040805190810160405280845181526020019190915292915050565b611967612451565b600082518451101561197b578391506119c5565b50600160208301518460200151146119a3578251602085015160208501518290209190201490505b80156119c15782518481815103905250825184602001818151019052505b8391505b5092915050565b6119d4612451565b6000808351855110156119e957849250611a2b565b835185518660200151010391506001905083602001518214611a1657835160208501518190209083201490505b8015611a2757835185818151039052505b8492505b505092915050565b611a3b612451565b6119c5838383612174565b611a4e612468565b611a56612468565b60008351604051805910611a675750595b818152601f19601f8301168101602001604052905091506020820190506119c581856020015186516121e3565b6000611aa1826000612228565b92915050565b6000611ab38383612396565b1515611abe57600080fd5b50900390565b600080548190600160a060020a03161580611af15750600054611aef90600160a060020a0316611e4a565b155b15611b0257611b006000611e4e565b505b60008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515611b4b57600080fd5b6102c65a03f11515611b5c57600080fd5b5050506040518051600154600160a060020a039081169116149050611bff5760008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515611bc457600080fd5b6102c65a03f11515611bd557600080fd5b505050604051805160018054600160a060020a031916600160a060020a0392909216919091179055505b600154600160a060020a0316632ef3accc86856000604051602001526040518363ffffffff1660e060020a0281526004018080602001838152602001828103825284818151815260200191508051906020019080838360005b83811015611c70578082015183820152602001611c58565b50505050905090810190601f168015611c9d5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b1515611cbc57600080fd5b6102c65a03f11515611ccd57600080fd5b5050506040518051915050670de0b6b3a76400003a840201811115611cf55760009150611e42565b600154600160a060020a031663c51be90f82600088888883604051602001526040518663ffffffff1660e060020a028152600401808581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b83811015611d73578082015183820152602001611d5b565b50505050905090810190601f168015611da05780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015611dd6578082015183820152602001611dbe565b50505050905090810190601f168015611e035780820380516001836020036101000a031916815260200191505b5096505050505050506020604051808303818588803b1515611e2457600080fd5b6125ee5a03f11515611e3557600080fd5b5050505060405180519250505b509392505050565b3b90565b600080611e6e731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed611e4a565b1115611ede5760008054600160a060020a031916731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed179055611ed660408051908101604052600b81527f6574685f6d61696e6e6574000000000000000000000000000000000000000000602082015261239b565b5060016110d3565b6000611efd73c03a2615d5efaf5f49f60b7bb6583eaec212fdf1611e4a565b1115611f655760008054600160a060020a03191673c03a2615d5efaf5f49f60b7bb6583eaec212fdf1179055611ed660408051908101604052600c81527f6574685f726f707374656e330000000000000000000000000000000000000000602082015261239b565b6000611f8473b7a07bcf2ba2f2703b24c0691b5278999c59ac7e611e4a565b1115611fec5760008054600160a060020a03191673b7a07bcf2ba2f2703b24c0691b5278999c59ac7e179055611ed660408051908101604052600981527f6574685f6b6f76616e0000000000000000000000000000000000000000000000602082015261239b565b600061200b73146500cfd35b22e4a392fe0adc06de1a1368ed48611e4a565b11156120735760008054600160a060020a03191673146500cfd35b22e4a392fe0adc06de1a1368ed48179055611ed660408051908101604052600b81527f6574685f72696e6b656279000000000000000000000000000000000000000000602082015261239b565b6000612092736f485c8bf6fc43ea212e93bbf8ce046c7f1cb475611e4a565b11156120c6575060008054600160a060020a031916736f485c8bf6fc43ea212e93bbf8ce046c7f1cb47517905560016110d3565b60006120e57320e12a1f859b3feae5fb2a0a32c18f5a65555bbf611e4a565b1115612119575060008054600160a060020a0319167320e12a1f859b3feae5fb2a0a32c18f5a65555bbf17905560016110d3565b60006121387351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa611e4a565b111561216c575060008054600160a060020a0319167351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa17905560016110d3565b506000919050565b61217c612451565b600061219485518660200151865187602001516123ae565b905084602001516020808501919091528501518103835284518560200151018114156121c357600085526121da565b835183510185818151039052508351810160208601525b50909392505050565b60005b6020821061220957825184526020840193506020830192506020820391506121e6565b6001826020036101000a03905080198351168185511617909352505050565b6000612232612468565b5082600080805b8351811015612379577f300000000000000000000000000000000000000000000000000000000000000084828151811061226f57fe5b016020015160f860020a900460f860020a02600160f860020a031916101580156122e057507f39000000000000000000000000000000000000000000000000000000000000008482815181106122c157fe5b016020015160f860020a900460f860020a02600160f860020a03191611155b156123365781156122ff578515156122f757612379565b600019909501945b600a83029250603084828151811061231357fe5b016020015160f860020a900460f860020a0260f860020a90040383019250612371565b83818151811061234257fe5b016020015160f860020a900460f860020a02600160f860020a031916602e60f860020a02141561237157600191505b600101612239565b600086111561238b5785600a0a830292505b509095945050505050565b111590565b600281805161067d92916020019061247a565b60008080808088871161243f57602087116124055760018760200360080260020a031980875116888b038a018a96505b8183885116146123fa5760018701968190106123de578b8b0196505b505050839450612445565b8686209150879350600092505b868903831161243f57508583208181141561242f57839450612445565b6001938401939290920191612412565b88880194505b50505050949350505050565b604080519081016040526000808252602082015290565b60206040519081016040526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106124bb57805160ff19168380011785556124e8565b828001600101855582156124e8579182015b828111156124e85782518255916020019190600101906124cd565b506113e4926119349250905b808211156113e457600081556001016124f4565b600054600160a060020a03161580612532575060005461253090600160a060020a0316611e4a565b155b15612543576125416000611e4e565b505b60008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561258c57600080fd5b6102c65a03f1151561259d57600080fd5b5050506040518051600154600160a060020a0390811691161490506126405760008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561260557600080fd5b6102c65a03f1151561261657600080fd5b505050604051805160018054600160a060020a031916600160a060020a0392909216919091179055505b600154600160a060020a031663688dcfd78260405160e060020a63ffffffff84160281527fff000000000000000000000000000000000000000000000000000000000000009091166004820152602401600060405180830381600087803b15156126a957600080fd5b6102c65a03f115156126ba57600080fd5b5050505056008dd0b145385d04711e29558ceab40b456976a2b9a7d648cc1bcd416161bf97b95b55524c5d205b276a736f6e2868747470733a2f2f6170692e72616e646f6d2e6f72672f6a736f6e2d7270632f312f696e766f6b65292e726573756c742e72616e646f6d5b2273657269616c4e756d626572222c2264617461225d272c20275c6e7b226a736f6e727063223a22322e30222c226d6574686f64223a2267656e65726174655369676e6564496e746567657273222c22706172616d73223a7b226170694b6579223a247b5b646563727970745d20424b3855784945484c6159384a4551446c31736a4b37332b66445a617a65326f527970334f7a674933513158627a377846474a37704b746d4b586479694d4c356532364859656f784f34664f466f5651376948425664334f6c6d30676f774a36306f4969432b4f66724f422b64736f6f62617a7463466d454b4d676837624c5852454c394f524162377255443444566c48344e707851346d666b674b7674453d7d2c226e223a312c226d696e223a312c226d6178223a3130302c227265706c6163656d656e74223a747275652c2262617365223a3130247b5b6964656e746974795d20227d227d2c226964223a31247b5b6964656e746974795d20227d227d275da165627a7a72305820df1995289447e753b2c69b4da7034540e1d870fc95c7b63e444e408e85ed86cc0029

Deployed Bytecode

0x60606040526004361061019d5763ffffffff60e060020a60003504166315c12d4d81146101d157806323214fab146101f6578063268d50fe1461020957806327dc297e1461021f578063301cf6e714610275578063313752421461029c57806338bbfa50146102bb5780633a4f6999146103535780633c314a91146103665780634025b5a81461038557806343c1598d1461039b5780634b7fcee7146103ae5780634f44728d146103c657806355b93031146103e55780635e968a49146103f857806361d027b31461040e578063666f4cad1461043d5780636cdf4c90146104505780636eacd48a146104665780637072a9771461047e5780637ac37d58146104aa5780638b7afe2e146104cc5780638da5cb5b146104df5780639619367d146104f2578063a5f4af3314610505578063b539cd5514610518578063befa1e2f1461052b578063c3de1ab91461053e578063cf832ce214610551578063d207e75714610579578063d263b7eb14610595578063d667dcd7146105a8578063dc6dd152146105bb578063e5c774de146105c6578063ed62f501146105d9575b60065433600160a060020a039081169116146101b857600080fd5b6101c4600754346105ec565b6007556101cf610608565b005b34156101dc57600080fd5b6101e461061a565b60405190815260200160405180910390f35b341561020157600080fd5b6101e4610620565b341561021457600080fd5b6101cf600435610626565b341561022a57600080fd5b6101cf600480359060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061064f95505050505050565b341561028057600080fd5b610288610681565b604051901515815260200160405180910390f35b34156102a757600080fd5b6101cf600160a060020a0360043516610691565b34156102c657600080fd5b6101cf600480359060446024803590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284378201915050505050509190803590602001908201803590602001908080601f0160208091040260200160405190810160405281815292919060208401838380828437509496506106d795505050505050565b341561035e57600080fd5b6101e46110b4565b341561037157600080fd5b6101e4600160a060020a03600435166110b9565b341561039057600080fd5b6101cf6004356110d8565b34156103a657600080fd5b6101e4611101565b34156103b957600080fd5b6101cf6004351515611108565b34156103d157600080fd5b6101cf600160a060020a0360043516611160565b34156103f057600080fd5b6101e46111c1565b341561040357600080fd5b6101cf6004356111c6565b341561041957600080fd5b610421611209565b604051600160a060020a03909116815260200160405180910390f35b341561044857600080fd5b6101e4611218565b341561045b57600080fd5b6101cf60043561121e565b341561047157600080fd5b6101cf6004351515611247565b341561048957600080fd5b61049161127e565b60405163ffffffff909116815260200160405180910390f35b34156104b557600080fd5b6101cf600160a060020a036004351660243561128f565b34156104d757600080fd5b6101e4611336565b34156104ea57600080fd5b61042161133c565b34156104fd57600080fd5b6101e4611354565b341561051057600080fd5b61028861135a565b341561052357600080fd5b6101e46113e8565b341561053657600080fd5b6101e46113ee565b341561054957600080fd5b6102886113f4565b341561055c57600080fd5b6101cf600435600160a060020a03602435166044356064356113fd565b341561058457600080fd5b6101cf63ffffffff6004351661149f565b34156105a057600080fd5b6101cf6114e5565b34156105b357600080fd5b6101e4611520565b6101cf600435611526565b34156105d157600080fd5b6101e4611783565b34156105e457600080fd5b6101e4611789565b60006105f8838361178f565b151561060357600080fd5b500190565b600a54600754620f4240910204600955565b600e5481565b600a5481565b60055433600160a060020a0390811665010000000000909204161461064a57600080fd5b600855565b61067d828260006040518059106106635750595b818152601f19601f830116810160200160405290506106d7565b5050565b60055460c860020a900460ff1681565b60055433600160a060020a039081166501000000000090920416146106b557600080fd5b60068054600160a060020a031916600160a060020a0392909216919091179055565b6106df612451565b60006106e9611796565b600160a060020a031633600160a060020a031614151561070857600080fd5b60055460c860020a900460ff1615156001141561072457600080fd5b600085815260106020526040902054600160a060020a0316151561074757600080fd5b61075084611937565b91506107e961079160408051908101604052600181527f5d000000000000000000000000000000000000000000000000000000000000006020820152611937565b6107dd6107d060408051908101604052600181527f5b000000000000000000000000000000000000000000000000000000000000006020820152611937565b859063ffffffff61195f16565b9063ffffffff6119cc16565b5061084661084161083c61082f60408051908101604052600281527f2c200000000000000000000000000000000000000000000000000000000000006020820152611937565b859063ffffffff611a3316565b611a46565b611a94565b90506108d961084161083c61088d60408051908101604052600181527f5d000000000000000000000000000000000000000000000000000000000000006020820152611937565b6107dd6108cc60408051908101604052600181527f5b000000000000000000000000000000000000000000000000000000000000006020820152611937565b879063ffffffff61195f16565b600086815260156020908152604080832093909355601081528282208054601183528484208054600160a060020a03909216600160a060020a0319928316179055815416905560188152828220805460199092529282209081559155600d5490546109449190611aa7565b600d55600085815260136020908152604080832080546014845282852090815590849055600c8054600101905554600f805490910190556015909152902054158061098e57508351155b8061099857508251155b15610c225760008581526011602090815260408083205460128352818420546016845282852054601585528386205460149095529483902054600160a060020a0390921694909386936000805160206126c183398151915293906003908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610a4a578082015183820152602001610a32565b50505050905090810190601f168015610a775780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a460008581526011602090815260408083205460149092529182902054600160a060020a039091169181156108fc02919051600060405180830381858888f193505050501515610c1d5760008581526011602090815260408083205460128352818420546016845282852054601585528386205460149095529483902054600160a060020a0390921694909386936000805160206126c183398151915293906004908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610b7e578082015183820152602001610b66565b50505050905090810190601f168015610bab5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a4600085815260116020908152604080832054600160a060020a031683526017825280832054888452601490925290912054610bf791906105ec565b600086815260116020908152604080832054600160a060020a0316835260179091529020555b6110ad565b6000858152601660209081526040808320546015909252909120541015610f0f57600754600086815260196020526040902054610c5f9190611aa7565b600755600e54600086815260196020526040902054610c7e91906105ec565b600e55600085815260196020908152604080832054601490925290912054610ca691906105ec565b600086815260196020818152604080842085905560118252808420546012835281852054601684528286205460158552958390205494909352600160a060020a031694919386936000805160206126c18339815191529391929091906001908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610d5a578082015183820152602001610d42565b50505050905090810190601f168015610d875780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a4610da0610608565b60008581526011602090815260408083205460199092529182902054600160a060020a039091169181156108fc02919051600060405180830381858888f193505050501515610c1d5760008581526011602090815260408083205460128352818420546016845282852054601585528386205460199095529483902054600160a060020a0390921694909386936000805160206126c183398151915293906002908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610e96578082015183820152602001610e7e565b50505050905090810190601f168015610ec35780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a4600085815260116020908152604080832054600160a060020a031683526017825280832054888452601990925290912054610bf791906105ec565b600085815260166020908152604080832054601590925290912054106110ad57600085815260116020908152604080832054601283528184205460168452828520546015855283862054601490955283862054600160a060020a0390931695919487946000805160206126c1833981519152949293919291908b90518086815260200185815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610fdd578082015183820152602001610fc5565b50505050905090810190601f16801561100a5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a460075460008681526014602052604090205461103b9190600019016105ec565b600755611046610608565b60008581526011602052604080822054600160a060020a0316919060019051600060405180830381858888f193505050501515610c1d57600085815260116020908152604080832054600160a060020a031683526017909152902054610bf79060016105ec565b5050505050565b606381565b600160a060020a0381166000908152601760205260409020545b919050565b60055433600160a060020a039081166501000000000090920416146110fc57600080fd5b600755565b620f424081565b60055433600160a060020a0390811665010000000000909204161461112c57600080fd5b6005805491151560c860020a0279ff0000000000000000000000000000000000000000000000000019909216919091179055565b60055433600160a060020a0390811665010000000000909204161461118457600080fd5b60058054600160a060020a03909216650100000000000278ffffffffffffffffffffffffffffffffffffffff000000000019909216919091179055565b600281565b60055433600160a060020a039081166501000000000090920416146111ea57600080fd5b6127108111156111f957600080fd5b600a819055611206610608565b50565b600654600160a060020a031681565b600f5481565b60055433600160a060020a0390811665010000000000909204161461124257600080fd5b600b55565b60055433600160a060020a0390811665010000000000909204161461126b57600080fd5b6005805460ff1916911515919091179055565b600554610100900463ffffffff1681565b60055433600160a060020a039081166501000000000090920416146112b357600080fd5b6112bf60075482611aa7565b6007556112ca610608565b600160a060020a03821681156108fc0282604051600060405180830381858888f1935050505015156112fb57600080fd5b8082600160a060020a03167f42c501a185f41a8eb77b0a3e7b72a6435ea7aa752f8a1a0a13ca4628495eca9160405160405180910390a35050565b60075481565b600554650100000000009004600160a060020a031681565b600b5481565b600080600560199054906101000a900460ff16151560011515141561137e57600080fd5b50600160a060020a033316600081815260176020526040808220805492905590919082905160006040518083038185876187965a03f192505050156113c657600191506113e4565b600160a060020a033316600090815260176020526040812082905591505b5090565b60095481565b600c5481565b60055460ff1681565b60055433600160a060020a0390811665010000000000909204161461142157600080fd5b61142d600d5483611aa7565b600d55600160a060020a03831681156108fc0282604051600060405180830381858888f19350505050151561146157600080fd5b80600160a060020a038416857f7b6ccf85690b8ce1b7d21a94ca738803a9da7dc74e10140f269efa0d8d6fb85160405160405180910390a450505050565b60055433600160a060020a039081166501000000000090920416146114c357600080fd5b6005805463ffffffff9092166101000264ffffffff0019909216919091179055565b60055433600160a060020a0390811665010000000000909204161461150957600080fd5b600554650100000000009004600160a060020a0316ff5b60085481565b60055460009060ff1615156001141561153e57600080fd5b3482600954826103e860085485611556866001611aa7565b611561876001611aa7565b606403880281151561156f57fe5b04010281151561157b57fe5b0403118061158a5750600b5482105b806115955750600281105b806115a05750606381115b156115aa57600080fd5b6116106040805190810160405280600681526020017f6e657374656400000000000000000000000000000000000000000000000000008152506101e06040519081016040526101b48082526126e16020830139600554610100900463ffffffff16611ac4565b60008181526012602090815260408083208490556016825280832088905560138252808320349081905560109092529091208054600160a060020a03191633600160a060020a0316179055600854919450906103e89082611672886001611aa7565b61167d896001611aa7565b606403340281151561168b57fe5b04010281151561169757fe5b60008681526018602052604090209190049190910390819055600d546116bc916105ec565b600d81905560075490106116cf57600080fd5b6000838152601360209081526040808320546018909252909120546116f491906105ec565b60008481526010602090815260408083205460128352818420546018845282852054601385528386205460169095529483902054600160a060020a039092169490937f1cb5bfc4e69cbacf65c8e05bdb84d7a327bd6bb4c034ff82359aefd7443775c493919290915180848152602001838152602001828152602001935050505060405180910390a450505050565b6103e881565b600d5481565b8101101590565b60008054600160a060020a031615806117c157506000546117bf90600160a060020a0316611e4a565b155b156117d2576117d06000611e4e565b505b60008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561181b57600080fd5b6102c65a03f1151561182c57600080fd5b5050506040518051600154600160a060020a0390811691161490506118cf5760008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561189457600080fd5b6102c65a03f115156118a557600080fd5b505050604051805160018054600160a060020a031916600160a060020a0392909216919091179055505b600154600160a060020a031663c281d19e6000604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561191757600080fd5b6102c65a03f1151561192857600080fd5b50505060405180519150505b90565b61193f612451565b602082016040805190810160405280845181526020019190915292915050565b611967612451565b600082518451101561197b578391506119c5565b50600160208301518460200151146119a3578251602085015160208501518290209190201490505b80156119c15782518481815103905250825184602001818151019052505b8391505b5092915050565b6119d4612451565b6000808351855110156119e957849250611a2b565b835185518660200151010391506001905083602001518214611a1657835160208501518190209083201490505b8015611a2757835185818151039052505b8492505b505092915050565b611a3b612451565b6119c5838383612174565b611a4e612468565b611a56612468565b60008351604051805910611a675750595b818152601f19601f8301168101602001604052905091506020820190506119c581856020015186516121e3565b6000611aa1826000612228565b92915050565b6000611ab38383612396565b1515611abe57600080fd5b50900390565b600080548190600160a060020a03161580611af15750600054611aef90600160a060020a0316611e4a565b155b15611b0257611b006000611e4e565b505b60008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515611b4b57600080fd5b6102c65a03f11515611b5c57600080fd5b5050506040518051600154600160a060020a039081169116149050611bff5760008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b1515611bc457600080fd5b6102c65a03f11515611bd557600080fd5b505050604051805160018054600160a060020a031916600160a060020a0392909216919091179055505b600154600160a060020a0316632ef3accc86856000604051602001526040518363ffffffff1660e060020a0281526004018080602001838152602001828103825284818151815260200191508051906020019080838360005b83811015611c70578082015183820152602001611c58565b50505050905090810190601f168015611c9d5780820380516001836020036101000a031916815260200191505b509350505050602060405180830381600087803b1515611cbc57600080fd5b6102c65a03f11515611ccd57600080fd5b5050506040518051915050670de0b6b3a76400003a840201811115611cf55760009150611e42565b600154600160a060020a031663c51be90f82600088888883604051602001526040518663ffffffff1660e060020a028152600401808581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b83811015611d73578082015183820152602001611d5b565b50505050905090810190601f168015611da05780820380516001836020036101000a031916815260200191505b50838103825285818151815260200191508051906020019080838360005b83811015611dd6578082015183820152602001611dbe565b50505050905090810190601f168015611e035780820380516001836020036101000a031916815260200191505b5096505050505050506020604051808303818588803b1515611e2457600080fd5b6125ee5a03f11515611e3557600080fd5b5050505060405180519250505b509392505050565b3b90565b600080611e6e731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed611e4a565b1115611ede5760008054600160a060020a031916731d3b2638a7cc9f2cb3d298a3da7a90b67e5506ed179055611ed660408051908101604052600b81527f6574685f6d61696e6e6574000000000000000000000000000000000000000000602082015261239b565b5060016110d3565b6000611efd73c03a2615d5efaf5f49f60b7bb6583eaec212fdf1611e4a565b1115611f655760008054600160a060020a03191673c03a2615d5efaf5f49f60b7bb6583eaec212fdf1179055611ed660408051908101604052600c81527f6574685f726f707374656e330000000000000000000000000000000000000000602082015261239b565b6000611f8473b7a07bcf2ba2f2703b24c0691b5278999c59ac7e611e4a565b1115611fec5760008054600160a060020a03191673b7a07bcf2ba2f2703b24c0691b5278999c59ac7e179055611ed660408051908101604052600981527f6574685f6b6f76616e0000000000000000000000000000000000000000000000602082015261239b565b600061200b73146500cfd35b22e4a392fe0adc06de1a1368ed48611e4a565b11156120735760008054600160a060020a03191673146500cfd35b22e4a392fe0adc06de1a1368ed48179055611ed660408051908101604052600b81527f6574685f72696e6b656279000000000000000000000000000000000000000000602082015261239b565b6000612092736f485c8bf6fc43ea212e93bbf8ce046c7f1cb475611e4a565b11156120c6575060008054600160a060020a031916736f485c8bf6fc43ea212e93bbf8ce046c7f1cb47517905560016110d3565b60006120e57320e12a1f859b3feae5fb2a0a32c18f5a65555bbf611e4a565b1115612119575060008054600160a060020a0319167320e12a1f859b3feae5fb2a0a32c18f5a65555bbf17905560016110d3565b60006121387351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa611e4a565b111561216c575060008054600160a060020a0319167351efaf4c8b3c9afbd5ab9f4bbc82784ab6ef8faa17905560016110d3565b506000919050565b61217c612451565b600061219485518660200151865187602001516123ae565b905084602001516020808501919091528501518103835284518560200151018114156121c357600085526121da565b835183510185818151039052508351810160208601525b50909392505050565b60005b6020821061220957825184526020840193506020830192506020820391506121e6565b6001826020036101000a03905080198351168185511617909352505050565b6000612232612468565b5082600080805b8351811015612379577f300000000000000000000000000000000000000000000000000000000000000084828151811061226f57fe5b016020015160f860020a900460f860020a02600160f860020a031916101580156122e057507f39000000000000000000000000000000000000000000000000000000000000008482815181106122c157fe5b016020015160f860020a900460f860020a02600160f860020a03191611155b156123365781156122ff578515156122f757612379565b600019909501945b600a83029250603084828151811061231357fe5b016020015160f860020a900460f860020a0260f860020a90040383019250612371565b83818151811061234257fe5b016020015160f860020a900460f860020a02600160f860020a031916602e60f860020a02141561237157600191505b600101612239565b600086111561238b5785600a0a830292505b509095945050505050565b111590565b600281805161067d92916020019061247a565b60008080808088871161243f57602087116124055760018760200360080260020a031980875116888b038a018a96505b8183885116146123fa5760018701968190106123de578b8b0196505b505050839450612445565b8686209150879350600092505b868903831161243f57508583208181141561242f57839450612445565b6001938401939290920191612412565b88880194505b50505050949350505050565b604080519081016040526000808252602082015290565b60206040519081016040526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106124bb57805160ff19168380011785556124e8565b828001600101855582156124e8579182015b828111156124e85782518255916020019190600101906124cd565b506113e4926119349250905b808211156113e457600081556001016124f4565b600054600160a060020a03161580612532575060005461253090600160a060020a0316611e4a565b155b15612543576125416000611e4e565b505b60008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561258c57600080fd5b6102c65a03f1151561259d57600080fd5b5050506040518051600154600160a060020a0390811691161490506126405760008054600160a060020a0316906338cc483190604051602001526040518163ffffffff1660e060020a028152600401602060405180830381600087803b151561260557600080fd5b6102c65a03f1151561261657600080fd5b505050604051805160018054600160a060020a031916600160a060020a0392909216919091179055505b600154600160a060020a031663688dcfd78260405160e060020a63ffffffff84160281527fff000000000000000000000000000000000000000000000000000000000000009091166004820152602401600060405180830381600087803b15156126a957600080fd5b6102c65a03f115156126ba57600080fd5b5050505056008dd0b145385d04711e29558ceab40b456976a2b9a7d648cc1bcd416161bf97b95b55524c5d205b276a736f6e2868747470733a2f2f6170692e72616e646f6d2e6f72672f6a736f6e2d7270632f312f696e766f6b65292e726573756c742e72616e646f6d5b2273657269616c4e756d626572222c2264617461225d272c20275c6e7b226a736f6e727063223a22322e30222c226d6574686f64223a2267656e65726174655369676e6564496e746567657273222c22706172616d73223a7b226170694b6579223a247b5b646563727970745d20424b3855784945484c6159384a4551446c31736a4b37332b66445a617a65326f527970334f7a674933513158627a377846474a37704b746d4b586479694d4c356532364859656f784f34664f466f5651376948425664334f6c6d30676f774a36306f4969432b4f66724f422b64736f6f62617a7463466d454b4d676837624c5852454c394f524162377255443444566c48344e707851346d666b674b7674453d7d2c226e223a312c226d696e223a312c226d6178223a3130302c227265706c6163656d656e74223a747275652c2262617365223a3130247b5b6964656e746974795d20227d227d2c226964223a31247b5b6964656e746974795d20227d227d275da165627a7a72305820df1995289447e753b2c69b4da7034540e1d870fc95c7b63e444e408e85ed86cc0029

Swarm Source

bzzr://df1995289447e753b2c69b4da7034540e1d870fc95c7b63e444e408e85ed86cc

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.