false
false

Contract Address Details

0xe97FE633EC2021A71214D5d9BfF9f337dD1db5c1

Contract Name
OrandProviderV2
Creator
0x3fb52f–2618ee at 0xa3a419–4dd3e0
Balance
0 U2U ( )
Tokens
Fetching tokens...
Transactions
21 Transactions
Transfers
0 Transfers
Gas Used
3,869,321
Last Balance Update
29089473
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
OrandProviderV2




Optimization enabled
true
Compiler version
v0.8.19+commit.7dd6d404




Optimization runs
1000
EVM Version
default




Verified at
2024-03-18T11:50:55.914219Z

Constructor Arguments

0x2296393f4c4bfde812a53ed8bfa841c6251e9891fb0def611331b716a935ec91ad75abb573aada6599df5d3b34fa26853d9f5d89691aef7b811b8463c1561d5a000000000000000000000000ed6a792f694b7a52e7cf4b7f02daa41a7c92f362000000000000000000000000674305ad68cf9c2f572d06b8b617ef3c6c74503e000000000000000000000000388a09a39619d5de01a10d78d23a3bc1528b7a470000000000000000000000000000000000000000000000000000000000000064
              

Contract source code

Sol2uml
new
// Sources flattened with hardhat v2.19.4 https://hardhat.org

// SPDX-License-Identifier: Apache-2.0 AND MIT

// File @openzeppelin/contracts/utils/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}


// File @openzeppelin/contracts/access/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}


// File @openzeppelin/contracts/utils/math/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

            ///////////////////////////////////////////////
            // 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 256, 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 << 3) < value ? 1 : 0);
        }
    }
}


// File @openzeppelin/contracts/utils/math/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}


// File @openzeppelin/contracts/utils/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)

pragma solidity ^0.8.0;


/**
 * @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 `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

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

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}


// File @openzeppelin/contracts/utils/cryptography/[email protected]

// Original license: SPDX_License_Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

/**
 * @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 // Deprecated in v4.8
    }

    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");
        }
    }

    /**
     * @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) {
        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.
            /// @solidity memory-safe-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 {
            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 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 message) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, "\x19Ethereum Signed Message:\n32")
            mstore(0x1c, hash)
            message := keccak256(0x00, 0x3c)
        }
    }

    /**
     * @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 data) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, "\x19\x01")
            mstore(add(ptr, 0x02), domainSeparator)
            mstore(add(ptr, 0x22), structHash)
            data := keccak256(ptr, 0x42)
        }
    }

    /**
     * @dev Returns an Ethereum Signed Data with intended validator, created from a
     * `validator` and `data` according to the version 0 of EIP-191.
     *
     * See {recover}.
     */
    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x00", validator, data));
    }
}


// File contracts/orand-v2/interfaces/IOrandECDSAV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity ^0.8.0;

// Error
error InvalidECDSAProofLength(uint256 proofLength);
error InvalidProofSigner(address proofSigner);

interface IOrandECDSAV2 {
  // Struct Orand ECDSA proof
  struct OrandECDSAProof {
    address signer;
    address receiverAddress;
    uint96 receiverEpoch;
    uint256 ecvrfProofDigest;
  }

  // Get signer address from a valid proof
  function decomposeProof(bytes memory proof) external pure returns (OrandECDSAProof memory ecdsaProof);

  // Get operator
  function getOperator() external view returns (address operatorAddress);
}


// File contracts/orand-v2/interfaces/IOrandProviderV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity ^0.8.0;

error UnableToForwardRandomness(address receiver, uint256 y);
error InvalidAlphaValue(uint256 expectedAlpha, uint256 givenAlpha);
error InvalidGenesisEpoch(uint256 currentEpoch);
error InvalidECVRFProofDigest();

interface IOrandProviderV2 is IOrandECDSAV2 {
  // ECVRF struct
  struct ECVRFProof {
    uint256[2] gamma;
    uint256 c;
    uint256 s;
    uint256 alpha;
    address uWitness;
    uint256[2] cGammaWitness;
    uint256[2] sHashWitness;
    uint256 zInv;
  }

  // Start new genesis for receiver
  function genesis(bytes memory fraudProof, ECVRFProof calldata ecvrfProof) external returns (bool);

  // Publish new epoch with Fraud Proof
  function publishFraudProof(bytes memory fraudProof, ECVRFProof calldata ecvrfProof) external returns (bool);

  // Publish new epoch with ECDSA Proof and Fraud Proof
  function publish(address receiver, ECVRFProof calldata ecvrfProof) external returns (bool);

  // Verify a ECVRF proof epoch is valid or not
  function verifyEpoch(
    bytes memory fraudProof,
    ECVRFProof calldata ecvrfProof
  )
    external
    view
    returns (
      OrandECDSAProof memory ecdsaProof,
      uint96 currentEpochNumber,
      bool isEpochLinked,
      bool isValidDualProof,
      uint256 currentEpochResult,
      uint256 verifiedEpochResult
    );

  // Get address of ECVRF verifier
  function getECVRFVerifier() external view returns (address ecvrfVerifier);
}


// File contracts/orand-v2/interfaces/IOrandECVRFV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity ^0.8.0;

interface IOrandECVRFV2 {
  // Verify raw proof of ECVRF
  function verifyECVRFProof(
    uint256[2] memory pk,
    uint256[2] memory gamma,
    uint256 c,
    uint256 s,
    uint256 alpha,
    address uWitness,
    uint256[2] memory cGammaWitness,
    uint256[2] memory sHashWitness,
    uint256 zInv
  ) external view returns (uint256 y);

  // Verify structed proof of ECVRF
  function verifyStructECVRFProof(
    uint256[2] memory pk,
    IOrandProviderV2.ECVRFProof memory ecvrfProof
  ) external view returns (uint256 y);
}


// File contracts/libraries/Bytes.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity 0.8.19;

// Index is out of range
error OutOfRange(uint256 requiredLen, uint256 maxLen);

library Bytes {
  // Read address from input bytes buffer
  function readAddress(bytes memory input, uint256 offset) internal pure returns (address result) {
    if (offset + 20 > input.length) {
      revert OutOfRange(offset + 20, input.length);
    }
    assembly {
      result := shr(96, mload(add(add(input, 0x20), offset)))
    }
  }

  // Read unsafe from input bytes buffer
  function readUintUnsafe(bytes memory input, uint256 offset, uint256 bitLen) internal pure returns (uint256 result) {
    assembly {
      result := shr(sub(256, bitLen), mload(add(add(input, 0x20), offset)))
    }
  }

  // Read uint256 from input bytes buffer
  function readUint256(bytes memory input, uint256 offset) internal pure returns (uint256 result) {
    if (offset + 32 > input.length) {
      revert OutOfRange(offset + 32, input.length);
    }
    assembly {
      result := mload(add(add(input, 0x20), offset))
    }
  }

  // Read a sub bytes array from input bytes buffer
  function readBytes(bytes memory input, uint256 offset, uint256 length) internal pure returns (bytes memory) {
    if (offset + length > input.length) {
      revert OutOfRange(offset + length, input.length);
    }
    bytes memory result = new bytes(length);
    assembly {
      // Seek offset to the beginning
      let seek := add(add(input, 0x20), offset)

      // Next is size of data
      let resultOffset := add(result, 0x20)

      for {
        let i := 0
      } lt(i, length) {
        i := add(i, 0x20)
      } {
        mstore(add(resultOffset, i), mload(add(seek, i)))
      }
    }
    return result;
  }
}


// File contracts/orand-v2/OrandECDSAV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity 0.8.19;



contract OrandECDSAV2 is IOrandECDSAV2 {
  // Event: Set New Operator
  event SetNewOperator(address indexed oldOperator, address indexed newOperator);

  // Orand operator address
  address private operator;

  // Byte manipulation
  using Bytes for bytes;

  // Verifiy digital signature
  using ECDSA for bytes;
  using ECDSA for bytes32;

  // Set operator at constructing time
  constructor(address operatorAddress) {
    _setOperator(operatorAddress);
  }

  //=======================[  Internal  ]====================

  // Set proof operator
  function _setOperator(address operatorAddress) internal {
    emit SetNewOperator(operator, operatorAddress);
    operator = operatorAddress;
  }

  //=======================[  Internal View  ]====================

  // Get operator address
  function _getOperator() internal view returns (address operatorAddress) {
    return operator;
  }

  // Verify proof of operator
  // 0 - 65: secp256k1 Signature
  // 65 - 77: Epoch
  // 77 - 97: Receiver address
  // 97 - 129: Y result of VRF
  function _decodeFraudProof(bytes memory fraudProof) internal pure returns (OrandECDSAProof memory ecdsaProof) {
    if (fraudProof.length != 129) {
      revert InvalidECDSAProofLength(fraudProof.length);
    }
    bytes memory signature = fraudProof.readBytes(0, 65);
    bytes memory message = fraudProof.readBytes(65, fraudProof.length - 65);
    uint256 proofUint = message.readUint256(0);
    ecdsaProof.receiverEpoch = uint96(proofUint >> 160);
    ecdsaProof.receiverAddress = address(uint160(proofUint));
    ecdsaProof.ecvrfProofDigest = message.readUint256(32);
    ecdsaProof.signer = message.toEthSignedMessageHash().recover(signature);
    return ecdsaProof;
  }

  //=======================[  External View  ]====================

  // Decompose a valid proof
  function decomposeProof(bytes memory proof) external pure returns (OrandECDSAProof memory ecdsaProof) {
    return _decodeFraudProof(proof);
  }

  // Get operator
  function getOperator() external view returns (address operatorAddress) {
    return _getOperator();
  }
}


// File contracts/orand-v2/interfaces/IOrandManagementV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity ^0.8.0;

interface IOrandManagementV2 {
  // Get public key
  function getPublicKey() external view returns (uint256[2] memory pubKey);

  // Get digest of corresponding public key
  function getPublicKeyDigest() external view returns (bytes32 operator);
}


// File contracts/orand-v2/OrandManagementV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity 0.8.19;


contract OrandManagementV2 is IOrandManagementV2 {
  // Public key that will be use to
  uint256[2] private publicKey;

  // Event Set New Public Key
  event SetNewPublicKey(address indexed actor, uint256 indexed pkx, uint256 indexed pky);

  // Set public key of Orand at the constructing time
  constructor(uint256[2] memory publickey) {
    _setPublicKey(publickey);
  }

  //=======================[  Internal  ]====================

  // Set new public key by XY to verify ECVRF proof
  function _setPublicKey(uint256[2] memory publickey) internal {
    publicKey = publickey;
    emit SetNewPublicKey(msg.sender, publickey[0], publickey[1]);
  }

  //=======================[  Internal view ]====================

  // Get public key
  function _getPublicKey() internal view returns (uint256[2] memory pubKey) {
    return publicKey;
  }

  // Get public key digest
  function _getPublicKeyDigest() internal view returns (bytes32 pubKeyDigest) {
    return keccak256(abi.encodePacked(publicKey));
  }

  //=======================[  External view  ]====================

  // Get public key
  function getPublicKey() external view returns (uint256[2] memory pubKey) {
    return _getPublicKey();
  }

  // Get digest of corresponding public key
  function getPublicKeyDigest() external view returns (bytes32 operator) {
    return _getPublicKeyDigest();
  }
}


// File contracts/orand-v2/interfaces/IOrandConsumerV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity ^0.8.0;

error InvalidProvider();

interface IOrandConsumerV2 {
  // Consume the verifiable randomness from Orand provider
  // Return false if you want to stop batching
  function consumeRandomness(uint256 randomness) external returns (bool);
}


// File contracts/orand-v2/interfaces/IOrandStorageV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity ^0.8.0;

interface IOrandStorageV2 {
  // Get a given epoch result for a given receiver
  function getEpochResult(address receiver, uint96 epoch) external view returns (uint256 result);

  // Get total number of epochs for a given receiver
  function getTotalEpoch(address receiver) external view returns (uint96 epoch);

  // Get current epoch of a given receiver
  function getCurrentEpoch(address receiver) external view returns (uint96 epoch);

  // Get current epoch of a given receiver
  function getCurrentEpochResult(address receiver) external view returns (uint256 result);
}


// File contracts/orand-v2/OrandStorageV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity 0.8.19;


contract OrandStorageV2 is IOrandStorageV2 {
  using Bytes for bytes;

  // Event: New Epoch
  event NewEpoch(address indexed receiverAddress, uint96 indexed receiverEpoch, uint256 indexed randomness);

  // Storage of recent epoch's result
  // Map epoch ++ receiver  -> alpha
  mapping(uint256 => uint256) private epochResult;

  // Map receiver -> total epoch
  mapping(address => uint256) private epochMax;

  //=======================[  Internal  ]====================

  // Add validity epoch
  function _addEpoch(address receiver, uint256 result) internal {
    uint96 epoch = uint96(epochMax[receiver]);
    // Add epoch to storage
    // epoch != 0 => able to sue == true
    epochResult[_packing(epoch, receiver)] = result;
    // If add new epoch we increase the epoch max 1
    epochMax[receiver] = epoch + 1;
    // Emit event to outside of EVM
    emit NewEpoch(receiver, epoch, result);
  }

  //=======================[  Internal pure ]====================

  // Packing adderss and uint96 to a single bytes32
  // 96 bits a ++ 160 bits b
  function _packing(uint96 a, address b) internal pure returns (uint256 packed) {
    assembly {
      packed := or(shl(160, a), b)
    }
  }

  //=======================[  Internal View  ]====================

  // Get result of current epoch
  function _getCurrentEpoch(address receiver) internal view returns (uint96 epoch) {
    epoch = uint96(epochMax[receiver]);
    return (epoch > 0) ? epoch - 1 : epoch;
  }

  // Get total number of epoch for a given receiver
  function _getTotalEpoch(address receiver) internal view returns (uint96 epoch) {
    return uint96(epochMax[receiver]);
  }

  // Get result of current epoch
  function _getCurrentEpochResult(address receiver) internal view returns (uint256 result) {
    return epochResult[_packing(_getCurrentEpoch(receiver), receiver)];
  }

  //=======================[  External View  ]====================

  // Get a given epoch result for a given receiver
  function getEpochResult(address receiver, uint96 epoch) external view returns (uint256 result) {
    return epochResult[_packing(epoch, receiver)];
  }

  // Get current epoch of a given receiver
  function getCurrentEpochResult(address receiver) external view returns (uint256 result) {
    return _getCurrentEpochResult(receiver);
  }

  // Get total number of epochs for a given receiver
  function getTotalEpoch(address receiver) external view returns (uint96 epoch) {
    return _getTotalEpoch(receiver);
  }

  // Get current epoch of a given receiver
  function getCurrentEpoch(address receiver) external view returns (uint96 epoch) {
    return _getCurrentEpoch(receiver);
  }
}


// File contracts/orocle-v1/interfaces/IOrocleAggregatorV1.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity ^0.8.0;

error ExistedApplication(uint32 appId);
error InvalidApplication(uint32 appId);
error InvalidApplicationName(bytes24 appName);
error InvalidRoundNumber(uint64 round, uint64 requiredRound);
error UndefinedRound(uint64 round);
error InvalidDataLength(uint256 length);
error UnableToPublishData(bytes data);

interface IOrocleAggregatorV1 {
  /**
   * Emit event when a new request is created
   * @param identifier Data identifier
   * @param data Data
   */
  function request(uint256 identifier, bytes calldata data) external returns (bool);

  /**
   * Fulfill request
   * @param identifier Data identifier
   * @param data Data
   */
  function fulfill(uint256 identifier, bytes calldata data) external returns (bool);

  /**
   * Get round of a given application
   * @param appId Application ID
   * @return round
   */
  function getMetadata(uint32 appId, bytes20 identifier) external view returns (uint64 round, uint64 lastUpdate);

  /**
   * Get data of an application
   * @param appId Application ID
   * @param round Round number
   * @param identifier Data identifier
   * @return data Data
   */
  function getData(uint32 appId, uint64 round, bytes20 identifier) external view returns (bytes32 data);

  /**
   * Get latest data of an application
   * @param appId Application ID
   * @param identifier Data identifier
   * @return data
   */
  function getLatestData(uint32 appId, bytes20 identifier) external view returns (bytes32 data);

  /**
   * Get latest data of an application
   * @param appId Application ID
   * @param identifier Data identifier
   * @return round lastUpdate data
   */
  function getLatestRound(
    uint32 appId,
    bytes20 identifier
  ) external view returns (uint64 round, uint64 lastUpdate, bytes32 data);
}


// File contracts/orand-v2/OrandProviderV2.sol

// Original license: SPDX_License_Identifier: Apache-2.0
pragma solidity 0.8.19;








contract OrandProviderV2 is IOrandProviderV2, Ownable, OrandStorageV2, OrandManagementV2, OrandECDSAV2 {
  // ECVRF verifier smart contract
  IOrandECVRFV2 ecvrf;

  // Orocle V1
  IOrocleAggregatorV1 oracle;

  // We allow max batching is 1000
  uint256 private maxBatching;

  // Event: Set New ECVRF Verifier
  event SetNewECVRFVerifier(address indexed actor, address indexed ecvrfAddress);

  // Event: Set the limit for batching randomness
  event SetBatchingLimit(address indexed actor, uint256 indexed maxBatching);

  // Event: set new oracle
  event SetNewOracle(address indexed actor, address indexed newOracle);

  // Provider V2 construct method
  constructor(
    uint256[2] memory publicKey,
    address operator,
    address ecvrfAddress,
    address oracleAddress,
    uint256 maxBatchingLimit
  ) OrandManagementV2(publicKey) OrandECDSAV2(operator) {
    ecvrf = IOrandECVRFV2(ecvrfAddress);
    oracle = IOrocleAggregatorV1(oracleAddress);
    maxBatching = maxBatchingLimit;
  }

  //=======================[  Owner  ]====================

  // Update new ECVRF verifier
  function setMaxBatching(uint256 maxBatchingLimit) external onlyOwner returns (bool) {
    maxBatching = maxBatchingLimit;
    emit SetBatchingLimit(msg.sender, maxBatchingLimit);
    return true;
  }

  // Update new ECVRF verifier
  function setNewOracle(address oracleAddress) external onlyOwner returns (bool) {
    oracle = IOrocleAggregatorV1(oracleAddress);
    emit SetNewOracle(msg.sender, oracleAddress);
    return true;
  }

  // Update new ECVRF verifier
  function setNewECVRFVerifier(address ecvrfAddress) external onlyOwner returns (bool) {
    ecvrf = IOrandECVRFV2(ecvrfAddress);
    emit SetNewECVRFVerifier(msg.sender, ecvrfAddress);
    return true;
  }

  // Set new public key to verify proof
  function setPublicKey(uint256[2] memory pk) external onlyOwner returns (bool) {
    _setPublicKey(pk);
    return true;
  }

  //=======================[  External  ]====================

  // Start new genesis for receiver
  function genesis(bytes memory fraudProof, ECVRFProof calldata ecvrfProof) external returns (bool) {
    OrandECDSAProof memory ecdsaProof = _decodeFraudProof(fraudProof);
    uint256 currentEpochResult = _getCurrentEpochResult(ecdsaProof.receiverAddress);

    // Invalid genesis epoch
    if (currentEpochResult != 0 || ecdsaProof.receiverEpoch != 0) {
      revert InvalidGenesisEpoch(currentEpochResult);
    }

    // ECVRF proof digest must match
    if (
      ecdsaProof.ecvrfProofDigest !=
      uint256(
        keccak256(
          abi.encodePacked(
            _getPublicKey(),
            ecvrfProof.gamma,
            ecvrfProof.c,
            ecvrfProof.s,
            ecvrfProof.alpha,
            ecvrfProof.uWitness,
            ecvrfProof.cGammaWitness,
            ecvrfProof.sHashWitness,
            ecvrfProof.zInv
          )
        )
      )
    ) {
      revert InvalidECVRFProofDigest();
    }

    // y = keccak256(gamma.x, gamma.y)
    // uint256 y = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));
    uint256 result = ecvrf.verifyStructECVRFProof(_getPublicKey(), ecvrfProof);

    // Add epoch to the epoch chain of Orand ECVRF
    _addEpoch(ecdsaProof.receiverAddress, result);

    return true;
  }

  // Publish new epoch with Fraud Proof
  function publishFraudProof(bytes memory fraudProof, ECVRFProof calldata ecvrfProof) external returns (bool) {
    OrandECDSAProof memory ecdsaProof = _decodeFraudProof(fraudProof);
    uint256 currentEpochResult = _getCurrentEpochResult(ecdsaProof.receiverAddress);

    // Current alpha must be the result of previous epoch
    if (ecdsaProof.signer != _getOperator()) {
      revert InvalidProofSigner(ecdsaProof.signer);
    }

    // Current alpha must be the result of previous epoch
    if (ecvrfProof.alpha != currentEpochResult) {
      revert InvalidAlphaValue(currentEpochResult, ecvrfProof.alpha);
    }

    // ECVRF proof digest must match
    if (
      ecdsaProof.ecvrfProofDigest !=
      uint256(
        keccak256(
          abi.encodePacked(
            _getPublicKey(),
            ecvrfProof.gamma,
            ecvrfProof.c,
            ecvrfProof.s,
            ecvrfProof.alpha,
            ecvrfProof.uWitness,
            ecvrfProof.cGammaWitness,
            ecvrfProof.sHashWitness,
            ecvrfProof.zInv
          )
        )
      )
    ) {
      revert InvalidECVRFProofDigest();
    }

    // y = keccak256(gamma.x, gamma.y)
    uint256 result = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));

    // Add epoch to the epoch chain of Orand ECVRF
    _addEpoch(ecdsaProof.receiverAddress, result);

    // Check for the existing smart contract and forward randomness to receiver
    if (ecdsaProof.receiverAddress.code.length > 0) {
      for (uint256 i = 0; i < maxBatching; i += 1) {
        if (!IOrandConsumerV2(ecdsaProof.receiverAddress).consumeRandomness(result)) {
          oracle.fulfill(0, abi.encodePacked(ecdsaProof.receiverAddress));
          break;
        }
        result = uint256(keccak256(abi.encodePacked(result)));
      }
    }

    return true;
  }

  // Publish new epoch with ECDSA Proof and Fraud Proof
  function publish(address receiver, ECVRFProof calldata ecvrfProof) external returns (bool) {
    uint256 currentEpochResult = _getCurrentEpochResult(receiver);

    // Current alpha must be the result of previous epoch
    if (ecvrfProof.alpha != currentEpochResult) {
      revert InvalidAlphaValue(currentEpochResult, ecvrfProof.alpha);
    }

    // y = keccak256(gamma.x, gamma.y)
    // uint256 y = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));
    uint256 result = ecvrf.verifyStructECVRFProof(_getPublicKey(), ecvrfProof);

    // Add epoch to the epoch chain of Orand ECVRF
    _addEpoch(receiver, result);

    // Check for the existing smart contract and forward randomness to receiver
    if (receiver.code.length > 0) {
      for (uint256 i = 0; i < maxBatching; i += 1) {
        if (!IOrandConsumerV2(receiver).consumeRandomness(result)) {
          oracle.fulfill(0, abi.encodePacked(receiver));
          break;
        }
        result = uint256(keccak256(abi.encodePacked(result)));
      }
    }

    return true;
  }

  //=======================[  External View  ]====================

  // Verify a ECVRF proof epoch is valid or not
  function verifyEpoch(
    bytes memory fraudProof,
    ECVRFProof calldata ecvrfProof
  )
    external
    view
    returns (
      OrandECDSAProof memory ecdsaProof,
      uint96 currentEpochNumber,
      bool isEpochLinked,
      bool isValidDualProof,
      uint256 currentEpochResult,
      uint256 verifiedEpochResult
    )
  {
    ecdsaProof = _decodeFraudProof(fraudProof);

    isValidDualProof =
      ecdsaProof.ecvrfProofDigest ==
      uint256(
        keccak256(
          abi.encodePacked(
            _getPublicKey(),
            ecvrfProof.gamma,
            ecvrfProof.c,
            ecvrfProof.s,
            ecvrfProof.alpha,
            ecvrfProof.uWitness,
            ecvrfProof.cGammaWitness,
            ecvrfProof.sHashWitness,
            ecvrfProof.zInv
          )
        )
      );

    currentEpochNumber = _getCurrentEpoch(ecdsaProof.receiverAddress);
    currentEpochResult = _getCurrentEpochResult(ecdsaProof.receiverAddress);
    isEpochLinked = currentEpochResult == ecvrfProof.alpha;

    // y = keccak256(gamma.x, gamma.y)
    // uint256 y = uint256(keccak256(abi.encodePacked(ecvrfProof.gamma)));
    verifiedEpochResult = ecvrf.verifyStructECVRFProof(_getPublicKey(), ecvrfProof);
  }

  // Get address of ECVRF verifier
  function getECVRFVerifier() external view returns (address ecvrfVerifier) {
    return address(ecvrf);
  }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"uint256[2]","name":"publicKey","internalType":"uint256[2]"},{"type":"address","name":"operator","internalType":"address"},{"type":"address","name":"ecvrfAddress","internalType":"address"},{"type":"address","name":"oracleAddress","internalType":"address"},{"type":"uint256","name":"maxBatchingLimit","internalType":"uint256"}]},{"type":"error","name":"InvalidAlphaValue","inputs":[{"type":"uint256","name":"expectedAlpha","internalType":"uint256"},{"type":"uint256","name":"givenAlpha","internalType":"uint256"}]},{"type":"error","name":"InvalidECDSAProofLength","inputs":[{"type":"uint256","name":"proofLength","internalType":"uint256"}]},{"type":"error","name":"InvalidECVRFProofDigest","inputs":[]},{"type":"error","name":"InvalidGenesisEpoch","inputs":[{"type":"uint256","name":"currentEpoch","internalType":"uint256"}]},{"type":"error","name":"InvalidProofSigner","inputs":[{"type":"address","name":"proofSigner","internalType":"address"}]},{"type":"error","name":"OutOfRange","inputs":[{"type":"uint256","name":"requiredLen","internalType":"uint256"},{"type":"uint256","name":"maxLen","internalType":"uint256"}]},{"type":"event","name":"NewEpoch","inputs":[{"type":"address","name":"receiverAddress","internalType":"address","indexed":true},{"type":"uint96","name":"receiverEpoch","internalType":"uint96","indexed":true},{"type":"uint256","name":"randomness","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetBatchingLimit","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"uint256","name":"maxBatching","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewECVRFVerifier","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"address","name":"ecvrfAddress","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewOperator","inputs":[{"type":"address","name":"oldOperator","internalType":"address","indexed":true},{"type":"address","name":"newOperator","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewOracle","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"address","name":"newOracle","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"SetNewPublicKey","inputs":[{"type":"address","name":"actor","internalType":"address","indexed":true},{"type":"uint256","name":"pkx","internalType":"uint256","indexed":true},{"type":"uint256","name":"pky","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"pure","outputs":[{"type":"tuple","name":"ecdsaProof","internalType":"struct IOrandECDSAV2.OrandECDSAProof","components":[{"type":"address","name":"signer","internalType":"address"},{"type":"address","name":"receiverAddress","internalType":"address"},{"type":"uint96","name":"receiverEpoch","internalType":"uint96"},{"type":"uint256","name":"ecvrfProofDigest","internalType":"uint256"}]}],"name":"decomposeProof","inputs":[{"type":"bytes","name":"proof","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"genesis","inputs":[{"type":"bytes","name":"fraudProof","internalType":"bytes"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV2.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint96","name":"epoch","internalType":"uint96"}],"name":"getCurrentEpoch","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"result","internalType":"uint256"}],"name":"getCurrentEpochResult","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"ecvrfVerifier","internalType":"address"}],"name":"getECVRFVerifier","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"result","internalType":"uint256"}],"name":"getEpochResult","inputs":[{"type":"address","name":"receiver","internalType":"address"},{"type":"uint96","name":"epoch","internalType":"uint96"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"operatorAddress","internalType":"address"}],"name":"getOperator","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[2]","name":"pubKey","internalType":"uint256[2]"}],"name":"getPublicKey","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"operator","internalType":"bytes32"}],"name":"getPublicKeyDigest","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint96","name":"epoch","internalType":"uint96"}],"name":"getTotalEpoch","inputs":[{"type":"address","name":"receiver","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"publish","inputs":[{"type":"address","name":"receiver","internalType":"address"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV2.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"publishFraudProof","inputs":[{"type":"bytes","name":"fraudProof","internalType":"bytes"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV2.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setMaxBatching","inputs":[{"type":"uint256","name":"maxBatchingLimit","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setNewECVRFVerifier","inputs":[{"type":"address","name":"ecvrfAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setNewOracle","inputs":[{"type":"address","name":"oracleAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setPublicKey","inputs":[{"type":"uint256[2]","name":"pk","internalType":"uint256[2]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"ecdsaProof","internalType":"struct IOrandECDSAV2.OrandECDSAProof","components":[{"type":"address","name":"signer","internalType":"address"},{"type":"address","name":"receiverAddress","internalType":"address"},{"type":"uint96","name":"receiverEpoch","internalType":"uint96"},{"type":"uint256","name":"ecvrfProofDigest","internalType":"uint256"}]},{"type":"uint96","name":"currentEpochNumber","internalType":"uint96"},{"type":"bool","name":"isEpochLinked","internalType":"bool"},{"type":"bool","name":"isValidDualProof","internalType":"bool"},{"type":"uint256","name":"currentEpochResult","internalType":"uint256"},{"type":"uint256","name":"verifiedEpochResult","internalType":"uint256"}],"name":"verifyEpoch","inputs":[{"type":"bytes","name":"fraudProof","internalType":"bytes"},{"type":"tuple","name":"ecvrfProof","internalType":"struct IOrandProviderV2.ECVRFProof","components":[{"type":"uint256[2]","name":"gamma","internalType":"uint256[2]"},{"type":"uint256","name":"c","internalType":"uint256"},{"type":"uint256","name":"s","internalType":"uint256"},{"type":"uint256","name":"alpha","internalType":"uint256"},{"type":"address","name":"uWitness","internalType":"address"},{"type":"uint256[2]","name":"cGammaWitness","internalType":"uint256[2]"},{"type":"uint256[2]","name":"sHashWitness","internalType":"uint256[2]"},{"type":"uint256","name":"zInv","internalType":"uint256"}]}]}]
              

Contract Creation Code

Verify & Publish
0x60806040523480156200001157600080fd5b50604051620020dc380380620020dc833981016040819052620000349162000213565b8385620000413362000095565b6200004c81620000e5565b5062000058816200012a565b50600680546001600160a01b039485166001600160a01b031991821617909155600780549390941692169190911790915560085550620002da9050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b620000f4600382600262000186565b506020810151815160405133907fbfa225acb3bdc1bbe3faa03e81a000c6399a94d8db72b0c434dd5828b7083f5690600090a450565b6005546040516001600160a01b038084169216907f82d04c58d23161f2b0d3c01082dae861326f4703555a22090a04f971dc00d4e790600090a3600580546001600160a01b0319166001600160a01b0392909216919091179055565b8260028101928215620001b7579160200282015b82811115620001b75782518255916020019190600101906200019a565b50620001c5929150620001c9565b5090565b5b80821115620001c55760008155600101620001ca565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b03811681146200020e57600080fd5b919050565b600080600080600060c086880312156200022c57600080fd5b86601f8701126200023c57600080fd5b604080519081016001600160401b0381118282101715620002615762000261620001e0565b80604052508060408801898111156200027957600080fd5b885b81811015620002955780518352602092830192016200027b565b50829750620002a481620001f6565b9650505050620002b760608701620001f6565b9250620002c760808701620001f6565b915060a086015190509295509295909350565b611df280620002ea6000396000f3fe608060405234801561001057600080fd5b506004361061016c5760003560e01c80639a336be1116100cd578063e02bc3c811610081578063e7f43c6811610066578063e7f43c6814610322578063f2fde38b1461032a578063f4de72311461033d57600080fd5b8063e02bc3c8146102fa578063e5114f6c1461030257600080fd5b8063bf776ba4116100b2578063bf776ba4146102b1578063c0f948d2146102c4578063cfa51d9a146102d557600080fd5b80639a336be11461026c578063b0ab7dac1461027f57600080fd5b806372ceb2de116101245780637fcde1c2116101095780637fcde1c214610221578063803ab8db146102345780638da5cb5b1461024757600080fd5b806372ceb2de146101fb5780637dbfe9f51461020e57600080fd5b80633d6a3664116101555780633d6a3664146101bb5780634d3223a5146101de578063715018a6146101f157600080fd5b8063243904d4146101715780632e334452146101a6575b600080fd5b61018461017f366004611756565b610350565b6040516bffffffffffffffffffffffff90911681526020015b60405180910390f35b6101ae610370565b60405161019d91906117a1565b6101ce6101c9366004611756565b610385565b604051901515815260200161019d565b6101846101ec366004611756565b6103ee565b6101f96103f9565b005b6101ce610209366004611756565b61040d565b6101ce61021c3660046117af565b610475565b6101ce61022f3660046117e1565b6104b9565b6101ce61024236600461182c565b610716565b6000546001600160a01b03165b6040516001600160a01b03909116815260200161019d565b6101ce61027a366004611939565b610731565b6102a361028d366004611980565b60a01b1760009081526001602052604090205490565b60405190815260200161019d565b6101ce6102bf366004611939565b6108cb565b6006546001600160a01b0316610254565b6102e86102e3366004611939565b610be6565b60405161019d969594939291906119c8565b6102a3610d35565b610315610310366004611a4a565b610d3f565b60405161019d9190611a87565b610254610d6c565b6101f9610338366004611756565b610d80565b6102a361034b366004611756565b610e10565b6001600160a01b0381166000908152600260205260408120545b92915050565b6103786116ce565b610380610e1b565b905090565b600061038f610e55565b6007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915560405133907fd85f66a2d033a785734c4777d12d2526304b1727ddd6774582a4ddb3474dac9790600090a35060015b919050565b600061036a82610eaf565b610401610e55565b61040b6000610eec565b565b6000610417610e55565b6006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915560405133907f5f710a9b3681930bf1343b51da6fa8f2476a09903e0831f661f36bd63892931a90600090a3506001919050565b600061047f610e55565b6008829055604051829033907fe71d538682fa7ee72ed8c324fac011fe5a8d0f5ceb54d49f35c82099889a957c90600090a3506001919050565b6000806104c584610f49565b9050808360800135146104fd576040516338e5849560e11b815260048101829052608084013560248201526044015b60405180910390fd5b6006546000906001600160a01b03166331ff34cf610519610e1b565b866040518363ffffffff1660e01b8152600401610537929190611ada565b602060405180830381865afa158015610554573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105789190611b55565b90506105848582610f79565b6001600160a01b0385163b1561070b5760005b60085481101561070957604051632f4a1ff560e01b8152600481018390526001600160a01b03871690632f4a1ff5906024016020604051808303816000875af11580156105e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060c9190611b6e565b6106d15760075460408051606089901b6bffffffffffffffffffffffff191660208201528151601481830301815260348201928390527f0d9577c6000000000000000000000000000000000000000000000000000000009092526001600160a01b0390921691630d9577c6916106889160009190603801611bb4565b6020604051808303816000875af11580156106a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106cb9190611b6e565b50610709565b60408051602081018490520160408051601f1981840301815291905280516020909101209150610702600182611c04565b9050610597565b505b506001949350505050565b6000610720610e55565b6107298261100e565b506001919050565b60008061073d84611051565b9050600061074e8260200151610f49565b90508015158061076f575060408201516bffffffffffffffffffffffff1615155b156107a9576040517f2c364f1c000000000000000000000000000000000000000000000000000000008152600481018290526024016104f4565b6107b1610e1b565b846040810135606082013560808301356107d160c0850160a08601611756565b8960c0018a610100018b61014001356040516020016107f899989796959493929190611c17565b6040516020818303038152906040528051906020012060001c826060015114610834576040516305b604d760e01b815260040160405180910390fd5b6006546000906001600160a01b03166331ff34cf610850610e1b565b876040518363ffffffff1660e01b815260040161086e929190611ada565b602060405180830381865afa15801561088b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108af9190611b55565b90506108bf836020015182610f79565b50600195945050505050565b6000806108d784611051565b905060006108e88260200151610f49565b90506108fc6005546001600160a01b031690565b6001600160a01b031682600001516001600160a01b0316146109585781516040517fd90fe8e10000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016104f4565b80846080013514610989576040516338e5849560e11b815260048101829052608085013560248201526044016104f4565b610991610e1b565b846040810135606082013560808301356109b160c0850160a08601611756565b8960c0018a610100018b61014001356040516020016109d899989796959493929190611c17565b6040516020818303038152906040528051906020012060001c826060015114610a14576040516305b604d760e01b815260040160405180910390fd5b604051600090610a28908690602001611ca6565b6040516020818303038152906040528051906020012060001c9050610a51836020015182610f79565b60208301516001600160a01b03163b156108bf5760005b600854811015610bd9576020840151604051632f4a1ff560e01b8152600481018490526001600160a01b0390911690632f4a1ff5906024016020604051808303816000875af1158015610abf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae39190611b6e565b610ba1576007546020808601516040516001600160a01b0390931692630d9577c692600092610b2c9290910160609190911b6bffffffffffffffffffffffff1916815260140190565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610b58929190611bb4565b6020604051808303816000875af1158015610b77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9b9190611b6e565b50610bd9565b60408051602081018490520160408051601f1981840301815291905280516020909101209150610bd2600182611c04565b9050610a68565b5060019695505050505050565b60408051608081018252600080825260208201819052918101829052606081018290529080808080610c1788611051565b9550610c21610e1b565b87604081013560608201356080830135610c4160c0850160a08601611756565b8c60c0018d610100018e6101400135604051602001610c6899989796959493929190611c17565b6040516020818303038152906040528051906020012060001c8660600151149250610c968660200151610eaf565b9450610ca58660200151610f49565b6006546080890135821495509092506001600160a01b03166331ff34cf610cca610e1b565b896040518363ffffffff1660e01b8152600401610ce8929190611ada565b602060405180830381865afa158015610d05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d299190611b55565b90509295509295509295565b6000610380611146565b60408051608081018252600080825260208201819052918101829052606081019190915261036a82611051565b60006103806005546001600160a01b031690565b610d88610e55565b6001600160a01b038116610e045760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104f4565b610e0d81610eec565b50565b600061036a82610f49565b610e236116ce565b60408051808201918290529060039060029082845b815481526020019060010190808311610e38575050505050905090565b6000546001600160a01b0316331461040b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104f4565b6001600160a01b0381166000908152600260205260409020546bffffffffffffffffffffffff8116610ee1578061036a565b61036a600182611cb3565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060016000610f63610f5b85610eaf565b60a01b851790565b8152602001908152602001600020549050919050565b6001600160a01b03821660009081526002602090815260408083205460a081901b861784526001928390529220839055610fb4908290611cdf565b6001600160a01b0384166000818152600260205260408082206bffffffffffffffffffffffff9485169055518593851692917f50524705e17603fd96db3d4cbd148655f75d19bf9ab86067ef587134b7919e8091a4505050565b61101b60038260026116ec565b506020810151815160405133907fbfa225acb3bdc1bbe3faa03e81a000c6399a94d8db72b0c434dd5828b7083f5690600090a450565b60408051608081018252600080825260208201819052918101829052606081019190915281516081146110b55781516040517f0786993c0000000000000000000000000000000000000000000000000000000081526004016104f491815260200190565b60006110c383826041611175565b905060006110e160418086516110d99190611d04565b869190611175565b905060006110ef8282611231565b60a081901c60408601526001600160a01b03811660208087019190915290915061111a908390611231565b60608501526111328361112c8461127f565b906112ba565b6001600160a01b0316845250919392505050565b6000600360405160200161115a9190611d17565b60405160208183030381529060405280519060200120905090565b82516060906111848385611c04565b11156111b8576111948284611c04565b845160405163abe5c32f60e01b8152600481019290925260248201526044016104f4565b60008267ffffffffffffffff8111156111d3576111d3611816565b6040519080825280601f01601f1916602001820160405280156111fd576020820181803683370190505b5090508360208601016020820160005b8581101561122557828101518282015260200161120d565b50919695505050505050565b8151600090611241836020611c04565b111561127657611252826020611c04565b835160405163abe5c32f60e01b8152600481019290925260248201526044016104f4565b50016020015190565b600061128b82516112de565b8260405160200161129d929190611d4b565b604051602081830303815290604052805190602001209050919050565b60008060006112c9858561137e565b915091506112d6816113c3565b509392505050565b606060006112eb83611528565b600101905060008167ffffffffffffffff81111561130b5761130b611816565b6040519080825280601f01601f191660200182016040528015611335576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461133f57509392505050565b60008082516041036113b45760208301516040840151606085015160001a6113a88782858561160a565b945094505050506113bc565b506000905060025b9250929050565b60008160048111156113d7576113d7611da6565b036113df5750565b60018160048111156113f3576113f3611da6565b036114405760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016104f4565b600281600481111561145457611454611da6565b036114a15760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016104f4565b60038160048111156114b5576114b5611da6565b03610e0d5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016104f4565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611571577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef8100000000831061159d576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106115bb57662386f26fc10000830492506010015b6305f5e10083106115d3576305f5e100830492506008015b61271083106115e757612710830492506004015b606483106115f9576064830492506002015b600a831061036a5760010192915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561164157506000905060036116c5565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611695573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166116be576000600192509250506116c5565b9150600090505b94509492505050565b60405180604001604052806002906020820280368337509192915050565b826002810192821561171a579160200282015b8281111561171a5782518255916020019190600101906116ff565b5061172692915061172a565b5090565b5b80821115611726576000815560010161172b565b80356001600160a01b03811681146103e957600080fd5b60006020828403121561176857600080fd5b6117718261173f565b9392505050565b8060005b600281101561179b57815184526020938401939091019060010161177c565b50505050565b6040810161036a8284611778565b6000602082840312156117c157600080fd5b5035919050565b600061016082840312156117db57600080fd5b50919050565b60008061018083850312156117f557600080fd5b6117fe8361173f565b915061180d84602085016117c8565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b60006040828403121561183e57600080fd5b82601f83011261184d57600080fd5b6040516040810181811067ffffffffffffffff8211171561187057611870611816565b806040525080604084018581111561188757600080fd5b845b818110156118a1578035835260209283019201611889565b509195945050505050565b600082601f8301126118bd57600080fd5b813567ffffffffffffffff808211156118d8576118d8611816565b604051601f8301601f19908116603f0116810190828211818310171561190057611900611816565b8160405283815286602085880101111561191957600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080610180838503121561194d57600080fd5b823567ffffffffffffffff81111561196457600080fd5b611970858286016118ac565b92505061180d84602085016117c8565b6000806040838503121561199357600080fd5b61199c8361173f565b915060208301356bffffffffffffffffffffffff811681146119bd57600080fd5b809150509250929050565b6101208101611a1382896001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b6bffffffffffffffffffffffff96909616608082015293151560a085015291151560c084015260e083015261010090910152919050565b600060208284031215611a5c57600080fd5b813567ffffffffffffffff811115611a7357600080fd5b611a7f848285016118ac565b949350505050565b6080810161036a82846001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b60408183375050565b6101a08101611ae98285611778565b604083604084013760408301356080830152606083013560a0830152608083013560c08301526001600160a01b03611b2360a0850161173f565b1660e0830152610100604060c08501828501376101406040828601828601378085013561018085015250509392505050565b600060208284031215611b6757600080fd5b5051919050565b600060208284031215611b8057600080fd5b8151801515811461177157600080fd5b60005b83811015611bab578181015183820152602001611b93565b50506000910152565b8281526040602082015260008251806040840152611bd9816060850160208701611b90565b601f01601f1916919091016060019392505050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561036a5761036a611bee565b6000818b825b6002811015611c3c578151835260209283019290910190600101611c1d565b50505060408a60408401378860808301528760a08301528660c08301526bffffffffffffffffffffffff198660601b1660e0830152611c7e60f4830186611ad1565b611c8c610134830185611ad1565b506101748101919091526101940198975050505050505050565b6040828237604001919050565b6bffffffffffffffffffffffff828116828216039080821115611cd857611cd8611bee565b5092915050565b6bffffffffffffffffffffffff818116838216019080821115611cd857611cd8611bee565b8181038181111561036a5761036a611bee565b60008183825b6002811015611d3c578154835260209092019160019182019101611d1d565b50505060408201905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351611d8381601a850160208801611b90565b835190830190611d9a81601a840160208801611b90565b01601a01949350505050565b634e487b7160e01b600052602160045260246000fdfea264697066735822122098df8515001e54f04cd5b3c6e771624fbe1b723cb79b71c6682b2ed6f55e3b1a64736f6c634300081300332296393f4c4bfde812a53ed8bfa841c6251e9891fb0def611331b716a935ec91ad75abb573aada6599df5d3b34fa26853d9f5d89691aef7b811b8463c1561d5a000000000000000000000000ed6a792f694b7a52e7cf4b7f02daa41a7c92f362000000000000000000000000674305ad68cf9c2f572d06b8b617ef3c6c74503e000000000000000000000000388a09a39619d5de01a10d78d23a3bc1528b7a470000000000000000000000000000000000000000000000000000000000000064

Deployed ByteCode

0x608060405234801561001057600080fd5b506004361061016c5760003560e01c80639a336be1116100cd578063e02bc3c811610081578063e7f43c6811610066578063e7f43c6814610322578063f2fde38b1461032a578063f4de72311461033d57600080fd5b8063e02bc3c8146102fa578063e5114f6c1461030257600080fd5b8063bf776ba4116100b2578063bf776ba4146102b1578063c0f948d2146102c4578063cfa51d9a146102d557600080fd5b80639a336be11461026c578063b0ab7dac1461027f57600080fd5b806372ceb2de116101245780637fcde1c2116101095780637fcde1c214610221578063803ab8db146102345780638da5cb5b1461024757600080fd5b806372ceb2de146101fb5780637dbfe9f51461020e57600080fd5b80633d6a3664116101555780633d6a3664146101bb5780634d3223a5146101de578063715018a6146101f157600080fd5b8063243904d4146101715780632e334452146101a6575b600080fd5b61018461017f366004611756565b610350565b6040516bffffffffffffffffffffffff90911681526020015b60405180910390f35b6101ae610370565b60405161019d91906117a1565b6101ce6101c9366004611756565b610385565b604051901515815260200161019d565b6101846101ec366004611756565b6103ee565b6101f96103f9565b005b6101ce610209366004611756565b61040d565b6101ce61021c3660046117af565b610475565b6101ce61022f3660046117e1565b6104b9565b6101ce61024236600461182c565b610716565b6000546001600160a01b03165b6040516001600160a01b03909116815260200161019d565b6101ce61027a366004611939565b610731565b6102a361028d366004611980565b60a01b1760009081526001602052604090205490565b60405190815260200161019d565b6101ce6102bf366004611939565b6108cb565b6006546001600160a01b0316610254565b6102e86102e3366004611939565b610be6565b60405161019d969594939291906119c8565b6102a3610d35565b610315610310366004611a4a565b610d3f565b60405161019d9190611a87565b610254610d6c565b6101f9610338366004611756565b610d80565b6102a361034b366004611756565b610e10565b6001600160a01b0381166000908152600260205260408120545b92915050565b6103786116ce565b610380610e1b565b905090565b600061038f610e55565b6007805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915560405133907fd85f66a2d033a785734c4777d12d2526304b1727ddd6774582a4ddb3474dac9790600090a35060015b919050565b600061036a82610eaf565b610401610e55565b61040b6000610eec565b565b6000610417610e55565b6006805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03841690811790915560405133907f5f710a9b3681930bf1343b51da6fa8f2476a09903e0831f661f36bd63892931a90600090a3506001919050565b600061047f610e55565b6008829055604051829033907fe71d538682fa7ee72ed8c324fac011fe5a8d0f5ceb54d49f35c82099889a957c90600090a3506001919050565b6000806104c584610f49565b9050808360800135146104fd576040516338e5849560e11b815260048101829052608084013560248201526044015b60405180910390fd5b6006546000906001600160a01b03166331ff34cf610519610e1b565b866040518363ffffffff1660e01b8152600401610537929190611ada565b602060405180830381865afa158015610554573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105789190611b55565b90506105848582610f79565b6001600160a01b0385163b1561070b5760005b60085481101561070957604051632f4a1ff560e01b8152600481018390526001600160a01b03871690632f4a1ff5906024016020604051808303816000875af11580156105e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061060c9190611b6e565b6106d15760075460408051606089901b6bffffffffffffffffffffffff191660208201528151601481830301815260348201928390527f0d9577c6000000000000000000000000000000000000000000000000000000009092526001600160a01b0390921691630d9577c6916106889160009190603801611bb4565b6020604051808303816000875af11580156106a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106cb9190611b6e565b50610709565b60408051602081018490520160408051601f1981840301815291905280516020909101209150610702600182611c04565b9050610597565b505b506001949350505050565b6000610720610e55565b6107298261100e565b506001919050565b60008061073d84611051565b9050600061074e8260200151610f49565b90508015158061076f575060408201516bffffffffffffffffffffffff1615155b156107a9576040517f2c364f1c000000000000000000000000000000000000000000000000000000008152600481018290526024016104f4565b6107b1610e1b565b846040810135606082013560808301356107d160c0850160a08601611756565b8960c0018a610100018b61014001356040516020016107f899989796959493929190611c17565b6040516020818303038152906040528051906020012060001c826060015114610834576040516305b604d760e01b815260040160405180910390fd5b6006546000906001600160a01b03166331ff34cf610850610e1b565b876040518363ffffffff1660e01b815260040161086e929190611ada565b602060405180830381865afa15801561088b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108af9190611b55565b90506108bf836020015182610f79565b50600195945050505050565b6000806108d784611051565b905060006108e88260200151610f49565b90506108fc6005546001600160a01b031690565b6001600160a01b031682600001516001600160a01b0316146109585781516040517fd90fe8e10000000000000000000000000000000000000000000000000000000081526001600160a01b0390911660048201526024016104f4565b80846080013514610989576040516338e5849560e11b815260048101829052608085013560248201526044016104f4565b610991610e1b565b846040810135606082013560808301356109b160c0850160a08601611756565b8960c0018a610100018b61014001356040516020016109d899989796959493929190611c17565b6040516020818303038152906040528051906020012060001c826060015114610a14576040516305b604d760e01b815260040160405180910390fd5b604051600090610a28908690602001611ca6565b6040516020818303038152906040528051906020012060001c9050610a51836020015182610f79565b60208301516001600160a01b03163b156108bf5760005b600854811015610bd9576020840151604051632f4a1ff560e01b8152600481018490526001600160a01b0390911690632f4a1ff5906024016020604051808303816000875af1158015610abf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae39190611b6e565b610ba1576007546020808601516040516001600160a01b0390931692630d9577c692600092610b2c9290910160609190911b6bffffffffffffffffffffffff1916815260140190565b6040516020818303038152906040526040518363ffffffff1660e01b8152600401610b58929190611bb4565b6020604051808303816000875af1158015610b77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b9b9190611b6e565b50610bd9565b60408051602081018490520160408051601f1981840301815291905280516020909101209150610bd2600182611c04565b9050610a68565b5060019695505050505050565b60408051608081018252600080825260208201819052918101829052606081018290529080808080610c1788611051565b9550610c21610e1b565b87604081013560608201356080830135610c4160c0850160a08601611756565b8c60c0018d610100018e6101400135604051602001610c6899989796959493929190611c17565b6040516020818303038152906040528051906020012060001c8660600151149250610c968660200151610eaf565b9450610ca58660200151610f49565b6006546080890135821495509092506001600160a01b03166331ff34cf610cca610e1b565b896040518363ffffffff1660e01b8152600401610ce8929190611ada565b602060405180830381865afa158015610d05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d299190611b55565b90509295509295509295565b6000610380611146565b60408051608081018252600080825260208201819052918101829052606081019190915261036a82611051565b60006103806005546001600160a01b031690565b610d88610e55565b6001600160a01b038116610e045760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104f4565b610e0d81610eec565b50565b600061036a82610f49565b610e236116ce565b60408051808201918290529060039060029082845b815481526020019060010190808311610e38575050505050905090565b6000546001600160a01b0316331461040b5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104f4565b6001600160a01b0381166000908152600260205260409020546bffffffffffffffffffffffff8116610ee1578061036a565b61036a600182611cb3565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060016000610f63610f5b85610eaf565b60a01b851790565b8152602001908152602001600020549050919050565b6001600160a01b03821660009081526002602090815260408083205460a081901b861784526001928390529220839055610fb4908290611cdf565b6001600160a01b0384166000818152600260205260408082206bffffffffffffffffffffffff9485169055518593851692917f50524705e17603fd96db3d4cbd148655f75d19bf9ab86067ef587134b7919e8091a4505050565b61101b60038260026116ec565b506020810151815160405133907fbfa225acb3bdc1bbe3faa03e81a000c6399a94d8db72b0c434dd5828b7083f5690600090a450565b60408051608081018252600080825260208201819052918101829052606081019190915281516081146110b55781516040517f0786993c0000000000000000000000000000000000000000000000000000000081526004016104f491815260200190565b60006110c383826041611175565b905060006110e160418086516110d99190611d04565b869190611175565b905060006110ef8282611231565b60a081901c60408601526001600160a01b03811660208087019190915290915061111a908390611231565b60608501526111328361112c8461127f565b906112ba565b6001600160a01b0316845250919392505050565b6000600360405160200161115a9190611d17565b60405160208183030381529060405280519060200120905090565b82516060906111848385611c04565b11156111b8576111948284611c04565b845160405163abe5c32f60e01b8152600481019290925260248201526044016104f4565b60008267ffffffffffffffff8111156111d3576111d3611816565b6040519080825280601f01601f1916602001820160405280156111fd576020820181803683370190505b5090508360208601016020820160005b8581101561122557828101518282015260200161120d565b50919695505050505050565b8151600090611241836020611c04565b111561127657611252826020611c04565b835160405163abe5c32f60e01b8152600481019290925260248201526044016104f4565b50016020015190565b600061128b82516112de565b8260405160200161129d929190611d4b565b604051602081830303815290604052805190602001209050919050565b60008060006112c9858561137e565b915091506112d6816113c3565b509392505050565b606060006112eb83611528565b600101905060008167ffffffffffffffff81111561130b5761130b611816565b6040519080825280601f01601f191660200182016040528015611335576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461133f57509392505050565b60008082516041036113b45760208301516040840151606085015160001a6113a88782858561160a565b945094505050506113bc565b506000905060025b9250929050565b60008160048111156113d7576113d7611da6565b036113df5750565b60018160048111156113f3576113f3611da6565b036114405760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016104f4565b600281600481111561145457611454611da6565b036114a15760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016104f4565b60038160048111156114b5576114b5611da6565b03610e0d5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f756500000000000000000000000000000000000000000000000000000000000060648201526084016104f4565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310611571577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef8100000000831061159d576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106115bb57662386f26fc10000830492506010015b6305f5e10083106115d3576305f5e100830492506008015b61271083106115e757612710830492506004015b606483106115f9576064830492506002015b600a831061036a5760010192915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561164157506000905060036116c5565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611695573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166116be576000600192509250506116c5565b9150600090505b94509492505050565b60405180604001604052806002906020820280368337509192915050565b826002810192821561171a579160200282015b8281111561171a5782518255916020019190600101906116ff565b5061172692915061172a565b5090565b5b80821115611726576000815560010161172b565b80356001600160a01b03811681146103e957600080fd5b60006020828403121561176857600080fd5b6117718261173f565b9392505050565b8060005b600281101561179b57815184526020938401939091019060010161177c565b50505050565b6040810161036a8284611778565b6000602082840312156117c157600080fd5b5035919050565b600061016082840312156117db57600080fd5b50919050565b60008061018083850312156117f557600080fd5b6117fe8361173f565b915061180d84602085016117c8565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b60006040828403121561183e57600080fd5b82601f83011261184d57600080fd5b6040516040810181811067ffffffffffffffff8211171561187057611870611816565b806040525080604084018581111561188757600080fd5b845b818110156118a1578035835260209283019201611889565b509195945050505050565b600082601f8301126118bd57600080fd5b813567ffffffffffffffff808211156118d8576118d8611816565b604051601f8301601f19908116603f0116810190828211818310171561190057611900611816565b8160405283815286602085880101111561191957600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080610180838503121561194d57600080fd5b823567ffffffffffffffff81111561196457600080fd5b611970858286016118ac565b92505061180d84602085016117c8565b6000806040838503121561199357600080fd5b61199c8361173f565b915060208301356bffffffffffffffffffffffff811681146119bd57600080fd5b809150509250929050565b6101208101611a1382896001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b6bffffffffffffffffffffffff96909616608082015293151560a085015291151560c084015260e083015261010090910152919050565b600060208284031215611a5c57600080fd5b813567ffffffffffffffff811115611a7357600080fd5b611a7f848285016118ac565b949350505050565b6080810161036a82846001600160a01b03808251168352806020830151166020840152506bffffffffffffffffffffffff6040820151166040830152606081015160608301525050565b60408183375050565b6101a08101611ae98285611778565b604083604084013760408301356080830152606083013560a0830152608083013560c08301526001600160a01b03611b2360a0850161173f565b1660e0830152610100604060c08501828501376101406040828601828601378085013561018085015250509392505050565b600060208284031215611b6757600080fd5b5051919050565b600060208284031215611b8057600080fd5b8151801515811461177157600080fd5b60005b83811015611bab578181015183820152602001611b93565b50506000910152565b8281526040602082015260008251806040840152611bd9816060850160208701611b90565b601f01601f1916919091016060019392505050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561036a5761036a611bee565b6000818b825b6002811015611c3c578151835260209283019290910190600101611c1d565b50505060408a60408401378860808301528760a08301528660c08301526bffffffffffffffffffffffff198660601b1660e0830152611c7e60f4830186611ad1565b611c8c610134830185611ad1565b506101748101919091526101940198975050505050505050565b6040828237604001919050565b6bffffffffffffffffffffffff828116828216039080821115611cd857611cd8611bee565b5092915050565b6bffffffffffffffffffffffff818116838216019080821115611cd857611cd8611bee565b8181038181111561036a5761036a611bee565b60008183825b6002811015611d3c578154835260209092019160019182019101611d1d565b50505060408201905092915050565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351611d8381601a850160208801611b90565b835190830190611d9a81601a840160208801611b90565b01601a01949350505050565b634e487b7160e01b600052602160045260246000fdfea264697066735822122098df8515001e54f04cd5b3c6e771624fbe1b723cb79b71c6682b2ed6f55e3b1a64736f6c63430008130033