ETH Price: $3,307.89 (+2.09%)
Gas: 5 Gwei

Contract

0x59A06CB545ac15364B849eFe6E7b897b9f66E494
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Emergency Withdr...176439522023-07-07 19:18:35385 days ago1688757515IN
0x59A06CB5...b9f66E494
0 ETH0.0018689457.09139627
Emergency Withdr...168830562023-03-22 12:12:47493 days ago1679487167IN
0x59A06CB5...b9f66E494
0 ETH0.000399513.96676066
Emergency Withdr...168830482023-03-22 12:11:11493 days ago1679487071IN
0x59A06CB5...b9f66E494
0 ETH0.0085812300
Emergency Withdr...168830242023-03-22 12:06:23493 days ago1679486783IN
0x59A06CB5...b9f66E494
0 ETH0.0004728920.56050162
Claim Rewards168793222023-03-21 23:38:47493 days ago1679441927IN
0x59A06CB5...b9f66E494
0 ETH0.0004060514.41200307
Claim Rewards168781082023-03-21 19:33:23493 days ago1679427203IN
0x59A06CB5...b9f66E494
0 ETH0.0004481416.24486726
Claim Rewards168780842023-03-21 19:28:23493 days ago1679426903IN
0x59A06CB5...b9f66E494
0 ETH0.0012082918.96828437
Claim Rewards168746902023-03-21 7:59:59494 days ago1679385599IN
0x59A06CB5...b9f66E494
0 ETH0.0003373112.22738091
Claim Rewards168742822023-03-21 6:37:47494 days ago1679380667IN
0x59A06CB5...b9f66E494
0 ETH0.000305910.8573342
Claim Rewards168742332023-03-21 6:27:59494 days ago1679380079IN
0x59A06CB5...b9f66E494
0 ETH0.0003375311.98009008
Claim Rewards168735982023-03-21 4:19:35494 days ago1679372375IN
0x59A06CB5...b9f66E494
0 ETH0.0003642712.93436267
Claim Rewards168732402023-03-21 3:06:47494 days ago1679368007IN
0x59A06CB5...b9f66E494
0 ETH0.0004488215.93675013
Claim Rewards168722112023-03-20 23:39:47494 days ago1679355587IN
0x59A06CB5...b9f66E494
0 ETH0.0004391715.59409927
Claim Rewards168721832023-03-20 23:34:11494 days ago1679355251IN
0x59A06CB5...b9f66E494
0 ETH0.0004898117.38481892
Claim Rewards168721652023-03-20 23:30:35494 days ago1679355035IN
0x59A06CB5...b9f66E494
0 ETH0.0005034617.87695992
Claim Rewards168711012023-03-20 19:55:35494 days ago1679342135IN
0x59A06CB5...b9f66E494
0 ETH0.0006855824.33292881
Claim Rewards168709982023-03-20 19:34:47494 days ago1679340887IN
0x59A06CB5...b9f66E494
0 ETH0.0006795224.11803082
Claim Rewards168708482023-03-20 19:04:47494 days ago1679339087IN
0x59A06CB5...b9f66E494
0 ETH0.0019084429.93874222
Claim Rewards168708442023-03-20 19:03:59494 days ago1679339039IN
0x59A06CB5...b9f66E494
0 ETH0.0009410533.40020432
Claim Rewards168707922023-03-20 18:53:11494 days ago1679338391IN
0x59A06CB5...b9f66E494
0 ETH0.0019894131.19915517
Claim Rewards168707852023-03-20 18:51:47494 days ago1679338307IN
0x59A06CB5...b9f66E494
0 ETH0.0008323529.54219632
Transfer168706622023-03-20 18:27:11494 days ago1679336831IN
0x59A06CB5...b9f66E494
0.39790358 ETH0.0006455730.66123394
Claim Rewards168706362023-03-20 18:21:59494 days ago1679336519IN
0x59A06CB5...b9f66E494
0 ETH0.0019522430.64218014
Transfer168701322023-03-20 16:40:11494 days ago1679330411IN
0x59A06CB5...b9f66E494
0.025 ETH0.0005354325.43024592
0x60806040168698992023-03-20 15:52:59494 days ago1679327579IN
 Create: ClaimRewards
0 ETH0.0157111823.04984535

Latest 19 internal transactions

Advanced mode:
Parent Transaction Hash Block From To
176439522023-07-07 19:18:35385 days ago1688757515
0x59A06CB5...b9f66E494
0.32254449 ETH
168793222023-03-21 23:38:47493 days ago1679441927
0x59A06CB5...b9f66E494
0.00890135 ETH
168781082023-03-21 19:33:23493 days ago1679427203
0x59A06CB5...b9f66E494
0.00599112 ETH
168780842023-03-21 19:28:23493 days ago1679426903
0x59A06CB5...b9f66E494
0.008796 ETH
168746892023-03-21 7:59:47494 days ago1679385587
0x59A06CB5...b9f66E494
0.00113452 ETH
168742812023-03-21 6:37:35494 days ago1679380655
0x59A06CB5...b9f66E494
0.00189454 ETH
168742332023-03-21 6:27:59494 days ago1679380079
0x59A06CB5...b9f66E494
0.00893467 ETH
168735982023-03-21 4:19:35494 days ago1679372375
0x59A06CB5...b9f66E494
0.00433091 ETH
168732402023-03-21 3:06:47494 days ago1679368007
0x59A06CB5...b9f66E494
0.00215754 ETH
168722112023-03-20 23:39:47494 days ago1679355587
0x59A06CB5...b9f66E494
0.00757854 ETH
168721832023-03-20 23:34:11494 days ago1679355251
0x59A06CB5...b9f66E494
0.01515818 ETH
168721652023-03-20 23:30:35494 days ago1679355035
0x59A06CB5...b9f66E494
0.00189458 ETH
168711012023-03-20 19:55:35494 days ago1679342135
0x59A06CB5...b9f66E494
0.00199957 ETH
168709982023-03-20 19:34:47494 days ago1679340887
0x59A06CB5...b9f66E494
0.01332957 ETH
168708482023-03-20 19:04:47494 days ago1679339087
0x59A06CB5...b9f66E494
0.00197189 ETH
168708442023-03-20 19:03:59494 days ago1679339039
0x59A06CB5...b9f66E494
0.00788978 ETH
168707922023-03-20 18:53:11494 days ago1679338391
0x59A06CB5...b9f66E494
0.00181374 ETH
168707852023-03-20 18:51:47494 days ago1679338307
0x59A06CB5...b9f66E494
0.00437733 ETH
168706362023-03-20 18:21:59494 days ago1679336519
0x59A06CB5...b9f66E494
0.00220517 ETH
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ClaimRewards

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 5 : ClaimRewards.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract ClaimRewards is ReentrancyGuard {
    using Strings for uint256;

    address owner;
    address admin;
    bytes32 public root;

    mapping(uint256 => bool) rewardStatus;

    event Claim(uint256 _rewardId, uint256 _rewards);
    event UpdateAdmin(address oldOwner, address newOwner);
    event UpdateOwner(address oldOwner, address newOwner);

    constructor(address _admin, address _owner, bytes32 _root) {
        owner = _owner;
        admin = _admin;
        root = _root;
    }

    function setOwner(address _owner) external nonReentrant {
        require(owner == msg.sender, "not owner");
        owner = _owner;
        emit UpdateOwner(msg.sender, owner);
    }

    function setRoot(bytes32 _root) external nonReentrant {
        require(admin == msg.sender, "not owner");
        root = _root;
    }

    function setAdmin(address _admin) external nonReentrant {
        require(admin == msg.sender, "not owner");
        admin = _admin;
        emit UpdateAdmin(msg.sender, owner);
    }

    function claimRewards(
        uint256 _rewardId,
        bytes32[] memory _merkleProof,
        uint256 _rewards
    ) external {
        require(!rewardStatus[_rewardId], "already claim");

        bytes32 leafToCheck = keccak256(
            abi.encodePacked(_rewardId.toString(), ",", _rewards.toString())
        );

        require(
            MerkleProof.verify(_merkleProof, root, leafToCheck),
            "Incorrect land proof"
        );

        (bool success, ) = msg.sender.call{value: _rewards}("");
        require(success, "refund failed");

        rewardStatus[_rewardId] = true;

        emit Claim(_rewardId, _rewards);
    }

    function emergencyWithdraw() external nonReentrant {
        require(owner == msg.sender, "not owner");
        _transferETH(address(this).balance);
    }

    function _transferETH(uint256 _amount) internal {
        (bool success, ) = msg.sender.call{value: _amount}("");
        require(success, "refund failed");
    }

    receive() external payable {}
}

File 2 of 5 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 3 of 5 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * 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.
 * OpenZeppelin's JavaScript library generates merkle trees that are safe
 * against this attack out of the box.
 */
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 Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProofCalldata(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++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}.
     *
     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 4 of 5 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 5 of 5 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @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] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"bytes32","name":"_root","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_rewardId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_rewards","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"UpdateAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"UpdateOwner","type":"event"},{"inputs":[{"internalType":"uint256","name":"_rewardId","type":"uint256"},{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"},{"internalType":"uint256","name":"_rewards","type":"uint256"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"root","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_root","type":"bytes32"}],"name":"setRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b50604051610a82380380610a8283398101604081905261002f91610087565b6001600081905580546001600160a01b039384166001600160a01b031991821617909155600280549490931693169290921790556003556100c2565b80516001600160a01b038116811461008257600080fd5b919050565b60008060006060848603121561009b578283fd5b6100a48461006b565b92506100b26020850161006b565b9150604084015190509250925092565b6109b1806100d16000396000f3fe6080604052600436106100595760003560e01c806313af403514610065578063177c67cb14610087578063704b6c02146100a7578063dab5f340146100c7578063db2e21bc146100e7578063ebf0c717146100fc57600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046107a6565b610124565b005b34801561009357600080fd5b506100856100a23660046107e5565b6101c5565b3480156100b357600080fd5b506100856100c23660046107a6565b61038c565b3480156100d357600080fd5b506100856100e23660046107cd565b610419565b3480156100f357600080fd5b5061008561045a565b34801561010857600080fd5b5061011260035481565b60405190815260200160405180910390f35b61012c6104a1565b6001546001600160a01b0316331461015f5760405162461bcd60e51b81526004016101569061091b565b60405180910390fd5b600180546001600160a01b0319166001600160a01b0383169081179091556040805133815260208101929092527fe2c7d1c4da37855e682bde14f17826d185497973b73fba7554daa6da467058d991015b60405180910390a16101c26001600055565b50565b60008381526004602052604090205460ff16156102145760405162461bcd60e51b815260206004820152600d60248201526c616c726561647920636c61696d60981b6044820152606401610156565b600061021f846104fb565b610228836104fb565b6040516020016102399291906108f2565b60405160208183030381529060405280519060200120905061025e83600354836105a6565b6102a15760405162461bcd60e51b815260206004820152601460248201527324b731b7b93932b1ba103630b73210383937b7b360611b6044820152606401610156565b604051600090339084908381818185875af1925050503d80600081146102e3576040519150601f19603f3d011682016040523d82523d6000602084013e6102e8565b606091505b50509050806103295760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b6044820152606401610156565b60008581526004602052604090819020805460ff19166001179055517f022e3d29644ead4083349ca84d24bcac368b2461819b70f5921fea15de4dec4d9061037d9087908690918252602082015260400190565b60405180910390a15050505050565b6103946104a1565b6002546001600160a01b031633146103be5760405162461bcd60e51b81526004016101569061091b565b600280546001600160a01b0319166001600160a01b0383811691909117909155600154604080513381529190921660208201527fcd6ba6b7da89e039d53b5d981527a893755342bb9d8e5c2f61f6638f1fb5192b91016101b0565b6104216104a1565b6002546001600160a01b0316331461044b5760405162461bcd60e51b81526004016101569061091b565b60038190556101c26001600055565b6104626104a1565b6001546001600160a01b0316331461048c5760405162461bcd60e51b81526004016101569061091b565b610495476105bc565b61049f6001600055565b565b600260005414156104f45760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610156565b6002600055565b6060600061050883610648565b600101905060008167ffffffffffffffff81111561053657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015610560576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846105995761059e565b61056a565b509392505050565b6000826105b38584610721565b14949350505050565b604051600090339083908381818185875af1925050503d80600081146105fe576040519150601f19603f3d011682016040523d82523d6000602084013e610603565b606091505b50509050806106445760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b6044820152606401610156565b5050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106106875772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106106b3576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106106d157662386f26fc10000830492506010015b6305f5e10083106106e9576305f5e100830492506008015b61271083106106fd57612710830492506004015b6064831061070f576064830492506002015b600a831061071b576001015b92915050565b600081815b845181101561059e576107608286838151811061075357634e487b7160e01b600052603260045260246000fd5b6020026020010151610774565b91508061076c8161093e565b915050610726565b600081831061079057600082815260208490526040902061079f565b60008381526020839052604090205b9392505050565b6000602082840312156107b7578081fd5b81356001600160a01b038116811461079f578182fd5b6000602082840312156107de578081fd5b5035919050565b6000806000606084860312156107f9578182fd5b8335925060208085013567ffffffffffffffff80821115610818578485fd5b818701915087601f83011261082b578485fd5b81358181111561083d5761083d610965565b8060051b604051601f19603f8301168101818110858211171561086257610862610965565b604052828152858101935084860182860187018c1015610880578889fd5b8895505b838610156108a2578035855260019590950194938601938601610884565b50979a979950505050604095909501359450505050565b60008151815b818110156108d957602081850181015186830152016108bf565b818111156108e75782828601525b509290920192915050565b60006108fe82856108b9565b600b60fa1b815261091260018201856108b9565b95945050505050565b6020808252600990820152683737ba1037bbb732b960b91b604082015260600190565b600060001982141561095e57634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea264697066735822122033b74789b352e1754d4fecab35b4b5d62a6b6c2e0fe697f553486e4e70b37e0564736f6c6343000804003300000000000000000000000052adcb180a3e983605ce82fb9c5377e439819aa100000000000000000000000052adcb180a3e983605ce82fb9c5377e439819aa1b8852fd2b3146e7c8a754dd198c7b53e65449d0230499752aa9603ab8cafec63

Deployed Bytecode

0x6080604052600436106100595760003560e01c806313af403514610065578063177c67cb14610087578063704b6c02146100a7578063dab5f340146100c7578063db2e21bc146100e7578063ebf0c717146100fc57600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046107a6565b610124565b005b34801561009357600080fd5b506100856100a23660046107e5565b6101c5565b3480156100b357600080fd5b506100856100c23660046107a6565b61038c565b3480156100d357600080fd5b506100856100e23660046107cd565b610419565b3480156100f357600080fd5b5061008561045a565b34801561010857600080fd5b5061011260035481565b60405190815260200160405180910390f35b61012c6104a1565b6001546001600160a01b0316331461015f5760405162461bcd60e51b81526004016101569061091b565b60405180910390fd5b600180546001600160a01b0319166001600160a01b0383169081179091556040805133815260208101929092527fe2c7d1c4da37855e682bde14f17826d185497973b73fba7554daa6da467058d991015b60405180910390a16101c26001600055565b50565b60008381526004602052604090205460ff16156102145760405162461bcd60e51b815260206004820152600d60248201526c616c726561647920636c61696d60981b6044820152606401610156565b600061021f846104fb565b610228836104fb565b6040516020016102399291906108f2565b60405160208183030381529060405280519060200120905061025e83600354836105a6565b6102a15760405162461bcd60e51b815260206004820152601460248201527324b731b7b93932b1ba103630b73210383937b7b360611b6044820152606401610156565b604051600090339084908381818185875af1925050503d80600081146102e3576040519150601f19603f3d011682016040523d82523d6000602084013e6102e8565b606091505b50509050806103295760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b6044820152606401610156565b60008581526004602052604090819020805460ff19166001179055517f022e3d29644ead4083349ca84d24bcac368b2461819b70f5921fea15de4dec4d9061037d9087908690918252602082015260400190565b60405180910390a15050505050565b6103946104a1565b6002546001600160a01b031633146103be5760405162461bcd60e51b81526004016101569061091b565b600280546001600160a01b0319166001600160a01b0383811691909117909155600154604080513381529190921660208201527fcd6ba6b7da89e039d53b5d981527a893755342bb9d8e5c2f61f6638f1fb5192b91016101b0565b6104216104a1565b6002546001600160a01b0316331461044b5760405162461bcd60e51b81526004016101569061091b565b60038190556101c26001600055565b6104626104a1565b6001546001600160a01b0316331461048c5760405162461bcd60e51b81526004016101569061091b565b610495476105bc565b61049f6001600055565b565b600260005414156104f45760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610156565b6002600055565b6060600061050883610648565b600101905060008167ffffffffffffffff81111561053657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015610560576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846105995761059e565b61056a565b509392505050565b6000826105b38584610721565b14949350505050565b604051600090339083908381818185875af1925050503d80600081146105fe576040519150601f19603f3d011682016040523d82523d6000602084013e610603565b606091505b50509050806106445760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b6044820152606401610156565b5050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106106875772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106106b3576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106106d157662386f26fc10000830492506010015b6305f5e10083106106e9576305f5e100830492506008015b61271083106106fd57612710830492506004015b6064831061070f576064830492506002015b600a831061071b576001015b92915050565b600081815b845181101561059e576107608286838151811061075357634e487b7160e01b600052603260045260246000fd5b6020026020010151610774565b91508061076c8161093e565b915050610726565b600081831061079057600082815260208490526040902061079f565b60008381526020839052604090205b9392505050565b6000602082840312156107b7578081fd5b81356001600160a01b038116811461079f578182fd5b6000602082840312156107de578081fd5b5035919050565b6000806000606084860312156107f9578182fd5b8335925060208085013567ffffffffffffffff80821115610818578485fd5b818701915087601f83011261082b578485fd5b81358181111561083d5761083d610965565b8060051b604051601f19603f8301168101818110858211171561086257610862610965565b604052828152858101935084860182860187018c1015610880578889fd5b8895505b838610156108a2578035855260019590950194938601938601610884565b50979a979950505050604095909501359450505050565b60008151815b818110156108d957602081850181015186830152016108bf565b818111156108e75782828601525b509290920192915050565b60006108fe82856108b9565b600b60fa1b815261091260018201856108b9565b95945050505050565b6020808252600990820152683737ba1037bbb732b960b91b604082015260600190565b600060001982141561095e57634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea264697066735822122033b74789b352e1754d4fecab35b4b5d62a6b6c2e0fe697f553486e4e70b37e0564736f6c63430008040033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000052adcb180a3e983605ce82fb9c5377e439819aa100000000000000000000000052adcb180a3e983605ce82fb9c5377e439819aa1b8852fd2b3146e7c8a754dd198c7b53e65449d0230499752aa9603ab8cafec63

-----Decoded View---------------
Arg [0] : _admin (address): 0x52AdcB180a3E983605ce82fb9C5377e439819aA1
Arg [1] : _owner (address): 0x52AdcB180a3E983605ce82fb9C5377e439819aA1
Arg [2] : _root (bytes32): 0xb8852fd2b3146e7c8a754dd198c7b53e65449d0230499752aa9603ab8cafec63

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000052adcb180a3e983605ce82fb9c5377e439819aa1
Arg [1] : 00000000000000000000000052adcb180a3e983605ce82fb9c5377e439819aa1
Arg [2] : b8852fd2b3146e7c8a754dd198c7b53e65449d0230499752aa9603ab8cafec63


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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