Contract 0xB399D0Eac6E06B51944d07b2600f6b2534efCf4c

Contract Overview

Balance:
0 MATIC
Txn Hash
Method
Block
From
To
Value [Txn Fee]
0x33c4f54a49e8255051081d2fdbd820d12ba422d19691675ce2970e37dd92eab2Set Manager293915902022-11-29 2:44:38180 days 19 hrs ago0x3a791e828fdd420fbe16416efdf509e4b9088dd4 IN  0xb399d0eac6e06b51944d07b2600f6b2534efcf4c0 MATIC0.00153286287 32.01
0x92e9a837642153a3869bc6ad275a71bb52b84c71d00d75e3fc24b5d0597db1b40x60a06040293915372022-11-29 2:40:12180 days 19 hrs ago0x3a791e828fdd420fbe16416efdf509e4b9088dd4 IN  Create: RNGChainlinkV20 MATIC0.05845848 60
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RNGChainlinkV2

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 2000 runs

Other Settings:
default evmVersion
File 1 of 7 : RNGChainlinkV2.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.6;

import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import "@pooltogether/owner-manager-contracts/contracts/Manageable.sol";

import "./RNGChainlinkV2Interface.sol";

contract RNGChainlinkV2 is RNGChainlinkV2Interface, VRFConsumerBaseV2, Manageable {
  /* ============ Global Variables ============ */

  /// @dev Reference to the VRFCoordinatorV2 deployed contract
  VRFCoordinatorV2Interface internal vrfCoordinator;

  /// @dev A counter for the number of requests made used for request ids
  uint32 internal requestCounter;

  /// @dev Chainlink VRF subscription id
  uint64 internal subscriptionId;

  /// @dev Hash of the public key used to verify the VRF proof
  bytes32 internal keyHash;

  /// @dev A list of random numbers from past requests mapped by request id
  mapping(uint32 => uint256) internal randomNumbers;

  /// @dev A list of blocks to be locked at based on past requests mapped by request id
  mapping(uint32 => uint32) internal requestLockBlock;

  /// @dev A mapping from Chainlink request ids to internal request ids
  mapping(uint256 => uint32) internal chainlinkRequestIds;

  /* ============ Events ============ */

  /**
   * @notice Emitted when the Chainlink VRF keyHash is set
   * @param keyHash Chainlink VRF keyHash
   */
  event KeyHashSet(bytes32 keyHash);

  /**
   * @notice Emitted when the Chainlink VRF subscription id is set
   * @param subscriptionId Chainlink VRF subscription id
   */
  event SubscriptionIdSet(uint64 subscriptionId);

  /**
   * @notice Emitted when the Chainlink VRF Coordinator address is set
   * @param vrfCoordinator Address of the VRF Coordinator
   */
  event VrfCoordinatorSet(VRFCoordinatorV2Interface indexed vrfCoordinator);

  /* ============ Constructor ============ */

  /**
   * @notice Constructor of the contract
   * @param _owner Owner of the contract
   * @param _vrfCoordinator Address of the VRF Coordinator
   * @param _subscriptionId Chainlink VRF subscription id
   * @param _keyHash Hash of the public key used to verify the VRF proof
   */
  constructor(
    address _owner,
    VRFCoordinatorV2Interface _vrfCoordinator,
    uint64 _subscriptionId,
    bytes32 _keyHash
  ) Ownable(_owner) VRFConsumerBaseV2(address(_vrfCoordinator)) {
    _setVRFCoordinator(_vrfCoordinator);
    _setSubscriptionId(_subscriptionId);
    _setKeyhash(_keyHash);
  }

  /* ============ External Functions ============ */

  /// @inheritdoc RNGInterface
  function requestRandomNumber()
    external
    override
    onlyManager
    returns (uint32 requestId, uint32 lockBlock)
  {
    uint256 _vrfRequestId = vrfCoordinator.requestRandomWords(
      keyHash,
      subscriptionId,
      3,
      1000000,
      1
    );

    requestCounter++;
    uint32 _requestCounter = requestCounter;

    requestId = _requestCounter;
    chainlinkRequestIds[_vrfRequestId] = _requestCounter;

    lockBlock = uint32(block.number);
    requestLockBlock[_requestCounter] = lockBlock;

    emit RandomNumberRequested(_requestCounter, msg.sender);
  }

  /// @inheritdoc RNGInterface
  function isRequestComplete(uint32 _internalRequestId)
    external
    view
    override
    returns (bool isCompleted)
  {
    return randomNumbers[_internalRequestId] != 0;
  }

  /// @inheritdoc RNGInterface
  function randomNumber(uint32 _internalRequestId)
    external
    view
    override
    returns (uint256 randomNum)
  {
    return randomNumbers[_internalRequestId];
  }

  /// @inheritdoc RNGInterface
  function getLastRequestId() external view override returns (uint32 requestId) {
    return requestCounter;
  }

  /// @inheritdoc RNGInterface
  function getRequestFee() external pure override returns (address feeToken, uint256 requestFee) {
    return (address(0), 0);
  }

  /// @inheritdoc RNGChainlinkV2Interface
  function getKeyHash() external view override returns (bytes32) {
    return keyHash;
  }

  /// @inheritdoc RNGChainlinkV2Interface
  function getSubscriptionId() external view override returns (uint64) {
    return subscriptionId;
  }

  /// @inheritdoc RNGChainlinkV2Interface
  function getVrfCoordinator() external view override returns (VRFCoordinatorV2Interface) {
    return vrfCoordinator;
  }

  /// @inheritdoc RNGChainlinkV2Interface
  function setSubscriptionId(uint64 _subscriptionId) external override onlyOwner {
    _setSubscriptionId(_subscriptionId);
  }

  /// @inheritdoc RNGChainlinkV2Interface
  function setKeyhash(bytes32 _keyHash) external override onlyOwner {
    _setKeyhash(_keyHash);
  }

  /* ============ Internal Functions ============ */

  /**
   * @notice Callback function called by VRF Coordinator
   * @dev The VRF Coordinator will only call it once it has verified the proof associated with the randomness.
   * @param _vrfRequestId Chainlink VRF request id
   * @param _randomWords Chainlink VRF array of random words
   */
  function fulfillRandomWords(uint256 _vrfRequestId, uint256[] memory _randomWords)
    internal
    override
  {
    uint32 _internalRequestId = chainlinkRequestIds[_vrfRequestId];
    require(_internalRequestId > 0, "RNGChainLink/requestId-incorrect");

    uint256 _randomNumber = _randomWords[0];
    randomNumbers[_internalRequestId] = _randomNumber;

    emit RandomNumberCompleted(_internalRequestId, _randomNumber);
  }

  /**
   * @notice Set Chainlink VRF coordinator contract address.
   * @param _vrfCoordinator Chainlink VRF coordinator contract address
   */
  function _setVRFCoordinator(VRFCoordinatorV2Interface _vrfCoordinator) internal {
    require(address(_vrfCoordinator) != address(0), "RNGChainLink/vrf-not-zero-addr");
    vrfCoordinator = _vrfCoordinator;
    emit VrfCoordinatorSet(_vrfCoordinator);
  }

  /**
   * @notice Set Chainlink VRF subscription id associated with this contract.
   * @param _subscriptionId Chainlink VRF subscription id
   */
  function _setSubscriptionId(uint64 _subscriptionId) internal {
    require(_subscriptionId > 0, "RNGChainLink/subId-gt-zero");
    subscriptionId = _subscriptionId;
    emit SubscriptionIdSet(_subscriptionId);
  }

  /**
   * @notice Set Chainlink VRF keyHash.
   * @param _keyHash Chainlink VRF keyHash
   */
  function _setKeyhash(bytes32 _keyHash) internal {
    require(_keyHash != bytes32(0), "RNGChainLink/keyHash-not-empty");
    keyHash = _keyHash;
    emit KeyHashSet(_keyHash);
  }
}

File 2 of 7 : VRFCoordinatorV2Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface VRFCoordinatorV2Interface {
  /**
   * @notice Get configuration relevant for making requests
   * @return minimumRequestConfirmations global min for request confirmations
   * @return maxGasLimit global max for request gas limit
   * @return s_provingKeyHashes list of registered key hashes
   */
  function getRequestConfig()
    external
    view
    returns (
      uint16,
      uint32,
      bytes32[] memory
    );

  /**
   * @notice Request a set of random words.
   * @param keyHash - Corresponds to a particular oracle job which uses
   * that key for generating the VRF proof. Different keyHash's have different gas price
   * ceilings, so you can select a specific one to bound your maximum per request cost.
   * @param subId  - The ID of the VRF subscription. Must be funded
   * with the minimum subscription balance required for the selected keyHash.
   * @param minimumRequestConfirmations - How many blocks you'd like the
   * oracle to wait before responding to the request. See SECURITY CONSIDERATIONS
   * for why you may want to request more. The acceptable range is
   * [minimumRequestBlockConfirmations, 200].
   * @param callbackGasLimit - How much gas you'd like to receive in your
   * fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords
   * may be slightly less than this amount because of gas used calling the function
   * (argument decoding etc.), so you may need to request slightly more than you expect
   * to have inside fulfillRandomWords. The acceptable range is
   * [0, maxGasLimit]
   * @param numWords - The number of uint256 random values you'd like to receive
   * in your fulfillRandomWords callback. Note these numbers are expanded in a
   * secure way by the VRFCoordinator from a single random value supplied by the oracle.
   * @return requestId - A unique identifier of the request. Can be used to match
   * a request to a response in fulfillRandomWords.
   */
  function requestRandomWords(
    bytes32 keyHash,
    uint64 subId,
    uint16 minimumRequestConfirmations,
    uint32 callbackGasLimit,
    uint32 numWords
  ) external returns (uint256 requestId);

  /**
   * @notice Create a VRF subscription.
   * @return subId - A unique subscription id.
   * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer.
   * @dev Note to fund the subscription, use transferAndCall. For example
   * @dev  LINKTOKEN.transferAndCall(
   * @dev    address(COORDINATOR),
   * @dev    amount,
   * @dev    abi.encode(subId));
   */
  function createSubscription() external returns (uint64 subId);

  /**
   * @notice Get a VRF subscription.
   * @param subId - ID of the subscription
   * @return balance - LINK balance of the subscription in juels.
   * @return reqCount - number of requests for this subscription, determines fee tier.
   * @return owner - owner of the subscription.
   * @return consumers - list of consumer address which are able to use this subscription.
   */
  function getSubscription(uint64 subId)
    external
    view
    returns (
      uint96 balance,
      uint64 reqCount,
      address owner,
      address[] memory consumers
    );

  /**
   * @notice Request subscription owner transfer.
   * @param subId - ID of the subscription
   * @param newOwner - proposed new owner of the subscription
   */
  function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external;

  /**
   * @notice Request subscription owner transfer.
   * @param subId - ID of the subscription
   * @dev will revert if original owner of subId has
   * not requested that msg.sender become the new owner.
   */
  function acceptSubscriptionOwnerTransfer(uint64 subId) external;

  /**
   * @notice Add a consumer to a VRF subscription.
   * @param subId - ID of the subscription
   * @param consumer - New consumer which can use the subscription
   */
  function addConsumer(uint64 subId, address consumer) external;

  /**
   * @notice Remove a consumer from a VRF subscription.
   * @param subId - ID of the subscription
   * @param consumer - Consumer to remove from the subscription
   */
  function removeConsumer(uint64 subId, address consumer) external;

  /**
   * @notice Cancel a subscription
   * @param subId - ID of the subscription
   * @param to - Where to send the remaining LINK to
   */
  function cancelSubscription(uint64 subId, address to) external;

  /*
   * @notice Check to see if there exists a request commitment consumers
   * for all consumers and keyhashes for a given sub.
   * @param subId - ID of the subscription
   * @return true if there exists at least one unfulfilled request for the subscription, false
   * otherwise.
   */
  function pendingRequestExists(uint64 subId) external view returns (bool);
}

File 3 of 7 : VRFConsumerBaseV2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/** ****************************************************************************
 * @notice Interface for contracts using VRF randomness
 * *****************************************************************************
 * @dev PURPOSE
 *
 * @dev Reggie the Random Oracle (not his real job) wants to provide randomness
 * @dev to Vera the verifier in such a way that Vera can be sure he's not
 * @dev making his output up to suit himself. Reggie provides Vera a public key
 * @dev to which he knows the secret key. Each time Vera provides a seed to
 * @dev Reggie, he gives back a value which is computed completely
 * @dev deterministically from the seed and the secret key.
 *
 * @dev Reggie provides a proof by which Vera can verify that the output was
 * @dev correctly computed once Reggie tells it to her, but without that proof,
 * @dev the output is indistinguishable to her from a uniform random sample
 * @dev from the output space.
 *
 * @dev The purpose of this contract is to make it easy for unrelated contracts
 * @dev to talk to Vera the verifier about the work Reggie is doing, to provide
 * @dev simple access to a verifiable source of randomness. It ensures 2 things:
 * @dev 1. The fulfillment came from the VRFCoordinator
 * @dev 2. The consumer contract implements fulfillRandomWords.
 * *****************************************************************************
 * @dev USAGE
 *
 * @dev Calling contracts must inherit from VRFConsumerBase, and can
 * @dev initialize VRFConsumerBase's attributes in their constructor as
 * @dev shown:
 *
 * @dev   contract VRFConsumer {
 * @dev     constructor(<other arguments>, address _vrfCoordinator, address _link)
 * @dev       VRFConsumerBase(_vrfCoordinator) public {
 * @dev         <initialization with other arguments goes here>
 * @dev       }
 * @dev   }
 *
 * @dev The oracle will have given you an ID for the VRF keypair they have
 * @dev committed to (let's call it keyHash). Create subscription, fund it
 * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface
 * @dev subscription management functions).
 * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations,
 * @dev callbackGasLimit, numWords),
 * @dev see (VRFCoordinatorInterface for a description of the arguments).
 *
 * @dev Once the VRFCoordinator has received and validated the oracle's response
 * @dev to your request, it will call your contract's fulfillRandomWords method.
 *
 * @dev The randomness argument to fulfillRandomWords is a set of random words
 * @dev generated from your requestId and the blockHash of the request.
 *
 * @dev If your contract could have concurrent requests open, you can use the
 * @dev requestId returned from requestRandomWords to track which response is associated
 * @dev with which randomness request.
 * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind,
 * @dev if your contract could have multiple requests in flight simultaneously.
 *
 * @dev Colliding `requestId`s are cryptographically impossible as long as seeds
 * @dev differ.
 *
 * *****************************************************************************
 * @dev SECURITY CONSIDERATIONS
 *
 * @dev A method with the ability to call your fulfillRandomness method directly
 * @dev could spoof a VRF response with any random value, so it's critical that
 * @dev it cannot be directly called by anything other than this base contract
 * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method).
 *
 * @dev For your users to trust that your contract's random behavior is free
 * @dev from malicious interference, it's best if you can write it so that all
 * @dev behaviors implied by a VRF response are executed *during* your
 * @dev fulfillRandomness method. If your contract must store the response (or
 * @dev anything derived from it) and use it later, you must ensure that any
 * @dev user-significant behavior which depends on that stored value cannot be
 * @dev manipulated by a subsequent VRF request.
 *
 * @dev Similarly, both miners and the VRF oracle itself have some influence
 * @dev over the order in which VRF responses appear on the blockchain, so if
 * @dev your contract could have multiple VRF requests in flight simultaneously,
 * @dev you must ensure that the order in which the VRF responses arrive cannot
 * @dev be used to manipulate your contract's user-significant behavior.
 *
 * @dev Since the block hash of the block which contains the requestRandomness
 * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful
 * @dev miner could, in principle, fork the blockchain to evict the block
 * @dev containing the request, forcing the request to be included in a
 * @dev different block with a different hash, and therefore a different input
 * @dev to the VRF. However, such an attack would incur a substantial economic
 * @dev cost. This cost scales with the number of blocks the VRF oracle waits
 * @dev until it calls responds to a request. It is for this reason that
 * @dev that you can signal to an oracle you'd like them to wait longer before
 * @dev responding to the request (however this is not enforced in the contract
 * @dev and so remains effective only in the case of unmodified oracle software).
 */
abstract contract VRFConsumerBaseV2 {
  error OnlyCoordinatorCanFulfill(address have, address want);
  address private immutable vrfCoordinator;

  /**
   * @param _vrfCoordinator address of VRFCoordinator contract
   */
  constructor(address _vrfCoordinator) {
    vrfCoordinator = _vrfCoordinator;
  }

  /**
   * @notice fulfillRandomness handles the VRF response. Your contract must
   * @notice implement it. See "SECURITY CONSIDERATIONS" above for important
   * @notice principles to keep in mind when implementing your fulfillRandomness
   * @notice method.
   *
   * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this
   * @dev signature, and will call it once it has verified the proof
   * @dev associated with the randomness. (It is triggered via a call to
   * @dev rawFulfillRandomness, below.)
   *
   * @param requestId The Id initially returned by requestRandomness
   * @param randomWords the VRF output expanded to the requested number of words
   */
  function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual;

  // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
  // proof. rawFulfillRandomness then calls fulfillRandomness, after validating
  // the origin of the call
  function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external {
    if (msg.sender != vrfCoordinator) {
      revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator);
    }
    fulfillRandomWords(requestId, randomWords);
  }
}

File 4 of 7 : Manageable.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.0;

import "./Ownable.sol";

/**
 * @title Abstract manageable contract that can be inherited by other contracts
 * @notice Contract module based on Ownable which provides a basic access control mechanism, where
 * there is an owner and a manager that can be granted exclusive access to specific functions.
 *
 * By default, the owner is the deployer of the contract.
 *
 * The owner account is set through a two steps process.
 *      1. The current `owner` calls {transferOwnership} to set a `pendingOwner`
 *      2. The `pendingOwner` calls {acceptOwnership} to accept the ownership transfer
 *
 * The manager account needs to be set using {setManager}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyManager`, which can be applied to your functions to restrict their use to
 * the manager.
 */
abstract contract Manageable is Ownable {
    address private _manager;

    /**
     * @dev Emitted when `_manager` has been changed.
     * @param previousManager previous `_manager` address.
     * @param newManager new `_manager` address.
     */
    event ManagerTransferred(address indexed previousManager, address indexed newManager);

    /* ============ External Functions ============ */

    /**
     * @notice Gets current `_manager`.
     * @return Current `_manager` address.
     */
    function manager() public view virtual returns (address) {
        return _manager;
    }

    /**
     * @notice Set or change of manager.
     * @dev Throws if called by any account other than the owner.
     * @param _newManager New _manager address.
     * @return Boolean to indicate if the operation was successful or not.
     */
    function setManager(address _newManager) external onlyOwner returns (bool) {
        return _setManager(_newManager);
    }

    /* ============ Internal Functions ============ */

    /**
     * @notice Set or change of manager.
     * @param _newManager New _manager address.
     * @return Boolean to indicate if the operation was successful or not.
     */
    function _setManager(address _newManager) private returns (bool) {
        address _previousManager = _manager;

        require(_newManager != _previousManager, "Manageable/existing-manager-address");

        _manager = _newManager;

        emit ManagerTransferred(_previousManager, _newManager);
        return true;
    }

    /* ============ Modifier Functions ============ */

    /**
     * @dev Throws if called by any account other than the manager.
     */
    modifier onlyManager() {
        require(manager() == msg.sender, "Manageable/caller-not-manager");
        _;
    }

    /**
     * @dev Throws if called by any account other than the manager or the owner.
     */
    modifier onlyManagerOrOwner() {
        require(manager() == msg.sender || owner() == msg.sender, "Manageable/caller-not-manager-or-owner");
        _;
    }
}

File 5 of 7 : RNGChainlinkV2Interface.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.6;

import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";

import "./RNGInterface.sol";

/**
 * @title RNG Chainlink V2 Interface
 * @notice Provides an interface for requesting random numbers from Chainlink VRF V2.
 */
interface RNGChainlinkV2Interface is RNGInterface {
  /**
   * @notice Get Chainlink VRF keyHash associated with this contract.
   * @return bytes32 Chainlink VRF keyHash
   */
  function getKeyHash() external view returns (bytes32);

  /**
   * @notice Get Chainlink VRF subscription id associated with this contract.
   * @return uint64 Chainlink VRF subscription id
   */
  function getSubscriptionId() external view returns (uint64);

  /**
   * @notice Get Chainlink VRF coordinator contract address associated with this contract.
   * @return address Chainlink VRF coordinator address
   */
  function getVrfCoordinator() external view returns (VRFCoordinatorV2Interface);

  /**
   * @notice Set Chainlink VRF keyHash.
   * @dev This function is only callable by the owner.
   * @param keyHash Chainlink VRF keyHash
   */
  function setKeyhash(bytes32 keyHash) external;

  /**
   * @notice Set Chainlink VRF subscription id associated with this contract.
   * @dev This function is only callable by the owner.
   * @param subscriptionId Chainlink VRF subscription id
   */
  function setSubscriptionId(uint64 subscriptionId) external;
}

File 6 of 7 : Ownable.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.0;

/**
 * @title Abstract ownable contract that can be inherited by other contracts
 * @notice Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner is the deployer of the contract.
 *
 * The owner account is set through a two steps process.
 *      1. The current `owner` calls {transferOwnership} to set a `pendingOwner`
 *      2. The `pendingOwner` calls {acceptOwnership} to accept the ownership transfer
 *
 * The manager account needs to be set using {setManager}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable {
    address private _owner;
    address private _pendingOwner;

    /**
     * @dev Emitted when `_pendingOwner` has been changed.
     * @param pendingOwner new `_pendingOwner` address.
     */
    event OwnershipOffered(address indexed pendingOwner);

    /**
     * @dev Emitted when `_owner` has been changed.
     * @param previousOwner previous `_owner` address.
     * @param newOwner new `_owner` address.
     */
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /* ============ Deploy ============ */

    /**
     * @notice Initializes the contract setting `_initialOwner` as the initial owner.
     * @param _initialOwner Initial owner of the contract.
     */
    constructor(address _initialOwner) {
        _setOwner(_initialOwner);
    }

    /* ============ External Functions ============ */

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

    /**
     * @notice Gets current `_pendingOwner`.
     * @return Current `_pendingOwner` address.
     */
    function pendingOwner() external view virtual returns (address) {
        return _pendingOwner;
    }

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

    /**
    * @notice Allows current owner to set the `_pendingOwner` address.
    * @param _newOwner Address to transfer ownership to.
    */
    function transferOwnership(address _newOwner) external onlyOwner {
        require(_newOwner != address(0), "Ownable/pendingOwner-not-zero-address");

        _pendingOwner = _newOwner;

        emit OwnershipOffered(_newOwner);
    }

    /**
    * @notice Allows the `_pendingOwner` address to finalize the transfer.
    * @dev This function is only callable by the `_pendingOwner`.
    */
    function claimOwnership() external onlyPendingOwner {
        _setOwner(_pendingOwner);
        _pendingOwner = address(0);
    }

    /* ============ Internal Functions ============ */

    /**
     * @notice Internal function to set the `_owner` of the contract.
     * @param _newOwner New `_owner` address.
     */
    function _setOwner(address _newOwner) private {
        address _oldOwner = _owner;
        _owner = _newOwner;
        emit OwnershipTransferred(_oldOwner, _newOwner);
    }

    /* ============ Modifier Functions ============ */

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == msg.sender, "Ownable/caller-not-owner");
        _;
    }

    /**
    * @dev Throws if called by any account other than the `pendingOwner`.
    */
    modifier onlyPendingOwner() {
        require(msg.sender == _pendingOwner, "Ownable/caller-not-pendingOwner");
        _;
    }
}

File 7 of 7 : RNGInterface.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.6;

/**
 * @title Random Number Generator Interface
 * @notice Provides an interface for requesting random numbers from 3rd-party RNG services (Chainlink VRF, Starkware VDF, etc..)
 */
interface RNGInterface {
  /**
   * @notice Emitted when a new request for a random number has been submitted
   * @param requestId The indexed ID of the request used to get the results of the RNG service
   * @param sender The indexed address of the sender of the request
   */
  event RandomNumberRequested(uint32 indexed requestId, address indexed sender);

  /**
   * @notice Emitted when an existing request for a random number has been completed
   * @param requestId The indexed ID of the request used to get the results of the RNG service
   * @param randomNumber The random number produced by the 3rd-party service
   */
  event RandomNumberCompleted(uint32 indexed requestId, uint256 randomNumber);

  /**
   * @notice Gets the last request id used by the RNG service
   * @return requestId The last request id used in the last request
   */
  function getLastRequestId() external view returns (uint32 requestId);

  /**
   * @notice Gets the Fee for making a Request against an RNG service
   * @return feeToken The address of the token that is used to pay fees
   * @return requestFee The fee required to be paid to make a request
   */
  function getRequestFee() external view returns (address feeToken, uint256 requestFee);

  /**
   * @notice Sends a request for a random number to the 3rd-party service
   * @dev Some services will complete the request immediately, others may have a time-delay
   * @dev Some services require payment in the form of a token, such as $LINK for Chainlink VRF
   * @return requestId The ID of the request used to get the results of the RNG service
   * @return lockBlock The block number at which the RNG service will start generating time-delayed randomness.
   * The calling contract should "lock" all activity until the result is available via the `requestId`
   */
  function requestRandomNumber() external returns (uint32 requestId, uint32 lockBlock);

  /**
   * @notice Checks if the request for randomness from the 3rd-party service has completed
   * @dev For time-delayed requests, this function is used to check/confirm completion
   * @param requestId The ID of the request used to get the results of the RNG service
   * @return isCompleted True if the request has completed and a random number is available, false otherwise
   */
  function isRequestComplete(uint32 requestId) external view returns (bool isCompleted);

  /**
   * @notice Gets the random number produced by the 3rd-party service
   * @param requestId The ID of the request used to get the results of the RNG service
   * @return randomNum The random number
   */
  function randomNumber(uint32 requestId) external returns (uint256 randomNum);
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"contract VRFCoordinatorV2Interface","name":"_vrfCoordinator","type":"address"},{"internalType":"uint64","name":"_subscriptionId","type":"uint64"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"keyHash","type":"bytes32"}],"name":"KeyHashSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousManager","type":"address"},{"indexed":true,"internalType":"address","name":"newManager","type":"address"}],"name":"ManagerTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipOffered","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":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"RandomNumberCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RandomNumberRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"subscriptionId","type":"uint64"}],"name":"SubscriptionIdSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract VRFCoordinatorV2Interface","name":"vrfCoordinator","type":"address"}],"name":"VrfCoordinatorSet","type":"event"},{"inputs":[],"name":"claimOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getKeyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastRequestId","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRequestFee","outputs":[{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"requestFee","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getSubscriptionId","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVrfCoordinator","outputs":[{"internalType":"contract VRFCoordinatorV2Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"isRequestComplete","outputs":[{"internalType":"bool","name":"isCompleted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_internalRequestId","type":"uint32"}],"name":"randomNumber","outputs":[{"internalType":"uint256","name":"randomNum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRandomNumber","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"},{"internalType":"uint32","name":"lockBlock","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"name":"setKeyhash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newManager","type":"address"}],"name":"setManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_subscriptionId","type":"uint64"}],"name":"setSubscriptionId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b506040516200127e3803806200127e8339810160408190526200003491620002b1565b6001600160601b0319606084901b166080528362000052816200007e565b506200005e83620000ce565b620000698262000174565b62000074816200022c565b505050506200032f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0381166200012a5760405162461bcd60e51b815260206004820152601e60248201527f524e47436861696e4c696e6b2f7672662d6e6f742d7a65726f2d61646472000060448201526064015b60405180910390fd5b600380546001600160a01b0319166001600160a01b0383169081179091556040517f4cc41e06d3d0588be9be0e1469ba1934c4bd1cb8f4f70adf2aa31f4b92134b2790600090a250565b6000816001600160401b031611620001cf5760405162461bcd60e51b815260206004820152601a60248201527f524e47436861696e4c696e6b2f73756249642d67742d7a65726f000000000000604482015260640162000121565b600380546001600160c01b0316600160c01b6001600160401b038416908102919091179091556040519081527f68de96e24c66c14c012b5bd342251abc26a6003eaa438002bfe530f28ca63fed906020015b60405180910390a150565b806200027b5760405162461bcd60e51b815260206004820152601e60248201527f524e47436861696e4c696e6b2f6b6579486173682d6e6f742d656d7074790000604482015260640162000121565b60048190556040518181527fd013f86c8346660ebf421351882cd1b3c2f91883092df1800264c656b0db0cc69060200162000221565b60008060008060808587031215620002c857600080fd5b8451620002d58162000316565b6020860151909450620002e88162000316565b60408601519093506001600160401b03811681146200030657600080fd5b6060959095015193969295505050565b6001600160a01b03811681146200032c57600080fd5b50565b60805160601c610f296200035560003960008181610320015261037b0152610f296000f3fe608060405234801561001057600080fd5b50600436106101365760003560e01c8063715018a6116100b2578063d0ebdbe711610081578063e30c397811610066578063e30c3978146102de578063ea7b4f77146102ef578063f2fde38b1461030257600080fd5b8063d0ebdbe71461029e578063de3d9fb7146102b157600080fd5b8063715018a61461023a5780638678a7b2146102425780638da5cb5b146102675780639d2a5f981461027857600080fd5b8063331bf12511610109578063481c6a75116100ee578063481c6a751461020e5780634e71e0c81461021f5780636309b7731461022757600080fd5b8063331bf125146101c45780633a19b9bc146101d657600080fd5b80630cb4a29d1461013b5780630d37b5371461016557806319c2b4c3146101795780631fe543e3146101af575b600080fd5b6003546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b60408051600080825260208201520161015c565b60035474010000000000000000000000000000000000000000900463ffffffff1660405163ffffffff909116815260200161015c565b6101c26101bd366004610d56565b610315565b005b6004545b60405190815260200161015c565b6101fe6101e4366004610e45565b63ffffffff16600090815260056020526040902054151590565b604051901515815260200161015c565b6002546001600160a01b0316610148565b6101c26103bb565b6101c2610235366004610d24565b610449565b6101c26104be565b61024a610533565b6040805163ffffffff93841681529290911660208301520161015c565b6000546001600160a01b0316610148565b6101c8610286366004610e45565b63ffffffff1660009081526005602052604090205490565b6101fe6102ac366004610cf4565b610763565b600354600160c01b900467ffffffffffffffff1660405167ffffffffffffffff909116815260200161015c565b6001546001600160a01b0316610148565b6101c26102fd366004610e6b565b6107dd565b6101c2610310366004610cf4565b61084f565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146103ad576040517f1cf993f40000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001660248201526044015b60405180910390fd5b6103b7828261098b565b5050565b6001546001600160a01b031633146104155760405162461bcd60e51b815260206004820152601f60248201527f4f776e61626c652f63616c6c65722d6e6f742d70656e64696e674f776e65720060448201526064016103a4565b60015461042a906001600160a01b0316610a60565b6001805473ffffffffffffffffffffffffffffffffffffffff19169055565b3361045c6000546001600160a01b031690565b6001600160a01b0316146104b25760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e6572000000000000000060448201526064016103a4565b6104bb81610abd565b50565b336104d16000546001600160a01b031690565b6001600160a01b0316146105275760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e6572000000000000000060448201526064016103a4565b6105316000610a60565b565b600080336105496002546001600160a01b031690565b6001600160a01b03161461059f5760405162461bcd60e51b815260206004820152601d60248201527f4d616e61676561626c652f63616c6c65722d6e6f742d6d616e6167657200000060448201526064016103a4565b60038054600480546040517f5d3b1d3000000000000000000000000000000000000000000000000000000000815291820152600160c01b820467ffffffffffffffff1660248201526044810192909252620f42406064830152600160848301526000916001600160a01b0390911690635d3b1d309060a401602060405180830381600087803b15801561063157600080fd5b505af1158015610645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106699190610d3d565b600380549192507401000000000000000000000000000000000000000090910463ffffffff1690601461069b83610e95565b82546101009290920a63ffffffff818102199093169183160217909155600354600084815260076020908152604080832080547401000000000000000000000000000000000000000090950486167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000095861681179091558084526006909252808320805490941643958616179093559151919650919450859250339183917fcf635b20f2defc1e71326dc4f0b616fa676e29a5bae87da19fcaddc550b33f039190a350509091565b6000336107786000546001600160a01b031690565b6001600160a01b0316146107ce5760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e6572000000000000000060448201526064016103a4565b6107d782610b46565b92915050565b336107f06000546001600160a01b031690565b6001600160a01b0316146108465760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e6572000000000000000060448201526064016103a4565b6104bb81610c32565b336108626000546001600160a01b031690565b6001600160a01b0316146108b85760405162461bcd60e51b815260206004820152601860248201527f4f776e61626c652f63616c6c65722d6e6f742d6f776e6572000000000000000060448201526064016103a4565b6001600160a01b0381166109345760405162461bcd60e51b815260206004820152602560248201527f4f776e61626c652f70656e64696e674f776e65722d6e6f742d7a65726f2d616460448201527f647265737300000000000000000000000000000000000000000000000000000060648201526084016103a4565b6001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f239a2ddded15777fa246aed5f7e1a9bc69a39d4eb4a397034d1d85766cca7d4c90600090a250565b60008281526007602052604090205463ffffffff16806109ed5760405162461bcd60e51b815260206004820181905260248201527f524e47436861696e4c696e6b2f7265717565737449642d696e636f727265637460448201526064016103a4565b600082600081518110610a0257610a02610ec7565b60209081029190910181015163ffffffff841660008181526005845260409081902083905551828152919350917f629394f18de7accce1179c28c39be59503a57cbcf45980a2772743b041b36271910160405180910390a250505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80610b0a5760405162461bcd60e51b815260206004820152601e60248201527f524e47436861696e4c696e6b2f6b6579486173682d6e6f742d656d707479000060448201526064016103a4565b60048190556040518181527fd013f86c8346660ebf421351882cd1b3c2f91883092df1800264c656b0db0cc6906020015b60405180910390a150565b6002546000906001600160a01b03908116908316811415610bcf5760405162461bcd60e51b815260206004820152602360248201527f4d616e61676561626c652f6578697374696e672d6d616e616765722d6164647260448201527f657373000000000000000000000000000000000000000000000000000000000060648201526084016103a4565b6002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0385811691821790925560405190918316907f9cb45c728de594dab506a1f1a8554e24c8eeaf983618d5ec5dd7bc6f3c49feee90600090a350600192915050565b60008167ffffffffffffffff1611610c8c5760405162461bcd60e51b815260206004820152601a60248201527f524e47436861696e4c696e6b2f73756249642d67742d7a65726f00000000000060448201526064016103a4565b6003805477ffffffffffffffffffffffffffffffffffffffffffffffff16600160c01b67ffffffffffffffff8416908102919091179091556040519081527f68de96e24c66c14c012b5bd342251abc26a6003eaa438002bfe530f28ca63fed90602001610b3b565b600060208284031215610d0657600080fd5b81356001600160a01b0381168114610d1d57600080fd5b9392505050565b600060208284031215610d3657600080fd5b5035919050565b600060208284031215610d4f57600080fd5b5051919050565b60008060408385031215610d6957600080fd5b8235915060208084013567ffffffffffffffff80821115610d8957600080fd5b818601915086601f830112610d9d57600080fd5b813581811115610daf57610daf610edd565b8060051b6040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0603f83011681018181108582111715610df257610df2610edd565b604052828152858101935084860182860187018b1015610e1157600080fd5b600095505b83861015610e34578035855260019590950194938601938601610e16565b508096505050505050509250929050565b600060208284031215610e5757600080fd5b813563ffffffff81168114610d1d57600080fd5b600060208284031215610e7d57600080fd5b813567ffffffffffffffff81168114610d1d57600080fd5b600063ffffffff80831681811415610ebd57634e487b7160e01b600052601160045260246000fd5b6001019392505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fdfea264697066735822122042526c344581deb9f46da496a1ec6cdaede06522e82b272433e8ea687ec4ca3964736f6c634300080600330000000000000000000000003a791e828fdd420fbe16416efdf509e4b9088dd40000000000000000000000007a1bac17ccc5b313516c5e16fb24f7659aa5ebed00000000000000000000000000000000000000000000000000000000000009834b09e658ed251bcafeebbc69400383d49f344ace09b9576fe248bb02c003fe9f

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

0000000000000000000000003a791e828fdd420fbe16416efdf509e4b9088dd40000000000000000000000007a1bac17ccc5b313516c5e16fb24f7659aa5ebed00000000000000000000000000000000000000000000000000000000000009834b09e658ed251bcafeebbc69400383d49f344ace09b9576fe248bb02c003fe9f

-----Decoded View---------------
Arg [0] : _owner (address): 0x3a791e828fdd420fbe16416efdf509e4b9088dd4
Arg [1] : _vrfCoordinator (address): 0x7a1bac17ccc5b313516c5e16fb24f7659aa5ebed
Arg [2] : _subscriptionId (uint64): 2435
Arg [3] : _keyHash (bytes32): 0x4b09e658ed251bcafeebbc69400383d49f344ace09b9576fe248bb02c003fe9f

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000003a791e828fdd420fbe16416efdf509e4b9088dd4
Arg [1] : 0000000000000000000000007a1bac17ccc5b313516c5e16fb24f7659aa5ebed
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000983
Arg [3] : 4b09e658ed251bcafeebbc69400383d49f344ace09b9576fe248bb02c003fe9f


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading