Contract

0x4e92f3e6C619A5837F0b18aCD0f63f837e80697B

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

-

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SamWitchVRF

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 9999999 runs

Other Settings:
paris EvmVersion
File 1 of 14 : SamWitchVRF.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.20;

import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {VRF} from "./libraries/VRF.sol";

import {ISamWitchVRFConsumer} from "./interfaces/ISamWitchVRFConsumer.sol";

import {ISamWitchVRF} from "./interfaces/ISamWitchVRF.sol";

/// @title SamWitchVRF - Verifiable Random Number
/// @author Sam Witch (SamWitchVRF & Estfor Kingdom)
/// @notice This contract listens for requests for VRF, and allows the oracle to fulfill random numbers
contract SamWitchVRF is ISamWitchVRF, UUPSUpgradeable, OwnableUpgradeable {
  mapping(address consumer => uint256 nonce) public consumers;
  mapping(address oracles => bool isOracle) public oracles;
  mapping(bytes32 requestId => bytes32 commitment) private requestCommitments;

  // 5k is plenty for an EXTCODESIZE call (2600) + warm CALL (100)
  // and some arithmetic operations.
  uint256 private constant GAS_FOR_CALL_EXACT_CHECK = 5_000;

  /// @custom:oz-upgrades-unsafe-allow constructor
  constructor() {
    _disableInitializers();
  }

  /// @notice Initialize the contract as part of the proxy contract deployment
  function initialize(address oracle) external payable initializer {
    __UUPSUpgradeable_init();
    __Ownable_init(_msgSender());
    oracles[oracle] = true;
  }

  /// @notice Called by the requester to make a full request, which provides
  /// all of its parameters as arguments
  /// @param numWords Number of random words to request
  /// @return requestId Request ID
  function requestRandomWords(
    uint256 numWords,
    uint256 callbackGasLimit
  ) external override returns (bytes32 requestId) {
    address consumer = _msgSender();
    uint256 nonce = consumers[consumer];
    if (nonce == 0) {
      revert InvalidConsumer(consumer);
    }

    unchecked {
      nonce += 1;
    }

    consumers[consumer] = nonce;
    requestId = _computeRequestId(consumer, nonce);

    requestCommitments[requestId] = keccak256(
      abi.encode(requestId, callbackGasLimit, numWords, consumer, block.chainid)
    );

    emit RandomWordsRequested(requestId, callbackGasLimit, numWords, consumer, nonce);
  }

  /// @notice Fulfill the request
  /// @param requestId Request ID
  /// @param fulfillAddress The address to fulfill the request
  /// @param callbackGasLimit The amount of gas to provide the consumer
  /// @param numWords The number of words to fulfill
  /// @param publicKey The public key of the oracle
  /// @param proof The proof of the random words
  /// @param uPoint The `u` EC point defined as `U = s*B - c*Y`
  /// @param vComponents The components required to compute `v` as `V = s*H - c*Gamma`
  /// @return callSuccess If the fulfillment call succeeded
  function fulfillRandomWords(
    bytes32 requestId,
    address oracle,
    address fulfillAddress,
    uint256 callbackGasLimit,
    uint256 numWords,
    uint256[2] calldata publicKey,
    uint256[4] calldata proof,
    uint256[2] calldata uPoint,
    uint256[4] calldata vComponents
  ) external override returns (bool callSuccess) {
    if (!oracles[oracle]) {
      revert OnlyOracle();
    }

    bytes32 commitment = keccak256(abi.encode(requestId, callbackGasLimit, numWords, fulfillAddress, block.chainid));
    if (requestCommitments[requestId] != commitment) {
      revert CommitmentMismatch();
    }

    // Verify the public key & proof are correct
    if (VRF.pointToAddress(publicKey[0], publicKey[1]) != oracle) {
      revert InvalidPublicKey();
    }
    if (!VRF.fastVerify(publicKey, proof, bytes.concat(commitment), uPoint, vComponents)) {
      revert InvalidProof();
    }

    // Get random words out of the proof
    uint256 randomness = _randomValueFromVRFProof(proof);
    uint256[] memory randomWords = new uint256[](numWords);
    for (uint256 i = 0; i < numWords; ++i) {
      randomWords[i] = uint256(keccak256(abi.encode(randomness, i)));
    }
    delete requestCommitments[requestId];

    // Call the consumer contract callback
    bytes memory data = abi.encodeWithSelector(
      ISamWitchVRFConsumer.fulfillRandomWords.selector,
      requestId,
      randomWords
    );
    callSuccess = _callWithExactGas(callbackGasLimit, fulfillAddress, data);
    if (callSuccess) {
      emit RandomWordsFulfilled(requestId, randomWords, oracle);
    } else {
      revert FulfillmentFailed(requestId);
    }
  }

  /// @dev Compute the parameters (EC points) required for the VRF fast verification function.
  /// @param publicKey The public key as an array composed of `[pubKey-x, pubKey-y]`
  /// @param proof The VRF proof as an array composed of `[gamma-x, gamma-y, c, s]`
  /// @param message The message (in bytes) used for computing the VRF
  /// @return The fast verify required parameters as the tuple `([uPointX, uPointY], [sHX, sHY, cGammaX, cGammaY])`
  function computeFastVerifyParams(
    uint256[2] calldata publicKey,
    uint256[4] calldata proof,
    bytes calldata message
  ) external pure returns (uint256[2] memory, uint256[4] memory) {
    return VRF.computeFastVerifyParams(publicKey, proof, message);
  }

  /// @notice Register a consumer to be able to request random words
  ///@param consumer An address which is allowed to request random words
  function registerConsumer(address consumer) external onlyOwner {
    consumers[consumer] = 1;
    emit ConsumerRegistered(consumer);
  }

  function _computeRequestId(address sender, uint256 nonce) private pure returns (bytes32) {
    return keccak256(abi.encodePacked(sender, nonce));
  }

  /// @dev calls target address with exactly gasAmount gas and data as calldata
  /// or reverts if at least gasAmount gas is not available.
  function _callWithExactGas(uint256 gasAmount, address target, bytes memory data) private returns (bool success) {
    // solhint-disable-next-line no-inline-assembly
    assembly ("memory-safe") {
      let g := gas()
      // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow
      // The gas actually passed to the callee is min(gasAmount, 63//64*gas available).
      // We want to ensure that we revert if gasAmount >  63//64*gas available
      // as we do not want to provide them with less, however that check itself costs
      // gas.  GAS_FOR_CALL_EXACT_CHECK ensures we have at least enough gas to be able
      // to revert if gasAmount >  63//64*gas available.
      if lt(g, GAS_FOR_CALL_EXACT_CHECK) {
        revert(0, 0)
      }
      g := sub(g, GAS_FOR_CALL_EXACT_CHECK)
      // if g - g//64 <= gasAmount, revert
      // (we subtract g//64 because of EIP-150)
      if iszero(gt(sub(g, div(g, 64)), gasAmount)) {
        revert(0, 0)
      }
      // solidity calls check that a contract actually exists at the destination, so we do the same
      if iszero(extcodesize(target)) {
        revert(0, 0)
      }
      // call and return whether we succeeded. ignore return data
      // call(gas,addr,value,argsOffset,argsLength,retOffset,retLength)
      success := call(gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0)
    }
    return success;
  }

  function _randomValueFromVRFProof(uint256[4] calldata _proof) private view returns (uint256 output) {
    return uint256(keccak256(abi.encode(block.chainid, _proof[0], _proof[1])));
  }

  // solhint-disable-next-line no-empty-blocks
  function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}

File 2 of 14 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @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.
 *
 * The initial owner is set to the address provided by the deployer. 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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable
    struct OwnableStorage {
        address _owner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
        assembly {
            $.slot := OwnableStorageLocation
        }
    }

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

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

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    function __Ownable_init(address initialOwner) internal onlyInitializing {
        __Ownable_init_unchained(initialOwner);
    }

    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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) {
        OwnableStorage storage $ = _getOwnableStorage();
        return $._owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

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

File 3 of 14 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

File 4 of 14 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.20;

import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol";
import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol";
import {Initializable} from "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
    address private immutable __self = address(this);

    /**
     * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`
     * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,
     * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.
     * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must
     * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function
     * during an upgrade.
     */
    string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";

    /**
     * @dev The call is from an unauthorized context.
     */
    error UUPSUnauthorizedCallContext();

    /**
     * @dev The storage `slot` is unsupported as a UUID.
     */
    error UUPSUnsupportedProxiableUUID(bytes32 slot);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        _checkProxy();
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        _checkNotDelegated();
        _;
    }

    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual notDelegated returns (bytes32) {
        return ERC1967Utils.IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     *
     * @custom:oz-upgrades-unsafe-allow-reachable delegatecall
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data);
    }

    /**
     * @dev Reverts if the execution is not performed via delegatecall or the execution
     * context is not of a proxy with an ERC1967-compliant implementation pointing to self.
     * See {_onlyProxy}.
     */
    function _checkProxy() internal view virtual {
        if (
            address(this) == __self || // Must be called through delegatecall
            ERC1967Utils.getImplementation() != __self // Must be called through an active proxy
        ) {
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Reverts if the execution is performed via delegatecall.
     * See {notDelegated}.
     */
    function _checkNotDelegated() internal view virtual {
        if (address(this) != __self) {
            // Must not be called through delegatecall
            revert UUPSUnauthorizedCallContext();
        }
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

    /**
     * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.
     *
     * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value
     * is expected to be the implementation slot in ERC1967.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {
        try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
            if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
                revert UUPSUnsupportedProxiableUUID(slot);
            }
            ERC1967Utils.upgradeToAndCall(newImplementation, data);
        } catch {
            // The implementation is not UUPS
            revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
        }
    }
}

File 5 of 14 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    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 6 of 14 : draft-IERC1822.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.20;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822Proxiable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 7 of 14 : IBeacon.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeacon {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {UpgradeableBeacon} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 8 of 14 : ERC1967Utils.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)

pragma solidity ^0.8.20;

import {IBeacon} from "../beacon/IBeacon.sol";
import {Address} from "../../utils/Address.sol";
import {StorageSlot} from "../../utils/StorageSlot.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 */
library ERC1967Utils {
    // We re-declare ERC-1967 events here because they can't be used directly from IERC1967.
    // This will be fixed in Solidity 0.8.21. At that point we should remove these events.
    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Emitted when the beacon is changed.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev The `implementation` of the proxy is invalid.
     */
    error ERC1967InvalidImplementation(address implementation);

    /**
     * @dev The `admin` of the proxy is invalid.
     */
    error ERC1967InvalidAdmin(address admin);

    /**
     * @dev The `beacon` of the proxy is invalid.
     */
    error ERC1967InvalidBeacon(address beacon);

    /**
     * @dev An upgrade function sees `msg.value > 0` that may be lost.
     */
    error ERC1967NonPayable();

    /**
     * @dev Returns the current implementation address.
     */
    function getImplementation() internal view returns (address) {
        return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        if (newImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(newImplementation);
        }
        StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Performs implementation upgrade with additional setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);

        if (data.length > 0) {
            Address.functionDelegateCall(newImplementation, data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Returns the current admin.
     *
     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using
     * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
     */
    function getAdmin() internal view returns (address) {
        return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        if (newAdmin == address(0)) {
            revert ERC1967InvalidAdmin(address(0));
        }
        StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {IERC1967-AdminChanged} event.
     */
    function changeAdmin(address newAdmin) internal {
        emit AdminChanged(getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1.
     */
    // solhint-disable-next-line private-vars-leading-underscore
    bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Returns the current beacon.
     */
    function getBeacon() internal view returns (address) {
        return StorageSlot.getAddressSlot(BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        if (newBeacon.code.length == 0) {
            revert ERC1967InvalidBeacon(newBeacon);
        }

        StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;

        address beaconImplementation = IBeacon(newBeacon).implementation();
        if (beaconImplementation.code.length == 0) {
            revert ERC1967InvalidImplementation(beaconImplementation);
        }
    }

    /**
     * @dev Change the beacon and trigger a setup call if data is nonempty.
     * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected
     * to avoid stuck value in the contract.
     *
     * Emits an {IERC1967-BeaconUpgraded} event.
     *
     * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since
     * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for
     * efficiency.
     */
    function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);

        if (data.length > 0) {
            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
        } else {
            _checkNonPayable();
        }
    }

    /**
     * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract
     * if an upgrade doesn't perform an initialization call.
     */
    function _checkNonPayable() private {
        if (msg.value > 0) {
            revert ERC1967NonPayable();
        }
    }
}

File 9 of 14 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

File 10 of 14 : StorageSlot.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.

pragma solidity ^0.8.20;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```solidity
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(newImplementation.code.length > 0);
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 */
library StorageSlot {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    struct StringSlot {
        string value;
    }

    struct BytesSlot {
        bytes value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` with member `value` located at `slot`.
     */
    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.
     */
    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` with member `value` located at `slot`.
     */
    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
     */
    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := store.slot
        }
    }
}

File 11 of 14 : ISamWitchVRF.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.20;

interface ISamWitchVRF {
  event ConsumerRegistered(address consumer);
  event RandomWordsRequested(
    bytes32 requestId,
    uint256 callbackGasLimit,
    uint256 numWords,
    address consumer,
    uint256 nonce
  );
  event RandomWordsFulfilled(bytes32 requestId, uint[] randomWords, address oracle);

  error FulfillmentFailed(bytes32 requestId);
  error InvalidConsumer(address consumer);
  error InvalidProof();
  error InvalidPublicKey();
  error OnlyOracle();
  error CommitmentMismatch();

  /// @notice Request some number of random words
  ///
  /// @param numWords The number of words to request
  /// @param callbackGasLimit The amount of gas to provide the consumer
  /// @return requestId The ID of the request
  function requestRandomWords(uint256 numWords, uint256 callbackGasLimit) external returns (bytes32 requestId);

  /// @notice Fulfill the request for random words
  ///
  /// @param requestId The ID of the request
  /// @param oracle The address of the oracle fulfilling the request
  /// @param fulfillAddress The address to fulfill the request
  /// @param callbackGasLimit The amount of gas to provide the consumer
  /// @param numWords The number of words to fulfill
  /// @param publicKey The public key of the oracle
  /// @param proof The proof of the random words
  /// @param uPoint The `u` EC point defined as `U = s*B - c*Y`
  /// @param vComponents The components required to compute `v` as `V = s*H - c*Gamma`
  /// @return callSuccess If the fulfillment call succeeded
  function fulfillRandomWords(
    bytes32 requestId,
    address oracle,
    address fulfillAddress,
    uint256 callbackGasLimit,
    uint256 numWords,
    uint256[2] memory publicKey,
    uint256[4] memory proof,
    uint256[2] memory uPoint,
    uint256[4] memory vComponents
  ) external returns (bool callSuccess);
}

File 12 of 14 : ISamWitchVRFConsumer.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.20;

interface ISamWitchVRFConsumer {
  /**
   * @notice fulfillRandomness handles the VRF response. Your contract must
   * @notice implement it.
   *
   * @param requestId The Id initially returned by requestRandomness
   * @param randomWords the VRF output expanded to the requested number of words
   */
  function fulfillRandomWords(bytes32 requestId, uint[] calldata randomWords) external;
}

File 13 of 14 : EllipticCurve.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 ** @title Elliptic Curve Library
 ** @dev Library providing arithmetic operations over elliptic curves.
 ** This library does not check whether the inserted points belong to the curve
 ** `isOnCurve` function should be used by the library user to check the aforementioned statement.
 ** @author Witnet Foundation
 */
library EllipticCurve {
  // Pre-computed constant for 2 ** 255
  uint256 private constant U255_MAX_PLUS_1 =
    57896044618658097711785492504343953926634992332820282019728792003956564819968;

  error InvalidNumber(uint256 _x, uint256 _pp);
  error ModulusIsZero();
  error InvalidCompressedECPointPrefix(uint8 _prefix);
  error UseJacDoubleFunctionInstead();

  /// @dev Modular euclidean inverse of a number (mod p).
  /// @param _x The number
  /// @param _pp The modulus
  /// @return q such that x*q = 1 (mod _pp)
  function invMod(uint256 _x, uint256 _pp) internal pure returns (uint256) {
    if (_x == 0 || _x == _pp || _pp == 0) {
      revert InvalidNumber(_x, _pp);
    }
    uint256 q = 0;
    uint256 newT = 1;
    uint256 r = _pp;
    uint256 t;
    while (_x != 0) {
      t = r / _x;
      (q, newT) = (newT, addmod(q, (_pp - mulmod(t, newT, _pp)), _pp));
      (r, _x) = (_x, r - t * _x);
    }

    return q;
  }

  /// @dev Modular exponentiation, b^e % _pp.
  /// Source: https://github.com/androlo/standard-contracts/blob/master/contracts/src/crypto/ECCMath.sol
  /// @param _base base
  /// @param _exp exponent
  /// @param _pp modulus
  /// @return r such that r = b**e (mod _pp)
  function expMod(uint256 _base, uint256 _exp, uint256 _pp) internal pure returns (uint256) {
    if (_pp == 0) {
      revert ModulusIsZero();
    }

    if (_base == 0) return 0;
    if (_exp == 0) return 1;

    uint256 r = 1;
    uint256 bit = U255_MAX_PLUS_1;
    assembly ("memory-safe") {
      for {

      } gt(bit, 0) {

      } {
        r := mulmod(mulmod(r, r, _pp), exp(_base, iszero(iszero(and(_exp, bit)))), _pp)
        r := mulmod(mulmod(r, r, _pp), exp(_base, iszero(iszero(and(_exp, div(bit, 2))))), _pp)
        r := mulmod(mulmod(r, r, _pp), exp(_base, iszero(iszero(and(_exp, div(bit, 4))))), _pp)
        r := mulmod(mulmod(r, r, _pp), exp(_base, iszero(iszero(and(_exp, div(bit, 8))))), _pp)
        bit := div(bit, 16)
      }
    }

    return r;
  }

  /// @dev Converts a point (x, y, z) expressed in Jacobian coordinates to affine coordinates (x', y', 1).
  /// @param _x coordinate x
  /// @param _y coordinate y
  /// @param _z coordinate z
  /// @param _pp the modulus
  /// @return (x', y') affine coordinates
  function toAffine(uint256 _x, uint256 _y, uint256 _z, uint256 _pp) internal pure returns (uint256, uint256) {
    uint256 zInv = invMod(_z, _pp);
    uint256 zInv2 = mulmod(zInv, zInv, _pp);
    uint256 x2 = mulmod(_x, zInv2, _pp);
    uint256 y2 = mulmod(_y, mulmod(zInv, zInv2, _pp), _pp);

    return (x2, y2);
  }

  /// @dev Derives the y coordinate from a compressed-format point x [[SEC-1]](https://www.secg.org/SEC1-Ver-1.0.pdf).
  /// @param _prefix parity byte (0x02 even, 0x03 odd)
  /// @param _x coordinate x
  /// @param _aa constant of curve
  /// @param _bb constant of curve
  /// @param _pp the modulus
  /// @return y coordinate y
  function deriveY(uint8 _prefix, uint256 _x, uint256 _aa, uint256 _bb, uint256 _pp) internal pure returns (uint256) {
    if (_prefix != 0x02 && _prefix != 0x03) {
      revert InvalidCompressedECPointPrefix(_prefix);
    }

    // x^3 + ax + b
    uint256 y2 = addmod(mulmod(_x, mulmod(_x, _x, _pp), _pp), addmod(mulmod(_x, _aa, _pp), _bb, _pp), _pp);
    y2 = expMod(y2, (_pp + 1) / 4, _pp);
    // uint256 cmp = yBit ^ y_ & 1;
    uint256 y = (y2 + _prefix) % 2 == 0 ? y2 : _pp - y2;

    return y;
  }

  /// @dev Check whether point (x,y) is on curve defined by a, b, and _pp.
  /// @param _x coordinate x of P1
  /// @param _y coordinate y of P1
  /// @param _aa constant of curve
  /// @param _bb constant of curve
  /// @param _pp the modulus
  /// @return true if x,y in the curve, false else
  function isOnCurve(uint _x, uint _y, uint _aa, uint _bb, uint _pp) internal pure returns (bool) {
    if (0 == _x || _x >= _pp || 0 == _y || _y >= _pp) {
      return false;
    }
    // y^2
    uint lhs = mulmod(_y, _y, _pp);
    // x^3
    uint rhs = mulmod(mulmod(_x, _x, _pp), _x, _pp);
    if (_aa != 0) {
      // x^3 + a*x
      rhs = addmod(rhs, mulmod(_x, _aa, _pp), _pp);
    }
    if (_bb != 0) {
      // x^3 + a*x + b
      rhs = addmod(rhs, _bb, _pp);
    }

    return lhs == rhs;
  }

  /// @dev Calculate inverse (x, -y) of point (x, y).
  /// @param _x coordinate x of P1
  /// @param _y coordinate y of P1
  /// @param _pp the modulus
  /// @return (x, -y)
  function ecInv(uint256 _x, uint256 _y, uint256 _pp) internal pure returns (uint256, uint256) {
    return (_x, (_pp - _y) % _pp);
  }

  /// @dev Add two points (x1, y1) and (x2, y2) in affine coordinates.
  /// @param _x1 coordinate x of P1
  /// @param _y1 coordinate y of P1
  /// @param _x2 coordinate x of P2
  /// @param _y2 coordinate y of P2
  /// @param _aa constant of the curve
  /// @param _pp the modulus
  /// @return (qx, qy) = P1+P2 in affine coordinates
  function ecAdd(
    uint256 _x1,
    uint256 _y1,
    uint256 _x2,
    uint256 _y2,
    uint256 _aa,
    uint256 _pp
  ) internal pure returns (uint256, uint256) {
    uint x = 0;
    uint y = 0;
    uint z = 0;

    // Double if x1==x2 else add
    if (_x1 == _x2) {
      // y1 = -y2 mod p
      if (addmod(_y1, _y2, _pp) == 0) {
        return (0, 0);
      } else {
        // P1 = P2
        (x, y, z) = jacDouble(_x1, _y1, 1, _aa, _pp);
      }
    } else {
      (x, y, z) = jacAdd(_x1, _y1, 1, _x2, _y2, 1, _pp);
    }
    // Get back to affine
    return toAffine(x, y, z, _pp);
  }

  /// @dev Substract two points (x1, y1) and (x2, y2) in affine coordinates.
  /// @param _x1 coordinate x of P1
  /// @param _y1 coordinate y of P1
  /// @param _x2 coordinate x of P2
  /// @param _y2 coordinate y of P2
  /// @param _aa constant of the curve
  /// @param _pp the modulus
  /// @return (qx, qy) = P1-P2 in affine coordinates
  function ecSub(
    uint256 _x1,
    uint256 _y1,
    uint256 _x2,
    uint256 _y2,
    uint256 _aa,
    uint256 _pp
  ) internal pure returns (uint256, uint256) {
    // invert square
    (uint256 x, uint256 y) = ecInv(_x2, _y2, _pp);
    // P1-square
    return ecAdd(_x1, _y1, x, y, _aa, _pp);
  }

  /// @dev Multiply point (x1, y1, z1) times d in affine coordinates.
  /// @param _k scalar to multiply
  /// @param _x coordinate x of P1
  /// @param _y coordinate y of P1
  /// @param _aa constant of the curve
  /// @param _pp the modulus
  /// @return (qx, qy) = d*P in affine coordinates
  function ecMul(
    uint256 _k,
    uint256 _x,
    uint256 _y,
    uint256 _aa,
    uint256 _pp
  ) internal pure returns (uint256, uint256) {
    // Jacobian multiplication
    (uint256 x1, uint256 y1, uint256 z1) = jacMul(_k, _x, _y, 1, _aa, _pp);
    // Get back to affine
    return toAffine(x1, y1, z1, _pp);
  }

  /// @dev Adds two points (x1, y1, z1) and (x2 y2, z2).
  /// @param _x1 coordinate x of P1
  /// @param _y1 coordinate y of P1
  /// @param _z1 coordinate z of P1
  /// @param _x2 coordinate x of square
  /// @param _y2 coordinate y of square
  /// @param _z2 coordinate z of square
  /// @param _pp the modulus
  /// @return (qx, qy, qz) P1+square in Jacobian
  function jacAdd(
    uint256 _x1,
    uint256 _y1,
    uint256 _z1,
    uint256 _x2,
    uint256 _y2,
    uint256 _z2,
    uint256 _pp
  ) internal pure returns (uint256, uint256, uint256) {
    if (_x1 == 0 && _y1 == 0) return (_x2, _y2, _z2);
    if (_x2 == 0 && _y2 == 0) return (_x1, _y1, _z1);

    // We follow the equations described in https://pdfs.semanticscholar.org/5c64/29952e08025a9649c2b0ba32518e9a7fb5c2.pdf Section 5
    uint[4] memory zs; // z1^2, z1^3, z2^2, z2^3
    zs[0] = mulmod(_z1, _z1, _pp);
    zs[1] = mulmod(_z1, zs[0], _pp);
    zs[2] = mulmod(_z2, _z2, _pp);
    zs[3] = mulmod(_z2, zs[2], _pp);

    // u1, s1, u2, s2
    zs = [mulmod(_x1, zs[2], _pp), mulmod(_y1, zs[3], _pp), mulmod(_x2, zs[0], _pp), mulmod(_y2, zs[1], _pp)];

    // In case of zs[0] == zs[2] && zs[1] == zs[3], double function should be used
    if (zs[0] == zs[2] && zs[1] == zs[3]) {
      revert UseJacDoubleFunctionInstead();
    }

    uint[4] memory hr;
    //h
    hr[0] = addmod(zs[2], _pp - zs[0], _pp);
    //r
    hr[1] = addmod(zs[3], _pp - zs[1], _pp);
    //h^2
    hr[2] = mulmod(hr[0], hr[0], _pp);
    // h^3
    hr[3] = mulmod(hr[2], hr[0], _pp);
    // qx = -h^3  -2u1h^2+r^2
    uint256 qx = addmod(mulmod(hr[1], hr[1], _pp), _pp - hr[3], _pp);
    qx = addmod(qx, _pp - mulmod(2, mulmod(zs[0], hr[2], _pp), _pp), _pp);
    // qy = -s1*z1*h^3+r(u1*h^2 -x^3)
    uint256 qy = mulmod(hr[1], addmod(mulmod(zs[0], hr[2], _pp), _pp - qx, _pp), _pp);
    qy = addmod(qy, _pp - mulmod(zs[1], hr[3], _pp), _pp);
    // qz = h*z1*z2
    uint256 qz = mulmod(hr[0], mulmod(_z1, _z2, _pp), _pp);
    return (qx, qy, qz);
  }

  /// @dev Doubles a points (x, y, z).
  /// @param _x coordinate x of P1
  /// @param _y coordinate y of P1
  /// @param _z coordinate z of P1
  /// @param _aa the a scalar in the curve equation
  /// @param _pp the modulus
  /// @return (qx, qy, qz) 2P in Jacobian
  function jacDouble(
    uint256 _x,
    uint256 _y,
    uint256 _z,
    uint256 _aa,
    uint256 _pp
  ) internal pure returns (uint256, uint256, uint256) {
    if (_z == 0) return (_x, _y, _z);

    // We follow the equations described in https://pdfs.semanticscholar.org/5c64/29952e08025a9649c2b0ba32518e9a7fb5c2.pdf Section 5
    // Note: there is a bug in the paper regarding the m parameter, M=3*(x1^2)+a*(z1^4)
    // x, y, z at this point represent the squares of _x, _y, _z
    uint256 x = mulmod(_x, _x, _pp); //x1^2
    uint256 y = mulmod(_y, _y, _pp); //y1^2
    uint256 z = mulmod(_z, _z, _pp); //z1^2

    // s
    uint s = mulmod(4, mulmod(_x, y, _pp), _pp);
    // m
    uint m = addmod(mulmod(3, x, _pp), mulmod(_aa, mulmod(z, z, _pp), _pp), _pp);

    // x, y, z at this point will be reassigned and rather represent qx, qy, qz from the paper
    // This allows to reduce the gas cost and stack footprint of the algorithm
    // qx
    x = addmod(mulmod(m, m, _pp), _pp - addmod(s, s, _pp), _pp);
    // qy = -8*y1^4 + M(S-T)
    y = addmod(mulmod(m, addmod(s, _pp - x, _pp), _pp), _pp - mulmod(8, mulmod(y, y, _pp), _pp), _pp);
    // qz = 2*y1*z1
    z = mulmod(2, mulmod(_y, _z, _pp), _pp);

    return (x, y, z);
  }

  /// @dev Multiply point (x, y, z) times d.
  /// @param _d scalar to multiply
  /// @param _x coordinate x of P1
  /// @param _y coordinate y of P1
  /// @param _z coordinate z of P1
  /// @param _aa constant of curve
  /// @param _pp the modulus
  /// @return (qx, qy, qz) d*P1 in Jacobian
  function jacMul(
    uint256 _d,
    uint256 _x,
    uint256 _y,
    uint256 _z,
    uint256 _aa,
    uint256 _pp
  ) internal pure returns (uint256, uint256, uint256) {
    // Early return in case that `_d == 0`
    if (_d == 0) {
      return (_x, _y, _z);
    }

    uint256 remaining = _d;
    uint256 qx = 0;
    uint256 qy = 0;
    uint256 qz = 1;

    // Double and add algorithm
    while (remaining != 0) {
      if ((remaining & 1) != 0) {
        (qx, qy, qz) = jacAdd(qx, qy, qz, _x, _y, _z, _pp);
      }
      remaining = remaining / 2;
      (_x, _y, _z) = jacDouble(_x, _y, _z, _aa, _pp);
    }
    return (qx, qy, qz);
  }
}

File 14 of 14 : VRF.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {EllipticCurve} from "./EllipticCurve.sol";

/**
 * @title Verifiable Random Functions (VRF)
 * @notice Library verifying VRF proofs using the `Secp256k1` curve and the `SHA256` hash function.
 * @dev This library follows the algorithms described in [VRF-draft-04](https://tools.ietf.org/pdf/draft-irtf-cfrg-vrf-04) and [RFC6979](https://tools.ietf.org/html/rfc6979).
 * It supports the _SECP256K1_SHA256_TAI_ cipher suite, i.e. the aforementioned algorithms using `SHA256` and the `Secp256k1` curve.
 * @author Witnet Foundation
 */
library VRF {
  /**
   * Secp256k1 parameters
   */

  // Generator coordinate `x` of the EC curve
  uint256 public constant GX = 0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798;
  // Generator coordinate `y` of the EC curve
  uint256 public constant GY = 0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8;
  // Constant `a` of EC equation
  uint256 public constant AA = 0;
  // Constant `b` of EC equation
  uint256 public constant BB = 7;
  // Prime number of the curve
  uint256 public constant PP = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F;
  // Order of the curve
  uint256 public constant NN = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141;

  error MalformedVRFProof();
  error MalformedCompressedECPoint();
  error NoValidPointFound();

  /// @dev Public key derivation from private key.
  /// Warning: this function should not be used to derive your public key as it would expose the private key.
  /// @param _d The scalar
  /// @param _x The coordinate x
  /// @param _y The coordinate y
  /// @return (qx, qy) The derived point
  function derivePoint(uint256 _d, uint256 _x, uint256 _y) internal pure returns (uint256, uint256) {
    return EllipticCurve.ecMul(_d, _x, _y, AA, PP);
  }

  /// @dev Function to derive the `y` coordinate given the `x` coordinate and the parity byte (`0x03` for odd `y` and `0x04` for even `y`).
  /// @param _yByte The parity byte following the ec point compressed format
  /// @param _x The coordinate `x` of the point
  /// @return The coordinate `y` of the point
  function deriveY(uint8 _yByte, uint256 _x) internal pure returns (uint256) {
    return EllipticCurve.deriveY(_yByte, _x, AA, BB, PP);
  }

  /// @dev Computes the VRF hash output as result of the digest of a ciphersuite-dependent prefix
  /// concatenated with the gamma point
  /// @param _gammaX The x-coordinate of the gamma EC point
  /// @param _gammaY The y-coordinate of the gamma EC point
  /// @return The VRF hash ouput as shas256 digest
  function gammaToHash(uint256 _gammaX, uint256 _gammaY) internal pure returns (bytes32) {
    bytes memory c = abi.encodePacked(
      // Cipher suite code (SECP256K1-SHA256-TAI is 0xFE)
      uint8(0xFE),
      // 0x03
      uint8(0x03),
      // Compressed Gamma Point
      encodePoint(_gammaX, _gammaY)
    );

    return sha256(c);
  }

  /// @dev VRF verification by providing the public key, the message and the VRF proof.
  /// This function computes several elliptic curve operations which may lead to extensive gas consumption.
  /// @param _publicKey The public key as an array composed of `[pubKey-x, pubKey-y]`
  /// @param _proof The VRF proof as an array composed of `[gamma-x, gamma-y, c, s]`
  /// @param _message The message (in bytes) used for computing the VRF
  /// @return true, if VRF proof is valid
  function verify(
    uint256[2] calldata _publicKey,
    uint256[4] calldata _proof,
    bytes calldata _message
  ) internal pure returns (bool) {
    // Step 2: Hash to try and increment (outputs a hashed value, a finite EC point in G)
    (uint256 hPointX, uint256 hPointY) = hashToTryAndIncrement(_publicKey, _message);

    // Step 3: U = s*B - c*Y (where B is the generator)
    (uint256 uPointX, uint256 uPointY) = ecMulSubMul(_proof[3], GX, GY, _proof[2], _publicKey[0], _publicKey[1]);

    // Step 4: V = s*H - c*Gamma
    (uint256 vPointX, uint256 vPointY) = ecMulSubMul(_proof[3], hPointX, hPointY, _proof[2], _proof[0], _proof[1]);

    // Step 5: derived c from hash points(...)
    bytes16 derivedC = hashPoints(hPointX, hPointY, _proof[0], _proof[1], uPointX, uPointY, vPointX, vPointY);

    // Step 6: Check validity c == c'
    return uint128(derivedC) == _proof[2];
  }

  /// @dev VRF fast verification by providing the public key, the message, the VRF proof and several intermediate elliptic curve points that enable the verification shortcut.
  /// This function leverages the EVM's `ecrecover` precompile to verify elliptic curve multiplications by decreasing the security from 32 to 20 bytes.
  /// Based on the original idea of Vitalik Buterin: https://ethresear.ch/t/you-can-kinda-abuse-ecrecover-to-do-ecmul-in-secp256k1-today/2384/9
  /// @param _publicKey The public key as an array composed of `[pubKey-x, pubKey-y]`
  /// @param _proof The VRF proof as an array composed of `[gamma-x, gamma-y, c, s]`
  /// @param _message The message (in bytes) used for computing the VRF
  /// @param _uPoint The `u` EC point defined as `U = s*B - c*Y`
  /// @param _vComponents The components required to compute `v` as `V = s*H - c*Gamma`
  /// @return true, if VRF proof is valid
  function fastVerify(
    uint256[2] calldata _publicKey,
    uint256[4] calldata _proof,
    bytes memory _message,
    uint256[2] calldata _uPoint,
    uint256[4] calldata _vComponents
  ) internal pure returns (bool) {
    // Step 2: Hash to try and increment -> hashed value, a finite EC point in G
    (uint256 hPointX, uint256 hPointY) = hashToTryAndIncrement(_publicKey, _message);

    // Step 3 & Step 4:
    // U = s*B - c*Y (where B is the generator)
    // V = s*H - c*Gamma
    if (
      !ecMulSubMulVerify(_proof[3], _proof[2], _publicKey[0], _publicKey[1], _uPoint[0], _uPoint[1]) ||
      !ecMulVerify(_proof[3], hPointX, hPointY, _vComponents[0], _vComponents[1]) ||
      !ecMulVerify(_proof[2], _proof[0], _proof[1], _vComponents[2], _vComponents[3])
    ) {
      return false;
    }
    (uint256 vPointX, uint256 vPointY) = EllipticCurve.ecSub(
      _vComponents[0],
      _vComponents[1],
      _vComponents[2],
      _vComponents[3],
      AA,
      PP
    );

    // Step 5: derived c from hash points(...)
    bytes16 derivedC = hashPoints(hPointX, hPointY, _proof[0], _proof[1], _uPoint[0], _uPoint[1], vPointX, vPointY);

    // Step 6: Check validity c == c'
    return uint128(derivedC) == _proof[2];
  }

  /// @dev Decode VRF proof from bytes
  /// @param _proof The VRF proof as bytes
  /// @return The VRF proof as an array composed of `[gamma-x, gamma-y, c, s]`
  function decodeProof(bytes memory _proof) internal pure returns (uint[4] memory) {
    if (_proof.length != 81) {
      revert MalformedVRFProof();
    }
    uint8 gammaSign;
    uint256 gammaX;
    uint128 c;
    uint256 s;
    assembly ("memory-safe") {
      gammaSign := mload(add(_proof, 1))
      gammaX := mload(add(_proof, 33))
      c := mload(add(_proof, 49))
      s := mload(add(_proof, 81))
    }
    uint256 gammaY = deriveY(gammaSign, gammaX);

    return [gammaX, gammaY, c, s];
  }

  /// @dev Decode EC point from bytes
  /// @param _point The EC point as bytes
  /// @return The point as `[point-x, point-y]`
  function decodePoint(bytes memory _point) internal pure returns (uint[2] memory) {
    if (_point.length != 33) {
      revert MalformedCompressedECPoint();
    }
    uint8 sign;
    uint256 x;
    assembly ("memory-safe") {
      sign := mload(add(_point, 1))
      x := mload(add(_point, 33))
    }
    uint256 y = deriveY(sign, x);

    return [x, y];
  }

  /// @dev Compute the parameters (EC points) required for the VRF fast verification function.
  /// @param _publicKey The public key as an array composed of `[pubKey-x, pubKey-y]`
  /// @param _proof The VRF proof as an array composed of `[gamma-x, gamma-y, c, s]`
  /// @param _message The message (in bytes) used for computing the VRF
  /// @return The fast verify required parameters as the tuple `([uPointX, uPointY], [sHX, sHY, cGammaX, cGammaY])`
  function computeFastVerifyParams(
    uint256[2] calldata _publicKey,
    uint256[4] calldata _proof,
    bytes memory _message
  ) internal pure returns (uint256[2] memory, uint256[4] memory) {
    // Requirements for Step 3: U = s*B - c*Y (where B is the generator)
    (uint256 hPointX, uint256 hPointY) = hashToTryAndIncrement(_publicKey, _message);
    (uint256 uPointX, uint256 uPointY) = ecMulSubMul(_proof[3], GX, GY, _proof[2], _publicKey[0], _publicKey[1]);
    // Requirements for Step 4: V = s*H - c*Gamma
    (uint256 sHX, uint256 sHY) = derivePoint(_proof[3], hPointX, hPointY);
    (uint256 cGammaX, uint256 cGammaY) = derivePoint(_proof[2], _proof[0], _proof[1]);

    return ([uPointX, uPointY], [sHX, sHY, cGammaX, cGammaY]);
  }

  /// @dev Function to convert a `Hash(PK|DATA)` to a point in the curve as defined in [VRF-draft-04](https://tools.ietf.org/pdf/draft-irtf-cfrg-vrf-04).
  /// Used in Step 2 of VRF verification function.
  /// @param _publicKey The public key as an array composed of `[pubKey-x, pubKey-y]`
  /// @param _message The message used for computing the VRF
  /// @return The hash point in affine cooridnates
  function hashToTryAndIncrement(
    uint256[2] calldata _publicKey,
    bytes memory _message
  ) internal pure returns (uint, uint) {
    // Step 1: public key to bytes
    // Step 2: V = cipher_suite | 0x01 | public_key_bytes | message | ctr
    bytes memory c = abi.encodePacked(
      // Cipher suite code (SECP256K1-SHA256-TAI is 0xFE)
      uint8(254),
      // 0x01
      uint8(1),
      // Public Key
      encodePoint(_publicKey[0], _publicKey[1]),
      // Message
      _message
    );

    // Step 3: find a valid EC point
    // Loop over counter ctr starting at 0x00 and do hash
    for (uint256 ctr = 0; ctr < 256; ctr++) {
      // Counter update
      // c[cLength-1] = byte(ctr);
      bytes32 sha = sha256(abi.encodePacked(c, uint8(ctr)));
      // Step 4: arbitrary string to point and check if it is on curve
      uint hPointX = uint256(sha);
      uint hPointY = deriveY(2, hPointX);
      if (EllipticCurve.isOnCurve(hPointX, hPointY, AA, BB, PP)) {
        // Step 5 (omitted): calculate H (cofactor is 1 on secp256k1)
        // If H is not "INVALID" and cofactor > 1, set H = cofactor * H
        return (hPointX, hPointY);
      }
    }
    revert NoValidPointFound();
  }

  /// @dev Function to hash a certain set of points as specified in [VRF-draft-04](https://tools.ietf.org/pdf/draft-irtf-cfrg-vrf-04).
  /// Used in Step 5 of VRF verification function.
  /// @param _hPointX The coordinate `x` of point `H`
  /// @param _hPointY The coordinate `y` of point `H`
  /// @param _gammaX The coordinate `x` of the point `Gamma`
  /// @param _gammaX The coordinate `y` of the point `Gamma`
  /// @param _uPointX The coordinate `x` of point `U`
  /// @param _uPointY The coordinate `y` of point `U`
  /// @param _vPointX The coordinate `x` of point `V`
  /// @param _vPointY The coordinate `y` of point `V`
  /// @return The first half of the digest of the points using SHA256
  function hashPoints(
    uint256 _hPointX,
    uint256 _hPointY,
    uint256 _gammaX,
    uint256 _gammaY,
    uint256 _uPointX,
    uint256 _uPointY,
    uint256 _vPointX,
    uint256 _vPointY
  ) internal pure returns (bytes16) {
    bytes memory c = abi.encodePacked(
      // Ciphersuite 0xFE
      uint8(254),
      // Prefix 0x02
      uint8(2),
      // Points to Bytes
      encodePoint(_hPointX, _hPointY),
      encodePoint(_gammaX, _gammaY),
      encodePoint(_uPointX, _uPointY),
      encodePoint(_vPointX, _vPointY)
    );
    // Hash bytes and truncate
    bytes32 sha = sha256(c);
    bytes16 half1;
    assembly ("memory-safe") {
      let freemem_pointer := mload(0x40)
      mstore(add(freemem_pointer, 0x00), sha)
      half1 := mload(add(freemem_pointer, 0x00))
    }

    return half1;
  }

  /// @dev Encode an EC point to bytes
  /// @param _x The coordinate `x` of the point
  /// @param _y The coordinate `y` of the point
  /// @return The point coordinates as bytes
  function encodePoint(uint256 _x, uint256 _y) internal pure returns (bytes memory) {
    uint8 prefix = uint8(2 + (_y % 2));

    return abi.encodePacked(prefix, _x);
  }

  /// @dev Substracts two key derivation functionsas `s1*A - s2*B`.
  /// @param _scalar1 The scalar `s1`
  /// @param _a1 The `x` coordinate of point `A`
  /// @param _a2 The `y` coordinate of point `A`
  /// @param _scalar2 The scalar `s2`
  /// @param _b1 The `x` coordinate of point `B`
  /// @param _b2 The `y` coordinate of point `B`
  /// @return The derived point in affine cooridnates
  function ecMulSubMul(
    uint256 _scalar1,
    uint256 _a1,
    uint256 _a2,
    uint256 _scalar2,
    uint256 _b1,
    uint256 _b2
  ) internal pure returns (uint256, uint256) {
    (uint256 m1, uint256 m2) = derivePoint(_scalar1, _a1, _a2);
    (uint256 n1, uint256 n2) = derivePoint(_scalar2, _b1, _b2);
    (uint256 r1, uint256 r2) = EllipticCurve.ecSub(m1, m2, n1, n2, AA, PP);

    return (r1, r2);
  }

  /// @dev Verify an Elliptic Curve multiplication of the form `(qx,qy) = scalar*(x,y)` by using the precompiled `ecrecover` function.
  /// The usage of the precompiled `ecrecover` function decreases the security from 32 to 20 bytes.
  /// Based on the original idea of Vitalik Buterin: https://ethresear.ch/t/you-can-kinda-abuse-ecrecover-to-do-ecmul-in-secp256k1-today/2384/9
  /// @param _scalar The scalar of the point multiplication
  /// @param _x The coordinate `x` of the point
  /// @param _y The coordinate `y` of the point
  /// @param _qx The coordinate `x` of the multiplication result
  /// @param _qy The coordinate `y` of the multiplication result
  /// @return true, if first 20 bytes match
  function ecMulVerify(uint256 _scalar, uint256 _x, uint256 _y, uint256 _qx, uint256 _qy) internal pure returns (bool) {
    address result = ecrecover(0, _y % 2 != 0 ? 28 : 27, bytes32(_x), bytes32(mulmod(_scalar, _x, NN)));

    return pointToAddress(_qx, _qy) == result;
  }

  /// @dev Verify an Elliptic Curve operation of the form `Q = scalar1*(gx,gy) - scalar2*(x,y)` by using the precompiled `ecrecover` function, where `(gx,gy)` is the generator of the EC.
  /// The usage of the precompiled `ecrecover` function decreases the security from 32 to 20 bytes.
  /// Based on SolCrypto library: https://github.com/HarryR/solcrypto
  /// @param _scalar1 The scalar of the multiplication of `(gx,gy)`
  /// @param _scalar2 The scalar of the multiplication of `(x,y)`
  /// @param _x The coordinate `x` of the point to be mutiply by `scalar2`
  /// @param _y The coordinate `y` of the point to be mutiply by `scalar2`
  /// @param _qx The coordinate `x` of the equation result
  /// @param _qy The coordinate `y` of the equation result
  /// @return true, if first 20 bytes match
  function ecMulSubMulVerify(
    uint256 _scalar1,
    uint256 _scalar2,
    uint256 _x,
    uint256 _y,
    uint256 _qx,
    uint256 _qy
  ) internal pure returns (bool) {
    uint256 scalar1 = (NN - _scalar1) % NN;
    scalar1 = mulmod(scalar1, _x, NN);
    uint256 scalar2 = (NN - _scalar2) % NN;

    address result = ecrecover(bytes32(scalar1), _y % 2 != 0 ? 28 : 27, bytes32(_x), bytes32(mulmod(scalar2, _x, NN)));

    return pointToAddress(_qx, _qy) == result;
  }

  /// @dev Gets the address corresponding to the EC point digest (keccak256), i.e. the first 20 bytes of the digest.
  /// This function is used for performing a fast EC multiplication verification.
  /// @param _x The coordinate `x` of the point
  /// @param _y The coordinate `y` of the point
  /// @return The address of the EC point digest (keccak256)
  function pointToAddress(uint256 _x, uint256 _y) internal pure returns (address) {
    return
      address(uint160(uint256(keccak256(abi.encodePacked(_x, _y))) & 0x00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF));
  }
}

Settings
{
  "evmVersion": "paris",
  "optimizer": {
    "enabled": true,
    "runs": 9999999,
    "details": {
      "yul": true
    }
  },
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"CommitmentMismatch","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"}],"name":"FulfillmentFailed","type":"error"},{"inputs":[{"internalType":"uint8","name":"_prefix","type":"uint8"}],"name":"InvalidCompressedECPointPrefix","type":"error"},{"inputs":[{"internalType":"address","name":"consumer","type":"address"}],"name":"InvalidConsumer","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"uint256","name":"_x","type":"uint256"},{"internalType":"uint256","name":"_pp","type":"uint256"}],"name":"InvalidNumber","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"InvalidPublicKey","type":"error"},{"inputs":[],"name":"ModulusIsZero","type":"error"},{"inputs":[],"name":"NoValidPointFound","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"OnlyOracle","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"UseJacDoubleFunctionInstead","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"consumer","type":"address"}],"name":"ConsumerRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"},{"indexed":false,"internalType":"uint256[]","name":"randomWords","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"oracle","type":"address"}],"name":"RandomWordsFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"callbackGasLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numWords","type":"uint256"},{"indexed":false,"internalType":"address","name":"consumer","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"RandomWordsRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[2]","name":"publicKey","type":"uint256[2]"},{"internalType":"uint256[4]","name":"proof","type":"uint256[4]"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"computeFastVerifyParams","outputs":[{"internalType":"uint256[2]","name":"","type":"uint256[2]"},{"internalType":"uint256[4]","name":"","type":"uint256[4]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"consumer","type":"address"}],"name":"consumers","outputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"address","name":"fulfillAddress","type":"address"},{"internalType":"uint256","name":"callbackGasLimit","type":"uint256"},{"internalType":"uint256","name":"numWords","type":"uint256"},{"internalType":"uint256[2]","name":"publicKey","type":"uint256[2]"},{"internalType":"uint256[4]","name":"proof","type":"uint256[4]"},{"internalType":"uint256[2]","name":"uPoint","type":"uint256[2]"},{"internalType":"uint256[4]","name":"vComponents","type":"uint256[4]"}],"name":"fulfillRandomWords","outputs":[{"internalType":"bool","name":"callSuccess","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"oracle","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"oracles","type":"address"}],"name":"oracles","outputs":[{"internalType":"bool","name":"isOracle","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"consumer","type":"address"}],"name":"registerConsumer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numWords","type":"uint256"},{"internalType":"uint256","name":"callbackGasLimit","type":"uint256"}],"name":"requestRandomWords","outputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]

60a080604052346100ea57306080527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c166100d9576002600160401b03196001600160401b03821601610073575b604051612caa90816100f08239608051818181610a5c0152610b500152f35b6001600160401b0319166001600160401b039081177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005581527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d290602090a13880610054565b63f92ee8a960e01b60005260046000fd5b600080fdfe608080604052600436101561001357600080fd5b60003560e01c9081630bf536681461149a5750806318e5d3241461103d5780631b739ef114610eaa57806344b22fdd14610e195780634f1ef28614610ad657806352d1902d14610a16578063715018a61461093a5780638da5cb5b146108c9578063ad3cb1cc14610817578063addd5099146107ad578063c4d66de814610535578063c95ac47a146100fc5763f2fde38b146100ae57600080fd5b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7576100f56100e86114fb565b6100f0611af4565b61165b565b005b600080fd5b346100f75760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757366044116100f7573660c4116100f75760c43567ffffffffffffffff81116100f757366023820112156100f757806004013567ffffffffffffffff81116100f75736602482840101116100f7576101d4906101af60409384805161018f828261153a565b3690376080928386516101a2828261153a565b36903760243692016115b5565b908380516101bd828261153a565b36903783516101cc828261153a565b369037611b62565b909160a43592608435926101e7856129a0565b916000838015801561050c575b8015610505575b6104b557509081889392946001907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f918184925b61038257505050506102c1946102a26102b1957ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f61029a6102948261029499816102949f9e9a6102a99a5081808b800980920999099009936024359060043590612a9a565b91612783565b939093611ea7565b0692612102565b959099612a9a565b9390956064359060443590612a9a565b92909184519685880188811067ffffffffffffffff821117610353578652875260208701528351946102f28661151e565b855260208501528284015260608301528051926000845b6002821061033d5750505082016000905b600482106103275760c084f35b602080600192855181520193019101909161031a565b6020806001928551815201930191019091610309565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b909193949596506103958184999461237c565b918094610488577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9083097ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f811161045b577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f908694089397819282810292818404149015171561045b579061044c91611ef3565b91828c9796959491929361022f565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526012600452fd5b604492507f0cedccd60000000000000000000000000000000000000000000000000000000082526004527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f602452fd5b50816101fb565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f81146101f4565b60207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7576105676114fb565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c16159167ffffffffffffffff8216801590816107a5575b600114908161079b575b159081610792575b5061076857818360017fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000073ffffffffffffffffffffffffffffffffffffffff9516177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055610713575b5061062a611f95565b610632611f95565b61063a611f95565b6106433361165b565b166000526001602052604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905561068057005b7fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b7fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005583610621565b7ff92ee8a90000000000000000000000000000000000000000000000000000000060005260046000fd5b905015846105b8565b303b1591506105b0565b8491506105a6565b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75773ffffffffffffffffffffffffffffffffffffffff6107f96114fb565b166000526001602052602060ff604060002054166040519015158152f35b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7576108c060408051610857828261153a565b600581527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602083017f352e302e300000000000000000000000000000000000000000000000000000008152845195869460208652518092816020880152878701906115ec565b01168101030190f35b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757602073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757610971611af4565b600073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300547fffffffffffffffffffffffff000000000000000000000000000000000000000081167f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000163003610aac5760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b7fe07c8dba0000000000000000000000000000000000000000000000000000000060005260046000fd5b60407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757610b086114fb565b60243567ffffffffffffffff81116100f757366023820112156100f757610b399036906024816004013591016115b5565b73ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016803014908115610dd7575b50610aac57610b88611af4565b73ffffffffffffffffffffffffffffffffffffffff8216916040517f52d1902d000000000000000000000000000000000000000000000000000000008152602081600481875afa60009181610da3575b50610c0b57837f4c9c8ce30000000000000000000000000000000000000000000000000000000060005260045260246000fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc859203610d765750813b15610d4957807fffffffffffffffffffffffff00000000000000000000000000000000000000007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2815115610d16576000808360206100f595519101845af43d15610d0e573d91610cf18361157b565b92610cff604051948561153a565b83523d6000602085013e612903565b606091612903565b505034610d1f57005b7fb398979f0000000000000000000000000000000000000000000000000000000060005260046000fd5b7f4c9c8ce30000000000000000000000000000000000000000000000000000000060005260045260246000fd5b7faa1d49a40000000000000000000000000000000000000000000000000000000060005260045260246000fd5b9091506020813d602011610dcf575b81610dbf6020938361153a565b810103126100f757519085610bd8565b3d9150610db2565b905073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141583610b7b565b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7577f20f06cf92183fb3bd87d074ec788beb83367293faf2388c274b4bad9aecae725602073ffffffffffffffffffffffffffffffffffffffff610e886114fb565b610e90611af4565b1680600052600082526001604060002055604051908152a1005b346100f75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75760043560243590336000526000602052604060002054801561100f5760209260017f2489c3d067fa16edc35faee5cd7bc71c0becee64789857b41495a3001f23c437920192336000526000855283604060002055611004604051868101903360601b825286603482015260348152610f5260548261153a565b5190206040805188810183815260208101879052918201859052336060830152466080830152919691610fb08160a084015b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810183528261153a565b519020866000526002885260406000205560405193849333918886919360809373ffffffffffffffffffffffffffffffffffffffff9297969560a08501988552602085015260408401521660608201520152565b0390a1604051908152f35b7f728aeb5f000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b346100f7576102207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75760043560243573ffffffffffffffffffffffffffffffffffffffff81168091036100f75760443573ffffffffffffffffffffffffffffffffffffffff811681036100f757606435608435913660e4116100f75736610164116100f757366101a4116100f75736610224116100f75783600052600160205260ff60406000205416156114705760408051602081018781529181018490526060810185905273ffffffffffffffffffffffffffffffffffffffff831660808201524660a08201526111398160c08101610f84565b5190208560005260026020528060406000205403611446578473ffffffffffffffffffffffffffffffffffffffff61117560c43560a43561174c565b160361141c5761119c906040519060208201526020815261119760408261153a565b611788565b156113f257604051602081019046825260e4356040820152610104356060820152606081526111cc60808261153a565b519020926111d98161160f565b936111e7604051958661153a565b8185527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06112148361160f565b0136602087013760005b828110611383575050508460005260026020526000604081205560405191602083017fbe52e34f000000000000000000000000000000000000000000000000000000008152866024850152604060448501526112ad846112816064820188611627565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810186528561153a565b5a61138881106100f7577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec78818185930160061c90030111156100f757823b156100f757600080949381945193f191821561135557906020937f948c1db220dafb0d9ee67781ef475f285c738a7bdef4f5bd8fe5a5979db479429261134260405193849384526060888501526060840190611627565b9060408301520390a16040519015158152f35b837f72d0f64f0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b6040516020810190838252826040820152604081526113a360608261153a565b5190209086518110156113c35760019160208260051b890101520161121e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f09bde3390000000000000000000000000000000000000000000000000000000060005260046000fd5b7fa2d0fee80000000000000000000000000000000000000000000000000000000060005260046000fd5b7f5054097b0000000000000000000000000000000000000000000000000000000060005260046000fd5b7f80fee1050000000000000000000000000000000000000000000000000000000060005260046000fd5b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75760209073ffffffffffffffffffffffffffffffffffffffff6114e96114fb565b16600052600082526040600020548152f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036100f757565b6080810190811067ffffffffffffffff82111761035357604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761035357604052565b67ffffffffffffffff811161035357601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b9291926115c18261157b565b916115cf604051938461153a565b8294818452818301116100f7578281602093846000960137010152565b60005b8381106115ff5750506000910152565b81810151838201526020016115ef565b67ffffffffffffffff81116103535760051b60200190565b906020808351928381520192019060005b8181106116455750505090565b8251845260209384019390920191600101611638565b73ffffffffffffffffffffffffffffffffffffffff16801561171d5773ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054827fffffffffffffffffffffffff00000000000000000000000000000000000000008216177f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b7f1e4fbdf700000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff91604051906020820192835260408201526040815261178160608261153a565b5190201690565b6117939060a4611daa565b6101443590610124359260a4359061016435936101843592817ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414103907ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641418211611ac557877ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414103907ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641418211611ac5576020926000926080927ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414191829060c43560011615611abc5760ff601c5b838581604051990609875216888601528260408601520609606082015282805260015afa15611a6a5760005173ffffffffffffffffffffffffffffffffffffffff806118ca868961174c565b921691161490811591611a9f575b508015611a80575b611a76576118f061020435611ea7565b611928907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f90066101e4356101c4356101a435612102565b936119339192611ffc565b936119436101043560e435611ffc565b9261194d91611ffc565b9261195791611ffc565b60405192839260208401957ffe000000000000000000000000000000000000000000000000000000000000008752602185017f02000000000000000000000000000000000000000000000000000000000000009052805190816022870191602001916119c2926115ec565b8401815191826022830191602001916119da926115ec565b016022018082516020819401916119f0926115ec565b01808251602081940191611a03926115ec565b01037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018252611a34908261153a565b60405180928192518092611a47926115ec565b810103905a916000916002602094fa15611a6a57600051806040515260801c1490565b6040513d6000823e3d90fd5b5050505050600090565b50611a99610204356101e4356101043560e43589611f00565b156118e0565b611ab591506101c4359085846101a43592611f00565b15386118d8565b60ff601b61187e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054163303611b3457565b7f118cdaa7000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b602291611c21611b76602435600435611ffc565b9260405194859160208301957ffe0000000000000000000000000000000000000000000000000000000000000087527f01000000000000000000000000000000000000000000000000000000000000006021850152611bde81518092602086880191016115ec565b8301611bf382518093602086850191016115ec565b0101037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810185528461153a565b600092835b6101008110611c59577f9a708eee0000000000000000000000000000000000000000000000000000000060005260046000fd5b60206000611ce9611c7e604051611cd8600186838c8282019687918d519283916115ec565b81017fff000000000000000000000000000000000000000000000000000000000000008b60f81b168382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe181018452018261153a565b6040519283928392519283916115ec565b8101039060025afa15611a6a5760005194611d7b57600094611d3a7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f806007818a8609088180858009850908612b4d565b6001611d4582611fee565b16611d6c57905b611d568282612051565b611d64575050600101611c26565b955093505050565b611d7590611ea7565b90611d4c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b91611dc0611b7660229460208101359035611ffc565b600092835b6101008110611df8577f9a708eee0000000000000000000000000000000000000000000000000000000060005260046000fd5b60206000611e1d611c7e604051611cd8600186838c8282019687918d519283916115ec565b8101039060025afa15611a6a5760005194611d7b57600094611e6e7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f806007818a8609088180858009850908612b4d565b6001611e7982611fee565b16611e9857905b611e8a8282612051565b611d64575050600101611dc5565b611ea190611ea7565b90611e80565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f03907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8211611ac557565b91908203918211611ac557565b6080907ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414160009360016020969897981615158514611f8d57601c925b60ff60405194878652168785015281604085015209606082015282805260015afa15611a6a5773ffffffffffffffffffffffffffffffffffffffff611f8581926000519461174c565b921691161490565b601b92611f3c565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615611fc457565b7fd7e6bcf80000000000000000000000000000000000000000000000000000000060005260046000fd5b9060028201809211611ac557565b906001166002019081600211611ac5577fff000000000000000000000000000000000000000000000000000000000000006040519260f81b16602083015260218201526021815261204e60418261153a565b90565b801580156120d8575b80156120d0575b80156120a6575b61209f577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f60078180938181800909089180091490565b5050600090565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f821015612068565b508115612061565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f81101561205a565b909392909180830361234857507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9084086121405750600091508190565b6000907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9081809181808080808b80099481808080600180099c8180808c88096004099e80099009928009600309088180808b800861219f9082611ef3565b8184800908996121af8b83611ef3565b900890099280096008096121c39083611ef3565b90089460019009600209925b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f916000858015801561233f575b8015612337575b61230757508095600185908615908382945b61226157505050506122345750829081808780098092099509900990565b807f4e487b7100000000000000000000000000000000000000000000000000000000602492526012600452fd5b61226e81859c949561237c565b9180946122da576122838a8092850982611ef3565b879408939a81928281029281840414901517156122ad57906122a491611ef3565b90929080612216565b6024877f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024877f4e487b710000000000000000000000000000000000000000000000000000000081526012600452fd5b90846044927f0cedccd6000000000000000000000000000000000000000000000000000000008352600452602452fd5b508415612204565b508481146121fd565b61237493947ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f93612386565b9291906121cf565b8115611d7b570490565b949291851580612541575b6125355780158061252d575b612523576040516080916123b1838361153a565b823683378615611d7b5786948580928180600180098087529781896001099c602088019d8e5282604089019d8e8c8152516001099160608a019283526040519e8f6123fb9061151e565b5190098d525190099460208b019586525190099860408901998a5251900960608701908152865188511480612518575b6124ee57849283808093816040519c856124468f978861153a565b368737518c516124569083611ef3565b900884525185516124679083611ef3565b90089860208301998a5281808b8180808089518a5190099360408a019485528185518b5190096060909a01998a5251800988516124a49083611ef3565b900881808751855190096002096124bb9083611ef3565b90089c519351905190096124cf8c83611ef3565b900890099251905190096124e39083611ef3565b900894510991929190565b7f9a0165ba0000000000000000000000000000000000000000000000000000000060005260046000fd5b50815181511461242b565b5092506001919050565b50821561239d565b94509092506001919050565b508115612391565b96949092959391958715806126e2575b6126d7578015806126cf575b6126c5576080906040519361257a838661153a565b823686378615611d7b57868092816125c298818d8009808a5282908e099d60208a019e8f528260408b0191818b800983528183518c099260608d019384526040519d8e61151e565b5190098b52519009966020890197885251900999604087019a8b5251900992606085019384528451895114806126ba575b6124ee578580949281808095816040519e8f95612610818861153a565b368737518b516126209083611ef3565b900884525185516126319083611ef3565b9008976020830198895281808a8180808089518a5190099360408a019485528185518b5190096060909a01998a52518009885161266e9083611ef3565b900881808751855190096002096126859083611ef3565b90089b519351905190096126998b83611ef3565b900890099251905190096126ad9083611ef3565b9008965192969509900990565b5080518451146125f3565b5091949392505050565b508215612565565b965090945092915050565b508315612559565b9492909391801561277d578215611d7b57828087818061273d818b81808080809d818e818082800991800909900981808b8009600309089781808080878009840960040994800990096004090882611ef3565b818480090899818061274f8d82611ef3565b92818d800990096004090890096127738280808a8009818b80090960080983611ef3565b9008940960020990565b92915050565b919291600084801580156128da575b80156128d3575b6104b5575080946001907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f918184925b61280657505050507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f929183915081808780098092099509900990565b61281381859a949561237c565b918094610488577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9083097ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f811161045b577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f908694089398819282810292818404149015171561045b57906128ca91611ef3565b909290806127c9565b5081612799565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8114612792565b90612942575080511561291857805190602001fd5b7f1425ea420000000000000000000000000000000000000000000000000000000060005260046000fd5b81511580612997575b612953575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b50803b1561294b565b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798917f483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b86001928015612a9257600094600194869392805b612a045750505050929190565b60018116612a4b575b6000612a40927ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9260011c9586956126ea565b9093919290916129f7565b93612a827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f838686612a40969b60009d8597612549565b9099509790959092509050612a0d565b509150600190565b919290926001928015612a9257600094600194869392805b612abf5750505050929190565b60018116612b06575b6000612afb927ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9260011c9586956126ea565b909391929091612ab2565b93612b3d7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f838686612afb969b60009d8597612549565b9099509790959092509050612ac8565b8015612c6e576001907f800000000000000000000000000000000000000000000000000000000000000090815b612b8357505090565b90917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8080809381877f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515870a91800909818660011c7f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515860a91800909818560021c7f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515850a91800909818460031c7f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515840a918009099160041c9081612b7a565b5060009056fea26469706673582212202de94fcd88b4bd639fc2d3e848d36e6418783858bd447fc66fba7ec1bf0ea37664736f6c634300081c0033

Deployed Bytecode

0x608080604052600436101561001357600080fd5b60003560e01c9081630bf536681461149a5750806318e5d3241461103d5780631b739ef114610eaa57806344b22fdd14610e195780634f1ef28614610ad657806352d1902d14610a16578063715018a61461093a5780638da5cb5b146108c9578063ad3cb1cc14610817578063addd5099146107ad578063c4d66de814610535578063c95ac47a146100fc5763f2fde38b146100ae57600080fd5b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7576100f56100e86114fb565b6100f0611af4565b61165b565b005b600080fd5b346100f75760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757366044116100f7573660c4116100f75760c43567ffffffffffffffff81116100f757366023820112156100f757806004013567ffffffffffffffff81116100f75736602482840101116100f7576101d4906101af60409384805161018f828261153a565b3690376080928386516101a2828261153a565b36903760243692016115b5565b908380516101bd828261153a565b36903783516101cc828261153a565b369037611b62565b909160a43592608435926101e7856129a0565b916000838015801561050c575b8015610505575b6104b557509081889392946001907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f918184925b61038257505050506102c1946102a26102b1957ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f61029a6102948261029499816102949f9e9a6102a99a5081808b800980920999099009936024359060043590612a9a565b91612783565b939093611ea7565b0692612102565b959099612a9a565b9390956064359060443590612a9a565b92909184519685880188811067ffffffffffffffff821117610353578652875260208701528351946102f28661151e565b855260208501528284015260608301528051926000845b6002821061033d5750505082016000905b600482106103275760c084f35b602080600192855181520193019101909161031a565b6020806001928551815201930191019091610309565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b909193949596506103958184999461237c565b918094610488577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9083097ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f811161045b577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f908694089397819282810292818404149015171561045b579061044c91611ef3565b91828c9796959491929361022f565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526012600452fd5b604492507f0cedccd60000000000000000000000000000000000000000000000000000000082526004527ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f602452fd5b50816101fb565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f81146101f4565b60207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7576105676114fb565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460ff8160401c16159167ffffffffffffffff8216801590816107a5575b600114908161079b575b159081610792575b5061076857818360017fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000073ffffffffffffffffffffffffffffffffffffffff9516177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0055610713575b5061062a611f95565b610632611f95565b61063a611f95565b6106433361165b565b166000526001602052604060002060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905561068057005b7fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b7fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005583610621565b7ff92ee8a90000000000000000000000000000000000000000000000000000000060005260046000fd5b905015846105b8565b303b1591506105b0565b8491506105a6565b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75773ffffffffffffffffffffffffffffffffffffffff6107f96114fb565b166000526001602052602060ff604060002054166040519015158152f35b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7576108c060408051610857828261153a565b600581527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602083017f352e302e300000000000000000000000000000000000000000000000000000008152845195869460208652518092816020880152878701906115ec565b01168101030190f35b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757602073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c1993005416604051908152f35b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757610971611af4565b600073ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300547fffffffffffffffffffffffff000000000000000000000000000000000000000081167f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346100f75760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75773ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000004e92f3e6c619a5837f0b18acd0f63f837e80697b163003610aac5760206040517f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8152f35b7fe07c8dba0000000000000000000000000000000000000000000000000000000060005260046000fd5b60407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f757610b086114fb565b60243567ffffffffffffffff81116100f757366023820112156100f757610b399036906024816004013591016115b5565b73ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000004e92f3e6c619a5837f0b18acd0f63f837e80697b16803014908115610dd7575b50610aac57610b88611af4565b73ffffffffffffffffffffffffffffffffffffffff8216916040517f52d1902d000000000000000000000000000000000000000000000000000000008152602081600481875afa60009181610da3575b50610c0b57837f4c9c8ce30000000000000000000000000000000000000000000000000000000060005260045260246000fd5b807f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc859203610d765750813b15610d4957807fffffffffffffffffffffffff00000000000000000000000000000000000000007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416177f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2815115610d16576000808360206100f595519101845af43d15610d0e573d91610cf18361157b565b92610cff604051948561153a565b83523d6000602085013e612903565b606091612903565b505034610d1f57005b7fb398979f0000000000000000000000000000000000000000000000000000000060005260046000fd5b7f4c9c8ce30000000000000000000000000000000000000000000000000000000060005260045260246000fd5b7faa1d49a40000000000000000000000000000000000000000000000000000000060005260045260246000fd5b9091506020813d602011610dcf575b81610dbf6020938361153a565b810103126100f757519085610bd8565b3d9150610db2565b905073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416141583610b7b565b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f7577f20f06cf92183fb3bd87d074ec788beb83367293faf2388c274b4bad9aecae725602073ffffffffffffffffffffffffffffffffffffffff610e886114fb565b610e90611af4565b1680600052600082526001604060002055604051908152a1005b346100f75760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75760043560243590336000526000602052604060002054801561100f5760209260017f2489c3d067fa16edc35faee5cd7bc71c0becee64789857b41495a3001f23c437920192336000526000855283604060002055611004604051868101903360601b825286603482015260348152610f5260548261153a565b5190206040805188810183815260208101879052918201859052336060830152466080830152919691610fb08160a084015b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810183528261153a565b519020866000526002885260406000205560405193849333918886919360809373ffffffffffffffffffffffffffffffffffffffff9297969560a08501988552602085015260408401521660608201520152565b0390a1604051908152f35b7f728aeb5f000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b346100f7576102207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75760043560243573ffffffffffffffffffffffffffffffffffffffff81168091036100f75760443573ffffffffffffffffffffffffffffffffffffffff811681036100f757606435608435913660e4116100f75736610164116100f757366101a4116100f75736610224116100f75783600052600160205260ff60406000205416156114705760408051602081018781529181018490526060810185905273ffffffffffffffffffffffffffffffffffffffff831660808201524660a08201526111398160c08101610f84565b5190208560005260026020528060406000205403611446578473ffffffffffffffffffffffffffffffffffffffff61117560c43560a43561174c565b160361141c5761119c906040519060208201526020815261119760408261153a565b611788565b156113f257604051602081019046825260e4356040820152610104356060820152606081526111cc60808261153a565b519020926111d98161160f565b936111e7604051958661153a565b8185527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06112148361160f565b0136602087013760005b828110611383575050508460005260026020526000604081205560405191602083017fbe52e34f000000000000000000000000000000000000000000000000000000008152866024850152604060448501526112ad846112816064820188611627565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810186528561153a565b5a61138881106100f7577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec78818185930160061c90030111156100f757823b156100f757600080949381945193f191821561135557906020937f948c1db220dafb0d9ee67781ef475f285c738a7bdef4f5bd8fe5a5979db479429261134260405193849384526060888501526060840190611627565b9060408301520390a16040519015158152f35b837f72d0f64f0000000000000000000000000000000000000000000000000000000060005260045260246000fd5b6040516020810190838252826040820152604081526113a360608261153a565b5190209086518110156113c35760019160208260051b890101520161121e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f09bde3390000000000000000000000000000000000000000000000000000000060005260046000fd5b7fa2d0fee80000000000000000000000000000000000000000000000000000000060005260046000fd5b7f5054097b0000000000000000000000000000000000000000000000000000000060005260046000fd5b7f80fee1050000000000000000000000000000000000000000000000000000000060005260046000fd5b346100f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100f75760209073ffffffffffffffffffffffffffffffffffffffff6114e96114fb565b16600052600082526040600020548152f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036100f757565b6080810190811067ffffffffffffffff82111761035357604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761035357604052565b67ffffffffffffffff811161035357601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b9291926115c18261157b565b916115cf604051938461153a565b8294818452818301116100f7578281602093846000960137010152565b60005b8381106115ff5750506000910152565b81810151838201526020016115ef565b67ffffffffffffffff81116103535760051b60200190565b906020808351928381520192019060005b8181106116455750505090565b8251845260209384019390920191600101611638565b73ffffffffffffffffffffffffffffffffffffffff16801561171d5773ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054827fffffffffffffffffffffffff00000000000000000000000000000000000000008216177f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b7f1e4fbdf700000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff91604051906020820192835260408201526040815261178160608261153a565b5190201690565b6117939060a4611daa565b6101443590610124359260a4359061016435936101843592817ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414103907ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641418211611ac557877ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414103907ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd03641418211611ac5576020926000926080927ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414191829060c43560011615611abc5760ff601c5b838581604051990609875216888601528260408601520609606082015282805260015afa15611a6a5760005173ffffffffffffffffffffffffffffffffffffffff806118ca868961174c565b921691161490811591611a9f575b508015611a80575b611a76576118f061020435611ea7565b611928907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f90066101e4356101c4356101a435612102565b936119339192611ffc565b936119436101043560e435611ffc565b9261194d91611ffc565b9261195791611ffc565b60405192839260208401957ffe000000000000000000000000000000000000000000000000000000000000008752602185017f02000000000000000000000000000000000000000000000000000000000000009052805190816022870191602001916119c2926115ec565b8401815191826022830191602001916119da926115ec565b016022018082516020819401916119f0926115ec565b01808251602081940191611a03926115ec565b01037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081018252611a34908261153a565b60405180928192518092611a47926115ec565b810103905a916000916002602094fa15611a6a57600051806040515260801c1490565b6040513d6000823e3d90fd5b5050505050600090565b50611a99610204356101e4356101043560e43589611f00565b156118e0565b611ab591506101c4359085846101a43592611f00565b15386118d8565b60ff601b61187e565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff7f9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c19930054163303611b3457565b7f118cdaa7000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b602291611c21611b76602435600435611ffc565b9260405194859160208301957ffe0000000000000000000000000000000000000000000000000000000000000087527f01000000000000000000000000000000000000000000000000000000000000006021850152611bde81518092602086880191016115ec565b8301611bf382518093602086850191016115ec565b0101037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0810185528461153a565b600092835b6101008110611c59577f9a708eee0000000000000000000000000000000000000000000000000000000060005260046000fd5b60206000611ce9611c7e604051611cd8600186838c8282019687918d519283916115ec565b81017fff000000000000000000000000000000000000000000000000000000000000008b60f81b168382015203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe181018452018261153a565b6040519283928392519283916115ec565b8101039060025afa15611a6a5760005194611d7b57600094611d3a7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f806007818a8609088180858009850908612b4d565b6001611d4582611fee565b16611d6c57905b611d568282612051565b611d64575050600101611c26565b955093505050565b611d7590611ea7565b90611d4c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b91611dc0611b7660229460208101359035611ffc565b600092835b6101008110611df8577f9a708eee0000000000000000000000000000000000000000000000000000000060005260046000fd5b60206000611e1d611c7e604051611cd8600186838c8282019687918d519283916115ec565b8101039060025afa15611a6a5760005194611d7b57600094611e6e7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f806007818a8609088180858009850908612b4d565b6001611e7982611fee565b16611e9857905b611e8a8282612051565b611d64575050600101611dc5565b611ea190611ea7565b90611e80565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f03907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8211611ac557565b91908203918211611ac557565b6080907ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414160009360016020969897981615158514611f8d57601c925b60ff60405194878652168785015281604085015209606082015282805260015afa15611a6a5773ffffffffffffffffffffffffffffffffffffffff611f8581926000519461174c565b921691161490565b601b92611f3c565b60ff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005460401c1615611fc457565b7fd7e6bcf80000000000000000000000000000000000000000000000000000000060005260046000fd5b9060028201809211611ac557565b906001166002019081600211611ac5577fff000000000000000000000000000000000000000000000000000000000000006040519260f81b16602083015260218201526021815261204e60418261153a565b90565b801580156120d8575b80156120d0575b80156120a6575b61209f577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f60078180938181800909089180091490565b5050600090565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f821015612068565b508115612061565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f81101561205a565b909392909180830361234857507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9084086121405750600091508190565b6000907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9081809181808080808b80099481808080600180099c8180808c88096004099e80099009928009600309088180808b800861219f9082611ef3565b8184800908996121af8b83611ef3565b900890099280096008096121c39083611ef3565b90089460019009600209925b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f916000858015801561233f575b8015612337575b61230757508095600185908615908382945b61226157505050506122345750829081808780098092099509900990565b807f4e487b7100000000000000000000000000000000000000000000000000000000602492526012600452fd5b61226e81859c949561237c565b9180946122da576122838a8092850982611ef3565b879408939a81928281029281840414901517156122ad57906122a491611ef3565b90929080612216565b6024877f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024877f4e487b710000000000000000000000000000000000000000000000000000000081526012600452fd5b90846044927f0cedccd6000000000000000000000000000000000000000000000000000000008352600452602452fd5b508415612204565b508481146121fd565b61237493947ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f93612386565b9291906121cf565b8115611d7b570490565b949291851580612541575b6125355780158061252d575b612523576040516080916123b1838361153a565b823683378615611d7b5786948580928180600180098087529781896001099c602088019d8e5282604089019d8e8c8152516001099160608a019283526040519e8f6123fb9061151e565b5190098d525190099460208b019586525190099860408901998a5251900960608701908152865188511480612518575b6124ee57849283808093816040519c856124468f978861153a565b368737518c516124569083611ef3565b900884525185516124679083611ef3565b90089860208301998a5281808b8180808089518a5190099360408a019485528185518b5190096060909a01998a5251800988516124a49083611ef3565b900881808751855190096002096124bb9083611ef3565b90089c519351905190096124cf8c83611ef3565b900890099251905190096124e39083611ef3565b900894510991929190565b7f9a0165ba0000000000000000000000000000000000000000000000000000000060005260046000fd5b50815181511461242b565b5092506001919050565b50821561239d565b94509092506001919050565b508115612391565b96949092959391958715806126e2575b6126d7578015806126cf575b6126c5576080906040519361257a838661153a565b823686378615611d7b57868092816125c298818d8009808a5282908e099d60208a019e8f528260408b0191818b800983528183518c099260608d019384526040519d8e61151e565b5190098b52519009966020890197885251900999604087019a8b5251900992606085019384528451895114806126ba575b6124ee578580949281808095816040519e8f95612610818861153a565b368737518b516126209083611ef3565b900884525185516126319083611ef3565b9008976020830198895281808a8180808089518a5190099360408a019485528185518b5190096060909a01998a52518009885161266e9083611ef3565b900881808751855190096002096126859083611ef3565b90089b519351905190096126998b83611ef3565b900890099251905190096126ad9083611ef3565b9008965192969509900990565b5080518451146125f3565b5091949392505050565b508215612565565b965090945092915050565b508315612559565b9492909391801561277d578215611d7b57828087818061273d818b81808080809d818e818082800991800909900981808b8009600309089781808080878009840960040994800990096004090882611ef3565b818480090899818061274f8d82611ef3565b92818d800990096004090890096127738280808a8009818b80090960080983611ef3565b9008940960020990565b92915050565b919291600084801580156128da575b80156128d3575b6104b5575080946001907ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f918184925b61280657505050507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f929183915081808780098092099509900990565b61281381859a949561237c565b918094610488577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9083097ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f811161045b577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f908694089398819282810292818404149015171561045b57906128ca91611ef3565b909290806127c9565b5081612799565b507ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8114612792565b90612942575080511561291857805190602001fd5b7f1425ea420000000000000000000000000000000000000000000000000000000060005260046000fd5b81511580612997575b612953575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b50803b1561294b565b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798917f483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b86001928015612a9257600094600194869392805b612a045750505050929190565b60018116612a4b575b6000612a40927ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9260011c9586956126ea565b9093919290916129f7565b93612a827ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f838686612a40969b60009d8597612549565b9099509790959092509050612a0d565b509150600190565b919290926001928015612a9257600094600194869392805b612abf5750505050929190565b60018116612b06575b6000612afb927ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f9260011c9586956126ea565b909391929091612ab2565b93612b3d7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f838686612afb969b60009d8597612549565b9099509790959092509050612ac8565b8015612c6e576001907f800000000000000000000000000000000000000000000000000000000000000090815b612b8357505090565b90917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f8080809381877f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515870a91800909818660011c7f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515860a91800909818560021c7f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515850a91800909818460031c7f3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c161515840a918009099160041c9081612b7a565b5060009056fea26469706673582212202de94fcd88b4bd639fc2d3e848d36e6418783858bd447fc66fba7ec1bf0ea37664736f6c634300081c0033

Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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