ETH Price: $3,609.18 (-0.20%)

Contract

0xDbeb213b3c8B08C240013f38122dC154f70E6422

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Refund1151239172024-01-21 14:16:51317 days ago1705846611IN
0xDbeb213b...4f70E6422
0 ETH0.0000308922290.00409215
Refund1151239082024-01-21 14:16:33317 days ago1705846593IN
0xDbeb213b...4f70E6422
0 ETH0.0000322880680.0040448
Create_red_packe...1149519162024-01-17 14:43:29321 days ago1705502609IN
0xDbeb213b...4f70E6422
0 ETH0.0001483346330.00802969
Claim1149518292024-01-17 14:40:35321 days ago1705502435IN
0xDbeb213b...4f70E6422
0 ETH0.0000756348670.00692011
Create_red_packe...1149518112024-01-17 14:39:59321 days ago1705502399IN
0xDbeb213b...4f70E6422
0 ETH0.0001348203060.00707703
Claim1149517672024-01-17 14:38:31321 days ago1705502311IN
0xDbeb213b...4f70E6422
0 ETH0.000083120950.00664674
Claim1149517422024-01-17 14:37:41321 days ago1705502261IN
0xDbeb213b...4f70E6422
0 ETH0.0000860100930.00645194
Create_red_packe...1149516992024-01-17 14:36:15321 days ago1705502175IN
0xDbeb213b...4f70E6422
0 ETH0.0001468842380.00612514
Claim1149515782024-01-17 14:32:13321 days ago1705501933IN
0xDbeb213b...4f70E6422
0 ETH0.000075080270.00576856
Create_red_packe...1149515452024-01-17 14:31:07321 days ago1705501867IN
0xDbeb213b...4f70E6422
0 ETH0.0001188959110.00599875
Claim1149514632024-01-17 14:28:23321 days ago1705501703IN
0xDbeb213b...4f70E6422
0 ETH0.0000807117460.00634366
Claim1149514262024-01-17 14:27:09321 days ago1705501629IN
0xDbeb213b...4f70E6422
0 ETH0.0000753157250.0061154
Create_red_packe...1149514032024-01-17 14:26:23321 days ago1705501583IN
0xDbeb213b...4f70E6422
0 ETH0.0001316026230.00630889
Claim1149258952024-01-17 0:16:07321 days ago1705450567IN
0xDbeb213b...4f70E6422
0 ETH0.000178258590.10235333
Claim1149109222024-01-16 15:57:01322 days ago1705420621IN
0xDbeb213b...4f70E6422
0 ETH0.0000849720110.09748016
Claim1149086042024-01-16 14:39:45322 days ago1705415985IN
0xDbeb213b...4f70E6422
0 ETH0.0001533053820.0144104
Claim1149085902024-01-16 14:39:17322 days ago1705415957IN
0xDbeb213b...4f70E6422
0 ETH0.0001558791870.01597638
Claim1149085842024-01-16 14:39:05322 days ago1705415945IN
0xDbeb213b...4f70E6422
0 ETH0.0001525988440.02584532
Create_red_packe...1149085672024-01-16 14:38:31322 days ago1705415911IN
0xDbeb213b...4f70E6422
0 ETH0.0001982859590.01422663
Claim1148206622024-01-14 13:48:21324 days ago1705240101IN
0xDbeb213b...4f70E6422
0 ETH0.0001819755120.00427486
Claim1148206572024-01-14 13:48:11324 days ago1705240091IN
0xDbeb213b...4f70E6422
0 ETH0.0001453459870.00434547
Claim1148203772024-01-14 13:38:51324 days ago1705239531IN
0xDbeb213b...4f70E6422
0 ETH0.0001004455980.00624188
Claim1148203722024-01-14 13:38:41324 days ago1705239521IN
0xDbeb213b...4f70E6422
0 ETH0.0001456654280.00620097
Claim1148201952024-01-14 13:32:47324 days ago1705239167IN
0xDbeb213b...4f70E6422
0 ETH0.0001166260370.00469999
Claim1148201952024-01-14 13:32:47324 days ago1705239167IN
0xDbeb213b...4f70E6422
0 ETH0.0001478339430.00469999
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
HappyRedPacket

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 9 : HappyRedPacket.sol
// SPDX-License-Identifier: MIT

/**
 * @author          Yisi Liu
 * @contact         [email protected]
 * @author_time     04/20/2021
 * @maintainer      Hancheng Zhou, Yisi Liu
 * @maintain_time   05/21/2021
**/

pragma solidity >= 0.8.0;
import "../lib/IERC20.sol";
import "../lib/SafeERC20.sol";
import "../lib/Initializable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";

contract HappyRedPacket is Initializable {
    using SafeMath for uint256;

    struct RedPacket {
        Packed packed;
        mapping(address => uint256) claimed_list;
        bytes32 merkleroot;
        address creator;
    }

    struct Packed {
        uint256 packed1;            // 0 (128) total_tokens (96) expire_time(32)
        uint256 packed2;            // 0 (64) token_addr (160) claimed_numbers(15) total_numbers(15) token_type(1) ifrandom(1)
    }

    event CreationSuccess(
        uint total,
        bytes32 id,
        string name,
        string message,
        address creator,
        uint creation_time,
        address token_address,
        uint number,
        bool ifrandom,
        uint duration
    );

    event ClaimSuccess(
        bytes32 id,
        address claimer,
        uint claimed_value,
        address token_address
    );

    event RefundSuccess(
        bytes32 id,
        address token_address,
        uint remaining_balance
    );

    using SafeERC20 for IERC20;
    uint32 nonce;
    mapping(bytes32 => RedPacket) redpacket_by_id;
    bytes32 private seed;
    uint256 constant MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

    function initialize() public initializer {
        seed = keccak256(abi.encodePacked("Dapp Learning Redpacket", block.timestamp, msg.sender));
    }

    // Inits a red packet instance
    // _token_type: 0 - ETH  1 - ERC20
    function create_red_packet (bytes32 _merkleroot, uint _number, bool _ifrandom, uint _duration, 
                                bytes32 _seed, string memory _message, string memory _name,
                                uint _token_type, address _token_addr, uint _total_tokens) 
    public payable {
        nonce ++;
        require(_total_tokens >= _number, "#tokens > #packets");
        require(_number > 0, "At least 1 recipient");
        require(_number < 256, "At most 255 recipients");
        require(_token_type == 0 || _token_type == 1, "Unrecognizable token type");

        // require minium 0.1 for each user
        require(_total_tokens > 10**(IERC20(_token_addr).decimals() - 1) * _number , "At least 0.1 for each user");
        
        uint256 received_amount = _total_tokens;
        if (_token_type == 0)
            require(msg.value >= _total_tokens, "No enough ETH");
        else if (_token_type == 1) {
            // https://github.com/DimensionDev/Maskbook/issues/4168
            // `received_amount` is not necessarily equal to `_total_tokens`
            uint256 balance_before_transfer = IERC20(_token_addr).balanceOf(address(this));
            IERC20(_token_addr).safeTransferFrom(msg.sender, address(this), _total_tokens);
            uint256 balance_after_transfer = IERC20(_token_addr).balanceOf(address(this));
            received_amount = balance_after_transfer.sub(balance_before_transfer);
            require(received_amount >= _number, "#received > #packets");
        }

        bytes32 _id = keccak256(abi.encodePacked(msg.sender, block.timestamp, nonce, seed, _seed));
        {
            uint _random_type = _ifrandom ? 1 : 0;
            RedPacket storage redp = redpacket_by_id[_id];
            redp.packed.packed1 = wrap1(received_amount, _duration);
            redp.packed.packed2 = wrap2(_token_addr, _number, _token_type, _random_type);
            redp.merkleroot = _merkleroot;
            redp.creator = msg.sender;
        }
        {
            // as a workaround for "CompilerError: Stack too deep, try removing local variables"
            uint number = _number;
            bool ifrandom = _ifrandom;
            uint duration = _duration;
            emit CreationSuccess(received_amount, _id, _name, _message, msg.sender, block.timestamp, _token_addr, number, ifrandom, duration);
        }
    }

    // It takes the signed msg.sender message as verification passcode
    function claim(bytes32 id, bytes32[] memory proof) 
    public returns (uint claimed) {

        RedPacket storage rp = redpacket_by_id[id];
        Packed memory packed = rp.packed;
        // Unsuccessful
        require (unbox(packed.packed1, 224, 32) > block.timestamp, "Expired");
        uint total_number = unbox(packed.packed2, 239, 15);
        uint claimed_number = unbox(packed.packed2, 224, 15);
        require (claimed_number < total_number, "Out of stock");
        
        bytes32 merkleroot = rp.merkleroot;
        require(MerkleProof.verify(proof, merkleroot, _leaf(msg.sender)), 'Verification failed');

        uint256 claimed_tokens;
        uint256 token_type = unbox(packed.packed2, 254, 1);
        uint256 ifrandom = unbox(packed.packed2, 255, 1);
        uint256 remaining_tokens = unbox(packed.packed1, 128, 96);
        // get token decimal
        address token_address = address(uint160(unbox(packed.packed2, 64, 160)));
        uint minium_value = 10**(IERC20(token_address).decimals() - 1);

        if (ifrandom == 1) {
            if (total_number - claimed_number == 1)
                claimed_tokens = remaining_tokens;
            else{
                // reserve minium amount => (total_number - claimed_number) * 0.1
                uint reserve_amount = (total_number - claimed_number) * minium_value;
                uint distribute_tokens = remaining_tokens - reserve_amount;
                claimed_tokens = random(seed, nonce) % SafeMath.div(SafeMath.mul(distribute_tokens, 2), total_number - claimed_number);
                // minium claimed_tokens for user is 0.1 ; and round the claimed_tokens to decimal 0.1
                claimed_tokens = claimed_tokens < minium_value ? minium_value : (claimed_tokens - (claimed_tokens % minium_value));
            }
        } else {
            if (total_number - claimed_number == 1) 
                claimed_tokens = remaining_tokens;
            else
                claimed_tokens = SafeMath.div(remaining_tokens, (total_number - claimed_number));
        }

        rp.packed.packed1 = rewriteBox(packed.packed1, 128, 96, remaining_tokens - claimed_tokens);

        // Penalize greedy attackers by placing duplication check at the very last
        require(rp.claimed_list[msg.sender] == 0, "Already claimed");

        rp.claimed_list[msg.sender] = claimed_tokens;
        rp.packed.packed2 = rewriteBox(packed.packed2, 224, 15, claimed_number + 1);

        // Transfer the red packet after state changing
        if (token_type == 0)
            payable(msg.sender).transfer(claimed_tokens);
        else if (token_type == 1)
            transfer_token(token_address, msg.sender, claimed_tokens);
        // Claim success event
        emit ClaimSuccess(id, msg.sender, claimed_tokens, token_address);
        return claimed_tokens;
    }

    // Returns 1. remaining value 2. total number of red packets 3. claimed number of red packets
    function check_availability(bytes32 id) external view returns ( address token_address, uint balance, uint total, 
                                                                    uint claimed, bool expired, uint256 claimed_amount) {
        RedPacket storage rp = redpacket_by_id[id];
        Packed memory packed = rp.packed;
        return (
            address(uint160(unbox(packed.packed2, 64, 160))), 
            unbox(packed.packed1, 128, 96), 
            unbox(packed.packed2, 239, 15), 
            unbox(packed.packed2, 224, 15), 
            block.timestamp > unbox(packed.packed1, 224, 32), 
            rp.claimed_list[msg.sender]
        );
    }

    function _leaf(address account) internal pure returns (bytes32){
        return keccak256(abi.encodePacked(account));
    }

    function refund(bytes32 id) public {
        RedPacket storage rp = redpacket_by_id[id];
        Packed memory packed = rp.packed;
        address creator = rp.creator;
        require(creator == msg.sender, "Creator Only");
        require(unbox(packed.packed1, 224, 32) <= block.timestamp, "Not expired yet");
        uint256 remaining_tokens = unbox(packed.packed1, 128, 96);
        require(remaining_tokens != 0, "None left in the red packet");

        uint256 token_type = unbox(packed.packed2, 254, 1);
        address token_address = address(uint160(unbox(packed.packed2, 64, 160)));

        rp.packed.packed1 = rewriteBox(packed.packed1, 128, 96, 0);

        if (token_type == 0) {
            payable(msg.sender).transfer(remaining_tokens);
        }
        else if (token_type == 1) {
            transfer_token(token_address, msg.sender, remaining_tokens);
        }

        emit RefundSuccess(id, token_address, remaining_tokens);
    }

//------------------------------------------------------------------
    /**
     * position      position in a memory block
     * size          data size
     * data          data
     * box() inserts the data in a 256bit word with the given position and returns it
     * data is checked by validRange() to make sure it is not over size 
    **/

    function box (uint16 position, uint16 size, uint256 data) internal pure returns (uint256 boxed) {
        require(validRange(size, data), "Value out of range BOX");
        assembly {
            // data << position
            boxed := shl(position, data)
        }
    }

    /**
     * position      position in a memory block
     * size          data size
     * base          base data
     * unbox() extracts the data out of a 256bit word with the given position and returns it
     * base is checked by validRange() to make sure it is not over size 
    **/

    function unbox (uint256 base, uint16 position, uint16 size) internal pure returns (uint256 unboxed) {
        require(validRange(256, base), "Value out of range UNBOX");
        assembly {
            // (((1 << size) - 1) & base >> position)
            unboxed := and(sub(shl(size, 1), 1), shr(position, base))

        }
    }

    /**
     * size          data size
     * data          data
     * validRange()  checks if the given data is over the specified data size
    **/

    function validRange (uint16 size, uint256 data) internal pure returns(bool ifValid) { 
        assembly {
            // 2^size > data or size ==256
            ifValid := or(eq(size, 256), gt(shl(size, 1), data))
        }
    }

    /**
     * _box          32byte data to be modified
     * position      position in a memory block
     * size          data size
     * data          data to be inserted
     * rewriteBox() updates a 32byte word with a data at the given position with the specified size
    **/

    function rewriteBox (uint256 _box, uint16 position, uint16 size, uint256 data) 
                        internal pure returns (uint256 boxed) {
        assembly {
            // mask = ~((1 << size - 1) << position)
            // _box = (mask & _box) | ()data << position)
            boxed := or( and(_box, not(shl(position, sub(shl(size, 1), 1)))), shl(position, data))
        }
    }

    function transfer_token(address token_address, address recipient_address, uint amount) internal{
        IERC20(token_address).safeTransfer(recipient_address, amount);
    }
    
    // A boring wrapper
    function random(bytes32 _seed, uint32 nonce_rand) internal view returns (uint rand) {
        return uint(keccak256(abi.encodePacked(nonce_rand, msg.sender, _seed, block.timestamp))) + 1 ;
    }
    
    function wrap1 (uint _total_tokens, uint _duration) internal view returns (uint256 packed1) {
        uint256 _packed1 = 0;
        _packed1 |= box(128, 96, _total_tokens);        // total tokens = 80 bits = ~8 * 10^10 18 decimals
        _packed1 |= box(224, 32, (block.timestamp + _duration));    // expiration_time = 32 bits (until 2106)
        return _packed1;
    }

    function wrap2 (address _token_addr, uint _number, uint _token_type, uint _ifrandom) internal pure returns (uint256 packed2) {
        uint256 _packed2 = 0;
        _packed2 |= box(64, 160, uint160(_token_addr));    // token_address = 160 bits
        _packed2 |= box(224, 15, 0);                   // claimed_number = 14 bits 16384
        _packed2 |= box(239, 15, _number);               // total_number = 14 bits 16384
        _packed2 |= box(254, 1, _token_type);             // token_type = 1 bit 2
        _packed2 |= box(255, 1, _ifrandom);                 // ifrandom = 1 bit 2
        return _packed2;
    }
}

File 2 of 9 : IERC20.sol
//SPDX-License-Identifier: UNLICENSED

pragma solidity ^0.8.0;

interface IERC20 {
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event Transfer(address indexed from, address indexed to, uint256 value);

    function allowance(address owner, address spender) external view returns (uint256);

    function approve(address spender, uint256 value) external returns (bool);

    function transfer(address to, uint256 value) external returns (bool);

    function transferFrom(
        address from,
        address to,
        uint256 value
    ) external returns (bool);

    function totalSupply() external view returns (uint256);

    function balanceOf(address owner) external view returns (uint256);

    function name() external pure returns (string memory);

    function symbol() external pure returns (string memory);

    function decimals() external pure returns (uint8);
}

File 3 of 9 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    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));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    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'
        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) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _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. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 4 of 9 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "./Address.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !Address.isContract(address(this));
    }
}

File 5 of 9 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // 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 (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @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) {
        return a + b;
    }

    /**
     * @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 a - b;
    }

    /**
     * @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) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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 a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting 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.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 6 of 9 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 7 of 9 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];
            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = _efficientHash(computedHash, proofElement);
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = _efficientHash(proofElement, computedHash);
            }
        }
        return computedHash;
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 8 of 9 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 9 of 9 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"claimed_value","type":"uint256"},{"indexed":false,"internalType":"address","name":"token_address","type":"address"}],"name":"ClaimSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"total","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256","name":"creation_time","type":"uint256"},{"indexed":false,"internalType":"address","name":"token_address","type":"address"},{"indexed":false,"internalType":"uint256","name":"number","type":"uint256"},{"indexed":false,"internalType":"bool","name":"ifrandom","type":"bool"},{"indexed":false,"internalType":"uint256","name":"duration","type":"uint256"}],"name":"CreationSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":false,"internalType":"address","name":"token_address","type":"address"},{"indexed":false,"internalType":"uint256","name":"remaining_balance","type":"uint256"}],"name":"RefundSuccess","type":"event"},{"inputs":[{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"check_availability","outputs":[{"internalType":"address","name":"token_address","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"claimed","type":"uint256"},{"internalType":"bool","name":"expired","type":"bool"},{"internalType":"uint256","name":"claimed_amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"claim","outputs":[{"internalType":"uint256","name":"claimed","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleroot","type":"bytes32"},{"internalType":"uint256","name":"_number","type":"uint256"},{"internalType":"bool","name":"_ifrandom","type":"bool"},{"internalType":"uint256","name":"_duration","type":"uint256"},{"internalType":"bytes32","name":"_seed","type":"bytes32"},{"internalType":"string","name":"_message","type":"string"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint256","name":"_token_type","type":"uint256"},{"internalType":"address","name":"_token_addr","type":"address"},{"internalType":"uint256","name":"_total_tokens","type":"uint256"}],"name":"create_red_packet","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"refund","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506119e1806100206000396000f3fe60806040526004361061004a5760003560e01c80636bfdaece1461004f5780637249fbb6146100ad5780638129fc1c146100cf578063e923849d146100e4578063f5c05eb7146100f7575b600080fd5b34801561005b57600080fd5b5061006f61006a3660046114a3565b610125565b604080516001600160a01b03909716875260208701959095529385019290925260608401521515608083015260a082015260c0015b60405180910390f35b3480156100b957600080fd5b506100cd6100c83660046114a3565b6101d3565b005b3480156100db57600080fd5b506100cd6103df565b6100cd6100f236600461156f565b6104f8565b34801561010357600080fd5b506101176101123660046114bb565b610a44565b6040519081526020016100a4565b60008181526001602081815260408084208151808301835281548152938101549284018390528493849384938493849390929091610165919060a0610ece565b81516101749060806060610ece565b610185836020015160ef600f610ece565b610196846020015160e0600f610ece565b84516101a59060e06020610ece565b3360009081526002909701602052604090962054939d929c50909a5098504293909311965094509092505050565b600081815260016020818152604092839020835180850190945280548452918201549083015260048101549091906001600160a01b031633811461024d5760405162461bcd60e51b815260206004820152600c60248201526b43726561746f72204f6e6c7960a01b60448201526064015b60405180910390fd5b4261025f836000015160e06020610ece565b111561029f5760405162461bcd60e51b815260206004820152600f60248201526e139bdd08195e1c1a5c9959081e595d608a1b6044820152606401610244565b60006102b2836000015160806060610ece565b9050806103015760405162461bcd60e51b815260206004820152601b60248201527f4e6f6e65206c65667420696e2074686520726564207061636b657400000000006044820152606401610244565b6000610314846020015160fe6001610ece565b905060006103298560200151604060a0610ece565b85516bffffffffffffffffffffffff60801b1916875590508161037957604051339084156108fc029085906000818181858888f19350505050158015610373573d6000803e3d6000fd5b5061038d565b816001141561038d5761038d813385610ede565b604080518881526001600160a01b03831660208201529081018490527f66c304c539e0bc7c8070207c09b9f6a5a9591b434dfed1867cc57fde7fb600939060600160405180910390a150505050505050565b600054610100900460ff166103fa5760005460ff16156103fe565b303b155b6104615760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610244565b600054610100900460ff16158015610483576000805461ffff19166101011790555b6040517f44617070204c6561726e696e67205265647061636b657400000000000000000060208201524260378201526001600160601b03193360601b166057820152606b0160408051601f19818403018152919052805160209091012060025580156104f5576000805461ff00191690555b50565b6000805462010000900463ffffffff1690600261051483611923565b91906101000a81548163ffffffff021916908363ffffffff16021790555050888110156105785760405162461bcd60e51b815260206004820152601260248201527123746f6b656e73203e20237061636b65747360701b6044820152606401610244565b600089116105bf5760405162461bcd60e51b8152602060048201526014602482015273105d081b19585cdd080c481c9958da5c1a595b9d60621b6044820152606401610244565b61010089106106095760405162461bcd60e51b81526020600482015260166024820152754174206d6f73742032353520726563697069656e747360501b6044820152606401610244565b8215806106165750826001145b6106625760405162461bcd60e51b815260206004820152601960248201527f556e7265636f676e697a61626c6520746f6b656e2074797065000000000000006044820152606401610244565b886001836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561069e57600080fd5b505afa1580156106b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d69190611645565b6106e091906118b9565b6106eb90600a6117d8565b6106f59190611883565b81116107435760405162461bcd60e51b815260206004820152601a60248201527f4174206c6561737420302e3120666f72206561636820757365720000000000006044820152606401610244565b808361078e57813410156107895760405162461bcd60e51b815260206004820152600d60248201526c09cde40cadcdeeaced0408aa89609b1b6044820152606401610244565b6108fa565b83600114156108fa576040516370a0823160e01b81523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b1580156107d957600080fd5b505afa1580156107ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610811919061162d565b90506108286001600160a01b038516333086610ef7565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a082319060240160206040518083038186803b15801561086a57600080fd5b505afa15801561087e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a2919061162d565b90506108ae8183610f68565b92508b8310156108f75760405162461bcd60e51b8152602060048201526014602482015273237265636569766564203e20237061636b65747360601b6044820152606401610244565b50505b600080546002546040513360601b6001600160601b03191660208201524260348201526201000090920460e01b6001600160e01b031916605483015260588201526078810189905260980160405160208183030381529060405280519060200120905060008a61096b57600061096e565b60015b600083815260016020526040902060ff91909116915061098e848c610f7b565b815561099c868e8985610faa565b81600001600101819055508d8160030181905550338160040160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550505060008b905060008b905060008b90507f86af556fd7cfab9462285ad44f2d5913527c539ff549f74731ca9997ca53401885858b8d33428d8a8a8a604051610a2b9a999897969594939291906116c1565b60405180910390a1505050505050505050505050505050565b60008281526001602081815260408084208151808301909252805480835293810154828401529290914291610a7b9160e090610ece565b11610ab25760405162461bcd60e51b8152602060048201526007602482015266115e1c1a5c995960ca1b6044820152606401610244565b6000610ac5826020015160ef600f610ece565b90506000610ada836020015160e0600f610ece565b9050818110610b1a5760405162461bcd60e51b815260206004820152600c60248201526b4f7574206f662073746f636b60a01b6044820152606401610244565b6003840154610b678782610b62336040516001600160601b0319606083901b166020820152600090603401604051602081830303815290604052805190602001209050919050565b611006565b610ba95760405162461bcd60e51b815260206004820152601360248201527215995c9a599a58d85d1a5bdb8819985a5b1959606a1b6044820152606401610244565b600080610bbd866020015160fe6001610ece565b90506000610bd2876020015160ff6001610ece565b90506000610be7886000015160806060610ece565b90506000610bfc8960200151604060a0610ece565b905060006001826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610c3b57600080fd5b505afa158015610c4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c739190611645565b610c7d91906118b9565b610c8890600a6117d8565b90508360011415610d4457610c9d888a6118a2565b60011415610cad57829550610d6f565b600081610cba8a8c6118a2565b610cc49190611883565b90506000610cd282866118a2565b9050610cf1610ce282600261101c565b610cec8c8e6118a2565b611028565b600254600054610d0d919062010000900463ffffffff16611034565b610d179190611947565b9750828810610d3957610d2a8389611947565b610d3490896118a2565b610d3b565b825b97505050610d6f565b610d4e888a6118a2565b60011415610d5e57829550610d6f565b610d6c83610cec8a8c6118a2565b95505b8951610d9a9060806060610d838a886118a2565b821b600190911b6000190190911b19919091161790565b8b5533600090815260028c01602052604090205415610ded5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b6044820152606401610244565b33600090815260028c01602090815260409091208790558a0151610e1a9060e0600f610d838c6001611769565b60018c015584610e5757604051339087156108fc029088906000818181858888f19350505050158015610e51573d6000803e3d6000fd5b50610e6b565b8460011415610e6b57610e6b823388610ede565b604080518f81523360208201529081018790526001600160a01b03831660608201527f358ddd686a5ca3ef6f8aee9b8d2dc3c642ecc278657c3802f8802b1a44c10e449060800160405180910390a1509399505050505050505050505b92915050565b600019600190911b0191901c1690565b610ef26001600160a01b0384168383611094565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610f629085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526110c4565b50505050565b6000610f7482846118a2565b9392505050565b600080610f8b6080606086611196565b17610fa260e06020610f9d8642611769565b611196565b179392505050565b600080610fc3604060a06001600160a01b038916611196565b17610fd260e0600f6000611196565b17610fe060ef600f87611196565b17610fee60fe600186611196565b17610ffc60ff600185611196565b1795945050505050565b60008261101385846111f2565b14949350505050565b6000610f748284611883565b6000610f748284611781565b6040516001600160e01b031960e083901b1660208201526001600160601b03193360601b1660248201526038810183905242605882015260009060780160408051601f198184030181529190528051602090910120610f74906001611769565b6040516001600160a01b038316602482015260448101829052610ef290849063a9059cbb60e01b90606401610f2b565b6000611119826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112749092919063ffffffff16565b805190915015610ef257808060200190518101906111379190611487565b610ef25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610244565b60006001831b82106101008414176111e95760405162461bcd60e51b81526020600482015260166024820152750acc2d8eaca40deeae840decc40e4c2dcceca40849eb60531b6044820152606401610244565b5090911b919050565b600081815b845181101561126c57600085828151811061122257634e487b7160e01b600052603260045260246000fd5b602002602001015190508083116112485760008381526020829052604090209250611259565b600081815260208490526040902092505b508061126481611908565b9150506111f7565b509392505050565b6060611283848460008561128b565b949350505050565b6060824710156112ec5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610244565b6001600160a01b0385163b6113435760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610244565b600080866001600160a01b0316858760405161135f9190611692565b60006040518083038185875af1925050503d806000811461139c576040519150601f19603f3d011682016040523d82523d6000602084013e6113a1565b606091505b50915091506113b18282866113bc565b979650505050505050565b606083156113cb575081610f74565b8251156113db5782518084602001fd5b8160405162461bcd60e51b815260040161024491906116ae565b80356001600160a01b038116811461140c57600080fd5b919050565b803561140c8161199d565b600082601f83011261142c578081fd5b813567ffffffffffffffff81111561144657611446611987565b611459601f8201601f1916602001611738565b81815284602083860101111561146d578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215611498578081fd5b8151610f748161199d565b6000602082840312156114b4578081fd5b5035919050565b600080604083850312156114cd578081fd5b8235915060208084013567ffffffffffffffff808211156114ec578384fd5b818601915086601f8301126114ff578384fd5b81358181111561151157611511611987565b8060051b9150611522848301611738565b8181528481019084860184860187018b101561153c578788fd5b8795505b8386101561155e578035835260019590950194918601918601611540565b508096505050505050509250929050565b6000806000806000806000806000806101408b8d03121561158e578586fd5b8a35995060208b013598506115a560408c01611411565b975060608b0135965060808b0135955060a08b013567ffffffffffffffff808211156115cf578687fd5b6115db8e838f0161141c565b965060c08d01359150808211156115f0578586fd5b506115fd8d828e0161141c565b94505060e08b013592506116146101008c016113f5565b91506101208b013590509295989b9194979a5092959850565b60006020828403121561163e578081fd5b5051919050565b600060208284031215611656578081fd5b815160ff81168114610f74578182fd5b6000815180845261167e8160208601602086016118dc565b601f01601f19169290920160200192915050565b600082516116a48184602087016118dc565b9190910192915050565b602081526000610f746020830184611666565b60006101408c83528b60208401528060408401526116e18184018c611666565b905082810360608401526116f5818b611666565b6001600160a01b03998a16608085015260a084019890985250509390951660c084015260e083019190915215156101008201526101200191909152949350505050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561176157611761611987565b604052919050565b6000821982111561177c5761177c61195b565b500190565b60008261179057611790611971565b500490565b600181815b808511156117d05781600019048211156117b6576117b661195b565b808516156117c357918102915b93841c939080029061179a565b509250929050565b6000610f7460ff8416836000826117f157506001610ec8565b816117fe57506000610ec8565b8160018114611814576002811461181e5761183a565b6001915050610ec8565b60ff84111561182f5761182f61195b565b50506001821b610ec8565b5060208310610133831016604e8410600b841016171561185d575081810a610ec8565b6118678383611795565b806000190482111561187b5761187b61195b565b029392505050565b600081600019048311821515161561189d5761189d61195b565b500290565b6000828210156118b4576118b461195b565b500390565b600060ff821660ff8416808210156118d3576118d361195b565b90039392505050565b60005b838110156118f75781810151838201526020016118df565b83811115610f625750506000910152565b600060001982141561191c5761191c61195b565b5060010190565b600063ffffffff8083168181141561193d5761193d61195b565b6001019392505050565b60008261195657611956611971565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146104f557600080fdfea26469706673582212200a61cda78a96c344f438465222b497751fdb571c5af62a5af63b273f180c25e764736f6c63430008040033

Deployed Bytecode

0x60806040526004361061004a5760003560e01c80636bfdaece1461004f5780637249fbb6146100ad5780638129fc1c146100cf578063e923849d146100e4578063f5c05eb7146100f7575b600080fd5b34801561005b57600080fd5b5061006f61006a3660046114a3565b610125565b604080516001600160a01b03909716875260208701959095529385019290925260608401521515608083015260a082015260c0015b60405180910390f35b3480156100b957600080fd5b506100cd6100c83660046114a3565b6101d3565b005b3480156100db57600080fd5b506100cd6103df565b6100cd6100f236600461156f565b6104f8565b34801561010357600080fd5b506101176101123660046114bb565b610a44565b6040519081526020016100a4565b60008181526001602081815260408084208151808301835281548152938101549284018390528493849384938493849390929091610165919060a0610ece565b81516101749060806060610ece565b610185836020015160ef600f610ece565b610196846020015160e0600f610ece565b84516101a59060e06020610ece565b3360009081526002909701602052604090962054939d929c50909a5098504293909311965094509092505050565b600081815260016020818152604092839020835180850190945280548452918201549083015260048101549091906001600160a01b031633811461024d5760405162461bcd60e51b815260206004820152600c60248201526b43726561746f72204f6e6c7960a01b60448201526064015b60405180910390fd5b4261025f836000015160e06020610ece565b111561029f5760405162461bcd60e51b815260206004820152600f60248201526e139bdd08195e1c1a5c9959081e595d608a1b6044820152606401610244565b60006102b2836000015160806060610ece565b9050806103015760405162461bcd60e51b815260206004820152601b60248201527f4e6f6e65206c65667420696e2074686520726564207061636b657400000000006044820152606401610244565b6000610314846020015160fe6001610ece565b905060006103298560200151604060a0610ece565b85516bffffffffffffffffffffffff60801b1916875590508161037957604051339084156108fc029085906000818181858888f19350505050158015610373573d6000803e3d6000fd5b5061038d565b816001141561038d5761038d813385610ede565b604080518881526001600160a01b03831660208201529081018490527f66c304c539e0bc7c8070207c09b9f6a5a9591b434dfed1867cc57fde7fb600939060600160405180910390a150505050505050565b600054610100900460ff166103fa5760005460ff16156103fe565b303b155b6104615760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610244565b600054610100900460ff16158015610483576000805461ffff19166101011790555b6040517f44617070204c6561726e696e67205265647061636b657400000000000000000060208201524260378201526001600160601b03193360601b166057820152606b0160408051601f19818403018152919052805160209091012060025580156104f5576000805461ff00191690555b50565b6000805462010000900463ffffffff1690600261051483611923565b91906101000a81548163ffffffff021916908363ffffffff16021790555050888110156105785760405162461bcd60e51b815260206004820152601260248201527123746f6b656e73203e20237061636b65747360701b6044820152606401610244565b600089116105bf5760405162461bcd60e51b8152602060048201526014602482015273105d081b19585cdd080c481c9958da5c1a595b9d60621b6044820152606401610244565b61010089106106095760405162461bcd60e51b81526020600482015260166024820152754174206d6f73742032353520726563697069656e747360501b6044820152606401610244565b8215806106165750826001145b6106625760405162461bcd60e51b815260206004820152601960248201527f556e7265636f676e697a61626c6520746f6b656e2074797065000000000000006044820152606401610244565b886001836001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561069e57600080fd5b505afa1580156106b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d69190611645565b6106e091906118b9565b6106eb90600a6117d8565b6106f59190611883565b81116107435760405162461bcd60e51b815260206004820152601a60248201527f4174206c6561737420302e3120666f72206561636820757365720000000000006044820152606401610244565b808361078e57813410156107895760405162461bcd60e51b815260206004820152600d60248201526c09cde40cadcdeeaced0408aa89609b1b6044820152606401610244565b6108fa565b83600114156108fa576040516370a0823160e01b81523060048201526000906001600160a01b038516906370a082319060240160206040518083038186803b1580156107d957600080fd5b505afa1580156107ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610811919061162d565b90506108286001600160a01b038516333086610ef7565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a082319060240160206040518083038186803b15801561086a57600080fd5b505afa15801561087e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a2919061162d565b90506108ae8183610f68565b92508b8310156108f75760405162461bcd60e51b8152602060048201526014602482015273237265636569766564203e20237061636b65747360601b6044820152606401610244565b50505b600080546002546040513360601b6001600160601b03191660208201524260348201526201000090920460e01b6001600160e01b031916605483015260588201526078810189905260980160405160208183030381529060405280519060200120905060008a61096b57600061096e565b60015b600083815260016020526040902060ff91909116915061098e848c610f7b565b815561099c868e8985610faa565b81600001600101819055508d8160030181905550338160040160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550505060008b905060008b905060008b90507f86af556fd7cfab9462285ad44f2d5913527c539ff549f74731ca9997ca53401885858b8d33428d8a8a8a604051610a2b9a999897969594939291906116c1565b60405180910390a1505050505050505050505050505050565b60008281526001602081815260408084208151808301909252805480835293810154828401529290914291610a7b9160e090610ece565b11610ab25760405162461bcd60e51b8152602060048201526007602482015266115e1c1a5c995960ca1b6044820152606401610244565b6000610ac5826020015160ef600f610ece565b90506000610ada836020015160e0600f610ece565b9050818110610b1a5760405162461bcd60e51b815260206004820152600c60248201526b4f7574206f662073746f636b60a01b6044820152606401610244565b6003840154610b678782610b62336040516001600160601b0319606083901b166020820152600090603401604051602081830303815290604052805190602001209050919050565b611006565b610ba95760405162461bcd60e51b815260206004820152601360248201527215995c9a599a58d85d1a5bdb8819985a5b1959606a1b6044820152606401610244565b600080610bbd866020015160fe6001610ece565b90506000610bd2876020015160ff6001610ece565b90506000610be7886000015160806060610ece565b90506000610bfc8960200151604060a0610ece565b905060006001826001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b158015610c3b57600080fd5b505afa158015610c4f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c739190611645565b610c7d91906118b9565b610c8890600a6117d8565b90508360011415610d4457610c9d888a6118a2565b60011415610cad57829550610d6f565b600081610cba8a8c6118a2565b610cc49190611883565b90506000610cd282866118a2565b9050610cf1610ce282600261101c565b610cec8c8e6118a2565b611028565b600254600054610d0d919062010000900463ffffffff16611034565b610d179190611947565b9750828810610d3957610d2a8389611947565b610d3490896118a2565b610d3b565b825b97505050610d6f565b610d4e888a6118a2565b60011415610d5e57829550610d6f565b610d6c83610cec8a8c6118a2565b95505b8951610d9a9060806060610d838a886118a2565b821b600190911b6000190190911b19919091161790565b8b5533600090815260028c01602052604090205415610ded5760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818db185a5b5959608a1b6044820152606401610244565b33600090815260028c01602090815260409091208790558a0151610e1a9060e0600f610d838c6001611769565b60018c015584610e5757604051339087156108fc029088906000818181858888f19350505050158015610e51573d6000803e3d6000fd5b50610e6b565b8460011415610e6b57610e6b823388610ede565b604080518f81523360208201529081018790526001600160a01b03831660608201527f358ddd686a5ca3ef6f8aee9b8d2dc3c642ecc278657c3802f8802b1a44c10e449060800160405180910390a1509399505050505050505050505b92915050565b600019600190911b0191901c1690565b610ef26001600160a01b0384168383611094565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610f629085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526110c4565b50505050565b6000610f7482846118a2565b9392505050565b600080610f8b6080606086611196565b17610fa260e06020610f9d8642611769565b611196565b179392505050565b600080610fc3604060a06001600160a01b038916611196565b17610fd260e0600f6000611196565b17610fe060ef600f87611196565b17610fee60fe600186611196565b17610ffc60ff600185611196565b1795945050505050565b60008261101385846111f2565b14949350505050565b6000610f748284611883565b6000610f748284611781565b6040516001600160e01b031960e083901b1660208201526001600160601b03193360601b1660248201526038810183905242605882015260009060780160408051601f198184030181529190528051602090910120610f74906001611769565b6040516001600160a01b038316602482015260448101829052610ef290849063a9059cbb60e01b90606401610f2b565b6000611119826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166112749092919063ffffffff16565b805190915015610ef257808060200190518101906111379190611487565b610ef25760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610244565b60006001831b82106101008414176111e95760405162461bcd60e51b81526020600482015260166024820152750acc2d8eaca40deeae840decc40e4c2dcceca40849eb60531b6044820152606401610244565b5090911b919050565b600081815b845181101561126c57600085828151811061122257634e487b7160e01b600052603260045260246000fd5b602002602001015190508083116112485760008381526020829052604090209250611259565b600081815260208490526040902092505b508061126481611908565b9150506111f7565b509392505050565b6060611283848460008561128b565b949350505050565b6060824710156112ec5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610244565b6001600160a01b0385163b6113435760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610244565b600080866001600160a01b0316858760405161135f9190611692565b60006040518083038185875af1925050503d806000811461139c576040519150601f19603f3d011682016040523d82523d6000602084013e6113a1565b606091505b50915091506113b18282866113bc565b979650505050505050565b606083156113cb575081610f74565b8251156113db5782518084602001fd5b8160405162461bcd60e51b815260040161024491906116ae565b80356001600160a01b038116811461140c57600080fd5b919050565b803561140c8161199d565b600082601f83011261142c578081fd5b813567ffffffffffffffff81111561144657611446611987565b611459601f8201601f1916602001611738565b81815284602083860101111561146d578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215611498578081fd5b8151610f748161199d565b6000602082840312156114b4578081fd5b5035919050565b600080604083850312156114cd578081fd5b8235915060208084013567ffffffffffffffff808211156114ec578384fd5b818601915086601f8301126114ff578384fd5b81358181111561151157611511611987565b8060051b9150611522848301611738565b8181528481019084860184860187018b101561153c578788fd5b8795505b8386101561155e578035835260019590950194918601918601611540565b508096505050505050509250929050565b6000806000806000806000806000806101408b8d03121561158e578586fd5b8a35995060208b013598506115a560408c01611411565b975060608b0135965060808b0135955060a08b013567ffffffffffffffff808211156115cf578687fd5b6115db8e838f0161141c565b965060c08d01359150808211156115f0578586fd5b506115fd8d828e0161141c565b94505060e08b013592506116146101008c016113f5565b91506101208b013590509295989b9194979a5092959850565b60006020828403121561163e578081fd5b5051919050565b600060208284031215611656578081fd5b815160ff81168114610f74578182fd5b6000815180845261167e8160208601602086016118dc565b601f01601f19169290920160200192915050565b600082516116a48184602087016118dc565b9190910192915050565b602081526000610f746020830184611666565b60006101408c83528b60208401528060408401526116e18184018c611666565b905082810360608401526116f5818b611666565b6001600160a01b03998a16608085015260a084019890985250509390951660c084015260e083019190915215156101008201526101200191909152949350505050565b604051601f8201601f1916810167ffffffffffffffff8111828210171561176157611761611987565b604052919050565b6000821982111561177c5761177c61195b565b500190565b60008261179057611790611971565b500490565b600181815b808511156117d05781600019048211156117b6576117b661195b565b808516156117c357918102915b93841c939080029061179a565b509250929050565b6000610f7460ff8416836000826117f157506001610ec8565b816117fe57506000610ec8565b8160018114611814576002811461181e5761183a565b6001915050610ec8565b60ff84111561182f5761182f61195b565b50506001821b610ec8565b5060208310610133831016604e8410600b841016171561185d575081810a610ec8565b6118678383611795565b806000190482111561187b5761187b61195b565b029392505050565b600081600019048311821515161561189d5761189d61195b565b500290565b6000828210156118b4576118b461195b565b500390565b600060ff821660ff8416808210156118d3576118d361195b565b90039392505050565b60005b838110156118f75781810151838201526020016118df565b83811115610f625750506000910152565b600060001982141561191c5761191c61195b565b5060010190565b600063ffffffff8083168181141561193d5761193d61195b565b6001019392505050565b60008261195657611956611971565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b80151581146104f557600080fdfea26469706673582212200a61cda78a96c344f438465222b497751fdb571c5af62a5af63b273f180c25e764736f6c63430008040033

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
[ 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.