Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x133DbFdf74f565838A2f9413Fb53761a19f06ADF
Balance 0 ETH
Nonce 1
Code Size 9115 bytes
Indexed Transactions 0 (1 on-chain, 0.7% indexed)
External Etherscan · Sourcify

Contract Bytecode

9115 bytes
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c8063a65b9a6011610071578063a65b9a6014610154578063af78feef14610170578063c90bd0471461018e578063d2fd8b76146101ac578063ec56a373146101c8578063fbdf3b4314610201576100a9565b80632f21a663146100ae578063414ac85b146100de57806345b4032c146100fc5780637fcce2a91461011857806394e15c8f14610136575b600080fd5b6100c860048036036100c39190810190611707565b610231565b6040516100d59190611e46565b60405180910390f35b6100e66102c1565b6040516100f39190611fe8565b60405180910390f35b610116600480360361011191908101906117c3565b6102c6565b005b610120610528565b60405161012d9190611fe8565b60405180910390f35b61013e61052d565b60405161014b9190611fe8565b60405180910390f35b61016e600480360361016991908101906117ff565b610532565b005b61017861084a565b6040516101859190611fe8565b60405180910390f35b61019661084f565b6040516101a39190611fe8565b60405180910390f35b6101c660048036036101c1919081019061184e565b610854565b005b6101e260048036036101dd9190810190611771565b610cdd565b6040516101f89a99989796959493929190612084565b60405180910390f35b61021b60048036036102169190810190611771565b610ec1565b6040516102289190611fe8565b60405180910390f35b60608082516040519080825280602002602001820160405280156102645781602001602082028038833980820191505090505b50905060008090505b83518110156102b75761029284828151811061028557fe5b6020026020010151610ec1565b82828151811061029e57fe5b602002602001018181525050808060010191505061026d565b5080915050919050565b600481565b600080600084815260200190815260200160002090508173ffffffffffffffffffffffffffffffffffffffff168160050160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461036e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161036590611f08565b60405180910390fd5b60018160030154146103b5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103ac90611f48565b60405180910390fd5b42816002015411156103fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f390611f68565b60405180910390fd5b600281600301819055506104598160060160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682600001548473ffffffffffffffffffffffffffffffffffffffff166111969092919063ffffffff16565b8060070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160060160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f0d4cdc2fe2a785f03bf5481e13bee5cdcb7743166bcadafebfd3f09db610811786856004015460405161051b929190611e68565b60405180910390a4505050565b600081565b600281565b600080600085815260200190815260200160002090508173ffffffffffffffffffffffffffffffffffffffff168160050160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146105da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105d190611f08565b60405180910390fd5b6001816003015414610621576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161061890611f48565b60405180910390fd5b42816002015411610667576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161065e90611f68565b60405180910390fd5b60028360405160200161067a9190611db4565b6040516020818303038152906040526040516106969190611dcf565b602060405180830381855afa1580156106b3573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052506106d6919081019061179a565b81600401541461071b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161071290611ee8565b60405180910390fd5b600381600301819055506107788160070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1682600001548473ffffffffffffffffffffffffffffffffffffffff166111969092919063ffffffff16565b8060070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168160060160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fbab3eb11a71b2cd82a010d4d5b2c3df5cd25ee8c9f1a75baff879a1b87942cb88787866004015460405161083c93929190611e91565b60405180910390a450505050565b600381565b600181565b428811610896576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161088d90611f68565b60405180910390fd5b60008a116108d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108d090611fa8565b60405180910390fd5b61090633308c8973ffffffffffffffffffffffffffffffffffffffff16611235909392919063ffffffff16565b6000600233878d8b8d8c60405160200161092596959493929190611d44565b6040516020818303038152906040526040516109419190611dcf565b602060405180830381855afa15801561095e573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250610981919081019061179a565b9050600080600083815260200190815260200160002060030154146109db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109d290611ec8565b60405180910390fd5b6040518061014001604052808c81526020018b81526020018a8152602001600181526020018981526020018873ffffffffffffffffffffffffffffffffffffffff1681526020013373ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff16815260200186868080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050815260200184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050815250600080838152602001908152602001600020600082015181600001556020820151816001015560408201518160020155606082015181600301556080820151816004015560a08201518160050160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060c08201518160060160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060e08201518160070160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610100820151816008019080519060200190610c22929190611494565b50610120820151816009019080519060200190610c40929190611494565b509050508573ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167f448581ece7da63e54a320119f9f2b80c868a954c441e70c88ecdfc95919751248e8e8e878f8d8d8d8d604051610cc899989796959493929190612003565b60405180910390a45050505050505050505050565b60006020528060005260406000206000915090508060000154908060010154908060020154908060030154908060040154908060050160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060060160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060070160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690806008018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e195780601f10610dee57610100808354040283529160200191610e19565b820191906000526020600020905b815481529060010190602001808311610dfc57829003601f168201915b505050505090806009018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610eb75780601f10610e8c57610100808354040283529160200191610eb7565b820191906000526020600020905b815481529060010190602001808311610e9a57829003601f168201915b505050505090508a565b6000610ecb611514565b6000808481526020019081526020016000206040518061014001604052908160008201548152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016006820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016007820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600882018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110b65780601f1061108b576101008083540402835291602001916110b6565b820191906000526020600020905b81548152906001019060200180831161109957829003601f168201915b50505050508152602001600982018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156111585780601f1061112d57610100808354040283529160200191611158565b820191906000526020600020905b81548152906001019060200180831161113b57829003601f168201915b50505050508152505090506001816060015114801561117a5750428160400151105b156111885760049150611190565b806060015191505b50919050565b611230838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b84846040516024016111ce929190611e1d565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506112d7565b505050565b6112d1848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b85858560405160240161126f93929190611de6565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506112d7565b50505050565b6112f68273ffffffffffffffffffffffffffffffffffffffff16611449565b611335576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132c90611fc8565b60405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff168360405161135e9190611dcf565b6000604051808303816000865af19150503d806000811461139b576040519150601f19603f3d011682016040523d82523d6000602084013e6113a0565b606091505b5091509150816113e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113dc90611f28565b60405180910390fd5b60008151111561144357808060200190516114039190810190611748565b611442576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161143990611f88565b60405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561148b57506000801b8214155b92505050919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106114d557805160ff1916838001178555611503565b82800160010185558215611503579182015b828111156115025782518255916020019190600101906114e7565b5b50905061151091906115ac565b5090565b6040518061014001604052806000815260200160008152602001600081526020016000815260200160008019168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081525090565b6115ce91905b808211156115ca5760008160009055506001016115b2565b5090565b90565b6000813590506115e0816122fc565b92915050565b600082601f8301126115f757600080fd5b813561160a6116058261215b565b61212e565b9150818183526020840193506020810190508385602084028201111561162f57600080fd5b60005b8381101561165f5781611645888261167e565b845260208401935060208301925050600181019050611632565b5050505092915050565b60008151905061167881612313565b92915050565b60008135905061168d8161232a565b92915050565b6000815190506116a28161232a565b92915050565b60008083601f8401126116ba57600080fd5b8235905067ffffffffffffffff8111156116d357600080fd5b6020830191508360018202830111156116eb57600080fd5b9250929050565b60008135905061170181612341565b92915050565b60006020828403121561171957600080fd5b600082013567ffffffffffffffff81111561173357600080fd5b61173f848285016115e6565b91505092915050565b60006020828403121561175a57600080fd5b600061176884828501611669565b91505092915050565b60006020828403121561178357600080fd5b60006117918482850161167e565b91505092915050565b6000602082840312156117ac57600080fd5b60006117ba84828501611693565b91505092915050565b600080604083850312156117d657600080fd5b60006117e48582860161167e565b92505060206117f5858286016115d1565b9150509250929050565b60008060006060848603121561181457600080fd5b60006118228682870161167e565b93505060206118338682870161167e565b9250506040611844868287016115d1565b9150509250925092565b6000806000806000806000806000806101008b8d03121561186e57600080fd5b600061187c8d828e016116f2565b9a5050602061188d8d828e016116f2565b995050604061189e8d828e016116f2565b98505060606118af8d828e0161167e565b97505060806118c08d828e016115d1565b96505060a06118d18d828e016115d1565b95505060c08b013567ffffffffffffffff8111156118ee57600080fd5b6118fa8d828e016116a8565b945094505060e08b013567ffffffffffffffff81111561191957600080fd5b6119258d828e016116a8565b92509250509295989b9194979a5092959850565b60006119458383611d0f565b60208301905092915050565b61196261195d82612200565b6122a6565b82525050565b611971816121ee565b82525050565b611988611983826121ee565b612294565b82525050565b600061199982612193565b6119a381856121c1565b93506119ae83612183565b8060005b838110156119df5781516119c68882611939565b97506119d1836121b4565b9250506001810190506119b2565b5085935050505092915050565b6119f58161221e565b82525050565b611a0c611a078261221e565b6122b8565b82525050565b6000611a1d8261219e565b611a2781856121d2565b9350611a37818560208601612261565b80840191505092915050565b6000611a4f83856121dd565b9350611a5c838584612252565b611a65836122de565b840190509392505050565b6000611a7b826121a9565b611a8581856121dd565b9350611a95818560208601612261565b611a9e816122de565b840191505092915050565b6000611ab6600b836121dd565b91507f535741505f4558495354530000000000000000000000000000000000000000006000830152602082019050919050565b6000611af6600e836121dd565b91507f494e56414c49445f5345435245540000000000000000000000000000000000006000830152602082019050919050565b6000611b36600d836121dd565b91507f494e56414c49445f544f4b454e000000000000000000000000000000000000006000830152602082019050919050565b6000611b766020836121dd565b91507f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65646000830152602082019050919050565b6000611bb6600f836121dd565b91507f535741505f4e4f545f41435449564500000000000000000000000000000000006000830152602082019050919050565b6000611bf6600c836121dd565b91507f494e56414c49445f54494d4500000000000000000000000000000000000000006000830152602082019050919050565b6000611c36602a836121dd565b91507f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008301527f6f742073756363656564000000000000000000000000000000000000000000006020830152604082019050919050565b6000611c9c600e836121dd565b91507f494e56414c49445f414d4f554e540000000000000000000000000000000000006000830152602082019050919050565b6000611cdc601f836121dd565b91507f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e7472616374006000830152602082019050919050565b611d1881612248565b82525050565b611d2781612248565b82525050565b611d3e611d3982612248565b6122d4565b82525050565b6000611d508289611951565b601482019150611d608288611977565b601482019150611d708287611d2d565b602082019150611d8082866119fb565b602082019150611d908285611d2d565b602082019150611da08284611977565b601482019150819050979650505050505050565b6000611dc082846119fb565b60208201915081905092915050565b6000611ddb8284611a12565b915081905092915050565b6000606082019050611dfb6000830186611968565b611e086020830185611968565b611e156040830184611d1e565b949350505050565b6000604082019050611e326000830185611968565b611e3f6020830184611d1e565b9392505050565b60006020820190508181036000830152611e60818461198e565b905092915050565b6000604082019050611e7d60008301856119ec565b611e8a60208301846119ec565b9392505050565b6000606082019050611ea660008301866119ec565b611eb360208301856119ec565b611ec060408301846119ec565b949350505050565b60006020820190508181036000830152611ee181611aa9565b9050919050565b60006020820190508181036000830152611f0181611ae9565b9050919050565b60006020820190508181036000830152611f2181611b29565b9050919050565b60006020820190508181036000830152611f4181611b69565b9050919050565b60006020820190508181036000830152611f6181611ba9565b9050919050565b60006020820190508181036000830152611f8181611be9565b9050919050565b60006020820190508181036000830152611fa181611c29565b9050919050565b60006020820190508181036000830152611fc181611c8f565b9050919050565b60006020820190508181036000830152611fe181611ccf565b9050919050565b6000602082019050611ffd6000830184611d1e565b92915050565b600060e082019050612018600083018c611d1e565b612025602083018b611d1e565b612032604083018a611d1e565b61203f60608301896119ec565b61204c60808301886119ec565b81810360a083015261205f818688611a43565b905081810360c0830152612074818486611a43565b90509a9950505050505050505050565b60006101408201905061209a600083018d611d1e565b6120a7602083018c611d1e565b6120b4604083018b611d1e565b6120c1606083018a611d1e565b6120ce60808301896119ec565b6120db60a0830188611968565b6120e860c0830187611968565b6120f560e0830186611968565b8181036101008301526121088185611a70565b905081810361012083015261211d8184611a70565b90509b9a5050505050505050505050565b6000604051905081810181811067ffffffffffffffff8211171561215157600080fd5b8060405250919050565b600067ffffffffffffffff82111561217257600080fd5b602082029050602081019050919050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b60006121f982612228565b9050919050565b600061220b82612228565b9050919050565b60008115159050919050565b6000819050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b8381101561227f578082015181840152602081019050612264565b8381111561228e576000848401525b50505050565b600061229f826122c2565b9050919050565b60006122b1826122c2565b9050919050565b6000819050919050565b60006122cd826122ef565b9050919050565b6000819050919050565b6000601f19601f8301169050919050565b60008160601b9050919050565b612305816121ee565b811461231057600080fd5b50565b61231c81612212565b811461232757600080fd5b50565b6123338161221e565b811461233e57600080fd5b50565b61234a81612248565b811461235557600080fd5b5056fea365627a7a7231582038c32c13bf4f7d549a0b195da8ad155fc661d359c6c98a0ab00abd427109c6f36c6578706572696d656e74616cf564736f6c63430005110040

Verified Source Code Partial Match

Compiler: v0.5.17+commit.d19bba13 EVM: istanbul Optimization: No
HashedTimeLockContract.sol 552 lines
pragma solidity >=0.5.5 <0.6.0;
pragma experimental ABIEncoderV2;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot overflow.
     *
     * _Available since v2.4.0._
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     *
     * _Available since v2.4.0._
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following 
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly { codehash := extcodehash(account) }
        return (codehash != accountHash && codehash != 0x0);
    }

    /**
     * @dev Converts an `address` into `address payable`. Note that this is
     * simply a type cast: the actual underlying value is not changed.
     *
     * _Available since v2.4.0._
     */
    function toPayable(address account) internal pure returns (address payable) {
        return address(uint160(account));
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     *
     * _Available since v2.4.0._
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-call-value
        (bool success, ) = recipient.call.value(amount)("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
}


interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}


library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves.

        // A Solidity high level call has three parts:
        //  1. The target address is checked to verify it contains contract code
        //  2. The call itself is made, and success asserted
        //  3. The return value is decoded, which in turn checks the size of the returned data.
        // solhint-disable-next-line max-line-length
        require(address(token).isContract(), "SafeERC20: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = address(token).call(data);
        require(success, "SafeERC20: low-level call failed");

        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

contract HashedTimeLockContract {
    using SafeERC20 for IERC20;

    mapping(bytes32 => LockContract) public contracts;

    //                   / - WITHDRAWN
    // INVALID - ACTIVE |
    //                   \ - EXPIRED - REFUNDED

    uint256 public constant INVALID = 0; // Uninitialized  swap -> can go to ACTIVE
    uint256 public constant ACTIVE = 1; // Active swap -> can go to WITHDRAWN or EXPIRED
    uint256 public constant REFUNDED = 2; // Swap is refunded -> final state.
    uint256 public constant WITHDRAWN = 3; // Swap is withdrawn -> final state.
    uint256 public constant EXPIRED = 4; // Swap is expired -> can go to REFUNDED

    struct LockContract {
        uint256 inputAmount;
        uint256 outputAmount;
        uint256 expiration;
        uint256 status;
        bytes32 hashLock;
        address tokenAddress;
        address sender;
        address receiver;
        string outputNetwork;
        string outputAddress;
    }

    event Withdraw(
        bytes32 id,
        bytes32 secret,
        bytes32 hashLock,
        address indexed tokenAddress,
        address indexed sender,
        address indexed receiver
    );

    event Refund(
        bytes32 id,
        bytes32 hashLock,
        address indexed tokenAddress,
        address indexed sender,
        address indexed receiver
    );

    event NewContract(
        uint256 inputAmount,
        uint256 outputAmount,
        uint256 expiration,
        bytes32 id,
        bytes32 hashLock,
        address indexed tokenAddress,
        address indexed sender,
        address indexed receiver,
        string outputNetwork,
        string outputAddress
    );

    function newContract(
        uint256 inputAmount,
        uint256 outputAmount,
        uint256 expiration,
        bytes32 hashLock,
        address tokenAddress,
        address receiver,
        string calldata outputNetwork,
        string calldata outputAddress
    ) external {
        require(expiration > block.timestamp, "INVALID_TIME");

        require(inputAmount > 0, "INVALID_AMOUNT");

        IERC20(tokenAddress).safeTransferFrom(
            msg.sender,
            address(this),
            inputAmount
        );

        bytes32 id = sha256(
            abi.encodePacked(
                msg.sender,
                receiver,
                inputAmount,
                hashLock,
                expiration,
                tokenAddress
            )
        );

        require(contracts[id].status == INVALID, "SWAP_EXISTS");

        contracts[id] = LockContract(
            inputAmount,
            outputAmount,
            expiration,
            ACTIVE,
            hashLock,
            tokenAddress,
            msg.sender,
            receiver,
            outputNetwork,
            outputAddress
        );

        emit NewContract(
            inputAmount,
            outputAmount,
            expiration,
            id,
            hashLock,
            tokenAddress,
            msg.sender,
            receiver,
            outputNetwork,
            outputAddress
        );
    }

    function withdraw(bytes32 id, bytes32 secret, address tokenAddress)
        external
    {
        LockContract storage c = contracts[id];

        require(c.tokenAddress == tokenAddress, "INVALID_TOKEN");

        require(c.status == ACTIVE, "SWAP_NOT_ACTIVE");

        require(c.expiration > block.timestamp, "INVALID_TIME");

        require(
            c.hashLock == sha256(abi.encodePacked(secret)),
            "INVALID_SECRET"
        );

        c.status = WITHDRAWN;

        IERC20(tokenAddress).safeTransfer(c.receiver, c.inputAmount);

        emit Withdraw(
            id,
            secret,
            c.hashLock,
            tokenAddress,
            c.sender,
            c.receiver
        );
    }

    function refund(bytes32 id, address tokenAddress) external {
        LockContract storage c = contracts[id];

        require(c.tokenAddress == tokenAddress, "INVALID_TOKEN");

        require(c.status == ACTIVE, "SWAP_NOT_ACTIVE");

        require(c.expiration <= block.timestamp, "INVALID_TIME");

        c.status = REFUNDED;

        IERC20(tokenAddress).safeTransfer(c.sender, c.inputAmount);

        emit Refund(id, c.hashLock, tokenAddress, c.sender, c.receiver);
    }

    function getStatus(bytes32[] memory ids)
        public
        view
        returns (uint256[] memory)
    {
        uint256[] memory result = new uint256[](ids.length);

        for (uint256 index = 0; index < ids.length; index++) {
            result[index] = getSingleStatus(ids[index]);
        }

        return result;
    }

    function getSingleStatus(bytes32 id) public view returns (uint256 result) {
        LockContract memory tempContract = contracts[id];

        if (
            tempContract.status == ACTIVE &&
            tempContract.expiration < block.timestamp
        ) {
            result = EXPIRED;
        } else {
            result = tempContract.status;
        }
    }
}

Read Contract

ACTIVE 0xc90bd047 → uint256
EXPIRED 0x414ac85b → uint256
INVALID 0x7fcce2a9 → uint256
REFUNDED 0x94e15c8f → uint256
WITHDRAWN 0xaf78feef → uint256
contracts 0xec56a373 → uint256, uint256, uint256, uint256, bytes32, address, address, address, string, string
getSingleStatus 0xfbdf3b43 → uint256
getStatus 0x2f21a663 → uint256[]

Write Contract 3 functions

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

newContract 0xd2fd8b76
uint256 inputAmount
uint256 outputAmount
uint256 expiration
bytes32 hashLock
address tokenAddress
address receiver
string outputNetwork
string outputAddress
refund 0x45b4032c
bytes32 id
address tokenAddress
withdraw 0xa65b9a60
bytes32 id
bytes32 secret
address tokenAddress

Recent Transactions

This address has 1 on-chain transactions, but only 0.7% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →