ETH Price: $3,165.49 (-8.79%)

Contract

0x15d3752e7c673a84837E8c5381992c9E63D8a698

Overview

ETH Balance

0 ETH

ETH Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
0x60806040951184212023-05-27 22:31:43424 days ago1685226703IN
 Create: FairyRaffle
0 ETH0.000839140.1

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
FairyRaffle

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 15 : FairyRaffle.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.18;

import {TypeAndVersion} from "../interfaces/TypeAndVersion.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {IRaffleChef} from "../interfaces/IRaffleChef.sol";
import {IRandomiserCallback} from "../interfaces/IRandomiserCallback.sol";
import {IRandomProvider} from "./IRandomProvider.sol";

/// @title FairyRaffle (VRF)
/// @author kevincharm
/// @notice The "classic" Fairymint raffler:
///     * Off-chain collection
///         Collect your participants off-chain. All this contract needs is a
///         final merkle root of all the participants. This provides
///         _transparency_: participants can verify that they are included in
///         the participants list and that the merkle root correctly
///         represents a publicly-provided participants list.
///     * On-chain raffle
///         The drawing of random numbers & picking of winners is performed
///         entirely on-chain. This provides _immutability_ and
///         _trustlessness_: the resulting list of winners must be drawn
///         according to the random number and algorithm and therefore is
///         impossible to manipulate, given the random number source is also
///         secure. The algorithm, while efficient enough for on-chain
///         execution, is based on secure cryptographic building blocks: Merkle
///         trees and Feistel ciphers.
///     * Off-chain distribution
///         The winners of the raffle can be computed from the results of the
///         on-chain raffle. As with off-chain collection, this provides
///         _transparency_: participants can verify that the list of winners
///         is indeed correct given the results of the on-chain raffle.
///     Customised for FVM: sourcing randomness from built-in drand
contract FairyRaffle is
    IRandomiserCallback,
    TypeAndVersion,
    OwnableUpgradeable
{
    /// @notice RaffleChef
    address public raffleChef;
    /// @notice Randomiser
    address public randomiser;
    /// @notice FairyRaffleFactory
    address public factory;

    /// @notice Merkle root (commitment) of raffle participants
    bytes32 public participantsMerkleRoot;
    /// @notice Number of raffle participants
    uint256 public nParticipants;
    /// @notice Number of winners that should be drawn during raffle
    uint256 public nWinners;
    /// @notice For record of provenance; could be e.g. an IPFS content hash
    ///     of participants list. This is not used on-chain.
    string public provenance;
    /// @notice Minimum blocks to wait until a VRF request can be fulfilled
    uint16 public minBlocksToWait;

    /// @notice The requestId returned by the randomiser
    uint256 public requestId;
    /// @notice The raffleId returned by RaffleChef
    uint256 public raffleId;
    /// @notice Callback gas limit for receiving random numbers
    uint32 public constant CALLBACK_GAS_LIMIT = 500_000;

    /// @notice Minimum period that must be awaited before a reroll is possible
    /// @dev NB: 24h is the period for which a VRF request can stay pending
    uint256 public constant MINIMUM_REROLL_PERIOD = 24 hours;
    /// @notice Last time a random number was requested
    uint256 public lastRolledAt;

    error Uninitialised();
    error RerollNotYetPossible(uint256 secondsLeft);
    error AlreadyFinalised(uint256 raffleId);
    error CallerNotRandomProvider(
        address caller,
        address expectedRandomProvider
    );
    error NotRolledYet();
    error RequestIdMismatch(
        uint256 receivedRequestId,
        uint256 expectedRequestId
    );

    constructor() {
        _disableInitializers();
    }

    function typeAndVersion() external pure override returns (string memory) {
        return "FairyRaffle 1.1.0";
    }

    /// @notice Commit to a participants list and start the raffle by
    ///     requesting a random number from drand.
    /// @dev Assumes this is called by the factory.
    /// @param minBlocksToWait_ How many (minimum) block confirmations before
    ///     the VRF
    function init(
        address raffleChef_,
        address randomiser_,
        bytes32 participantsMerkleRoot_,
        uint256 nParticipants_,
        uint256 nWinners_,
        string calldata provenance_,
        uint16 minBlocksToWait_
    ) public payable initializer {
        __Ownable_init();

        raffleChef = raffleChef_;
        randomiser = randomiser_;

        participantsMerkleRoot = participantsMerkleRoot_;
        nParticipants = nParticipants_;
        nWinners = nWinners_;
        provenance = provenance_;
        minBlocksToWait = minBlocksToWait_;

        factory = msg.sender;

        _roll();
    }

    /// @dev Assert that the raffle has not been finalised
    function _assertNotFinalised() internal view {
        if (raffleId != 0) {
            revert AlreadyFinalised(raffleId);
        }
    }

    /// @notice Request a random number and record the timestamp.
    /// @dev Does NOT do any checks about whether a roll is allowed
    function _roll() internal {
        lastRolledAt = block.timestamp;
        requestId = IRandomProvider(factory).getRandomNumber{value: msg.value}(
            500_000,
            minBlocksToWait
        );
    }

    /// @notice Re-request a random number. This can be called if a VRF request
    ///     was never fulfilled by the node operator, and the minimum waiting
    ///     period has passed.
    function reroll() public payable onlyOwner {
        _assertNotFinalised();
        if (requestId == 0) {
            revert Uninitialised();
        }
        if (block.timestamp - lastRolledAt <= MINIMUM_REROLL_PERIOD) {
            revert RerollNotYetPossible(lastRolledAt + MINIMUM_REROLL_PERIOD);
        }
        _roll();
    }

    /// @notice See {IRandomiserCallback-receiveRandomWords}
    /// @notice When this function is called by the randomiser, the raffle is
    ///     finalised with a random seed on the RaffleChef, and the winners
    ///     may instantly be queried on the RaffleChef.
    function receiveRandomWords(
        uint256 requestId_,
        uint256[] calldata randomWords
    ) external {
        if (msg.sender != randomiser) {
            revert CallerNotRandomProvider(msg.sender, randomiser);
        }
        uint256 rid = requestId;
        if (rid == 0) {
            revert NotRolledYet();
        }
        if (requestId_ != rid) {
            revert RequestIdMismatch(requestId_, rid);
        }
        _assertNotFinalised();

        raffleId = IRaffleChef(raffleChef).commit(
            participantsMerkleRoot,
            nParticipants,
            nWinners,
            provenance,
            randomWords[0]
        );
    }
}

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

interface LinkTokenInterface {
  function allowance(address owner, address spender) external view returns (uint256 remaining);

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

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

  function decimals() external view returns (uint8 decimalPlaces);

  function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);

  function increaseApproval(address spender, uint256 subtractedValue) external;

  function name() external view returns (string memory tokenName);

  function symbol() external view returns (string memory tokenSymbol);

  function totalSupply() external view returns (uint256 totalTokensIssued);

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

  function transferAndCall(
    address to,
    uint256 value,
    bytes calldata data
  ) external returns (bool success);

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

File 3 of 15 : 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 4 of 15 : 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 5 of 15 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../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.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

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

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

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

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

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

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions 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() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

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

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 6 of 15 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * 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]
 * ```
 * 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 Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

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

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 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 functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _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 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _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() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @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 {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

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

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

File 7 of 15 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
        }
    }
}

File 8 of 15 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../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;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 9 of 15 : IRandomProvider.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.18;

import {ChainlinkVRFV2Randomiser} from "../randomisers/ChainlinkVRFV2Randomiser.sol";

interface IRandomProvider {
    /// @notice Compute the required ETH to get a random number
    /// @param callbackGasLimit Gas limit to use for callback
    function computeRandomNumberRequestCost(uint32 callbackGasLimit)
        external
        returns (uint256);

    /// @notice Get a random number from
    /// @param callbackGasLimit Gas limit to use for callback
    /// @param minBlocksToWait Minimum confirmations to wait
    function getRandomNumber(uint32 callbackGasLimit, uint16 minBlocksToWait)
        external
        payable
        returns (uint256 requestId);
}

File 10 of 15 : IRaffleChef.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.18;

interface IRaffleChef {
    event RaffleCreated(uint256 indexed raffleId);
    event RaffleCommitted(uint256 indexed raffleId);

    error RaffleNotRolled(uint256 raffleId);
    error InvalidCommitment(
        uint256 raffleId,
        bytes32 merkleRoot,
        uint256 nParticipants,
        uint256 nWinners,
        uint256 randomness,
        string provenance
    );
    error Unauthorised(address unauthorisedUser);
    error StartingRaffleIdTooLow(uint256 raffleId);
    error InvalidProof(bytes32 leaf, bytes32[] proof);

    /// @dev Descriptive state of a raffle based on its variables that are set/unset
    enum RaffleState {
        /// @dev Default state
        Unknown,
        /// @dev Done
        Committed
    }

    /// @notice Structure of every raffle; presence of certain elements indicate the raffle state
    struct Raffle {
        bytes32 participantsMerkleRoot;
        uint256 nParticipants;
        uint256 nWinners;
        uint256 randomSeed;
        address owner;
        string provenance;
    }

    /// @notice Publish a commitment (the merkle root of the finalised participants list, and
    ///     the number of winners to draw, and the random seed). Only call this function once
    ///     the random seed and list of raffle participants has finished being collected.
    /// @param participantsMerkleRoot Merkle root constructed from finalised participants list
    /// @param nWinners Number of winners to draw
    /// @param provenance IPFS CID of this raffle's provenance including full participants list
    /// @param randomness Random seed for the raffle
    /// @return Raffle ID that can be used to lookup the raffle results, when
    ///     the raffle is finalised.
    function commit(
        bytes32 participantsMerkleRoot,
        uint256 nParticipants,
        uint256 nWinners,
        string calldata provenance,
        uint256 randomness
    ) external returns (uint256);

    /// @notice Get the nth-drawn winner of the raffle with raffleId.
    ///     NB: 0-based.
    /// @param raffleId ID of the raffle to check
    /// @param n nth winner
    function getNthWinner(uint256 raffleId, uint256 n)
        external
        view
        returns (uint256);

    /// @notice Get a list of winners in a range.
    /// @param raffleId ID of the raffle to check
    /// @param from Winner index to start from (0-based)
    /// @param to Winner index to stop at (exclusive)
    function getWinners(
        uint256 raffleId,
        uint256 from,
        uint256 to
    ) external view returns (uint256[] memory);

    /// @notice Verify that an account is in the winners list for a specific raffle
    ///     using a merkle proof and the raffle's previous public commitments. This is
    ///     a view-only function that does not record if a winner has already claimed
    ///     their win; that is left up to the caller to handle.
    /// @param raffleId ID of the raffle to check against
    /// @param leafHash Hash of the leaf value that represents the participant
    /// @param proof Merkle subproof (hashes)
    /// @param originalIndex Original leaf index in merkle tree, part of merkle proof
    /// @return isWinner true if claiming account is indeed a winner
    /// @return permutedIndex winning (shuffled) index
    function verifyWinner(
        uint256 raffleId,
        bytes32 leafHash,
        bytes32[] calldata proof,
        uint256 originalIndex
    ) external view returns (bool isWinner, uint256 permutedIndex);

    /// @notice Get an existing raffle
    /// @param raffleId ID of raffle to get
    /// @return raffle data, if it exists
    function getRaffle(uint256 raffleId) external view returns (Raffle memory);

    /// @notice Get the current state of raffle, given a `raffleId`
    /// @param raffleId ID of raffle to get
    /// @return See {RaffleState} enum
    function getRaffleState(uint256 raffleId)
        external
        view
        returns (RaffleState);
}

File 11 of 15 : IRandomiserCallback.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8;

interface IRandomiserCallback {
    /// @notice Receive random words from a randomiser.
    /// @dev Ensure that proper access control is enforced on this function;
    ///     only the designated randomiser may call this function and the
    ///     requestId should be as expected from the randomness request.
    /// @param requestId The identifier for the original randomness request
    /// @param randomWords An arbitrary array of random numbers
    function receiveRandomWords(
        uint256 requestId,
        uint256[] calldata randomWords
    ) external;
}

File 12 of 15 : IRandomiserGen2.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.18;

interface IRandomiserGen2 {
    function getRandomNumber(
        address callbackContract,
        uint32 callbackGasLimit,
        uint16 minConfirmations
    ) external payable returns (uint256 requestId);
}

File 13 of 15 : TypeAndVersion.sol
// SPDX-License-Identifier: MIT
/**
    The MIT License (MIT)

    Copyright (c) 2018 SmartContract ChainLink, Ltd.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/

pragma solidity ^0.8;

abstract contract TypeAndVersion {
    function typeAndVersion() external pure virtual returns (string memory);
}

File 14 of 15 : ChainlinkVRFV2Randomiser.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8;

import {IRandomiserGen2} from "../interfaces/IRandomiserGen2.sol";
import {TypeAndVersion} from "../interfaces/TypeAndVersion.sol";
import {Authorised} from "../vendor/Authorised.sol";
import {VRFCoordinatorV2Interface} from "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import {VRFConsumerBaseV2} from "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol";
import {LinkTokenInterface} from "@chainlink/contracts/src/v0.8/interfaces/LinkTokenInterface.sol";
import {IRandomiserCallback} from "../interfaces/IRandomiserCallback.sol";

/// @title ChainlinkVRFV2Randomiser
/// @author kevincharm
/// @notice Consume Chainlink's subscription-managed VRFv2 wrapper to return a
///     random number.
/// @dev NB: Not audited.
contract ChainlinkVRFV2Randomiser is
    IRandomiserGen2,
    TypeAndVersion,
    Authorised,
    VRFConsumerBaseV2
{
    /// --- VRF SHIT ---
    /// @notice VRF Coordinator (V2)
    /// @dev https://docs.chain.link/vrf/v2/subscription/supported-networks
    address public immutable vrfCoordinator;
    /// @notice LINK token (make sure it's the ERC-677 one)
    /// @dev PegSwap: https://pegswap.chain.link
    address public immutable linkToken;
    /// @notice LINK token unit
    uint256 public immutable juels;
    /// @dev VRF Coordinator LINK premium per request
    uint256 public immutable linkPremium;
    /// @notice Each gas lane has a different key hash; each gas lane
    ///     determines max gwei that will be used for the callback
    bytes32 public immutable gasLaneKeyHash;
    /// @notice Max gas price for gas lane used in gasLaneKeyHash
    /// @dev This is used purely for gas estimation
    uint256 public immutable gasLaneMaxWei;
    /// @notice Absolute gas limit for callbacks
    uint32 public immutable callbackGasLimit;
    /// @notice VRF subscription ID; created during deployment
    uint64 public immutable subId;

    /// @notice requestId => contract to callback
    /// @dev contract must implement IRandomiserCallback
    mapping(uint256 => address) public callbackTargets;

    event RandomNumberRequested(uint256 indexed requestId);
    event RandomNumberFulfilled(uint256 indexed requestId, uint256 randomness);

    error InvalidFeedConfig(address feed, uint8 decimals);
    error InvalidFeedAnswer(
        int256 price,
        uint256 latestRoundId,
        uint256 updatedAt
    );

    constructor(
        address vrfCoordinator_,
        address linkToken_,
        uint256 linkPremium_,
        bytes32 gasLaneKeyHash_,
        uint256 gasLaneMaxWei_,
        uint32 callbackGasLimit_,
        uint64 subId_
    ) VRFConsumerBaseV2(vrfCoordinator_) {
        vrfCoordinator = vrfCoordinator_;
        linkToken = linkToken_;
        juels = 10**LinkTokenInterface(linkToken_).decimals();
        linkPremium = linkPremium_;
        gasLaneKeyHash = gasLaneKeyHash_;
        gasLaneMaxWei = gasLaneMaxWei_;
        callbackGasLimit = callbackGasLimit_;
        // NB: This contract must be added as a consumer to this subscription
        subId = subId_;
    }

    function typeAndVersion()
        external
        pure
        virtual
        override
        returns (string memory)
    {
        return "ChainlinkVRFV2Randomiser 1.0.0";
    }

    /// @notice Request a random number
    /// @param callbackContract Target contract to callback with random numbers
    /// @param minConfirmations Number of block confirmations to wait.
    function getRandomNumber(
        address callbackContract,
        uint32, /** callbackGasLimit */
        uint16 minConfirmations
    ) public payable override onlyAuthorised returns (uint256 requestId) {
        requestId = VRFCoordinatorV2Interface(vrfCoordinator)
            .requestRandomWords(
                gasLaneKeyHash,
                subId,
                minConfirmations,
                callbackGasLimit,
                1
            );
        callbackTargets[requestId] = callbackContract;
        emit RandomNumberRequested(requestId);
    }

    /// @notice Callback function used by VRF Coordinator
    function fulfillRandomWords(uint256 requestId, uint256[] memory randomness)
        internal
        override
    {
        address target = callbackTargets[requestId];
        delete callbackTargets[requestId];
        IRandomiserCallback(target).receiveRandomWords(requestId, randomness);
        emit RandomNumberFulfilled(requestId, randomness[0]);
    }
}

File 15 of 15 : Authorised.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8;

/// @title Authorised
/// @notice Restrict functions to whitelisted admins with the `onlyAdmin`
///     modifier. Deployer of contract is automatically added as an admin.
contract Authorised {
    /// @notice Whitelisted admins
    mapping(address => bool) public isAuthorised;

    error NotAuthorised(address culprit);

    constructor() {
        isAuthorised[msg.sender] = true;
    }

    /// @notice Restrict function to whitelisted admins only
    modifier onlyAuthorised() {
        if (!isAuthorised[msg.sender]) {
            revert NotAuthorised(msg.sender);
        }
        _;
    }

    /// @notice Set authorisation of a specific account
    /// @param toggle `true` to authorise account as an admin
    function authorise(address guy, bool toggle) public onlyAuthorised {
        isAuthorised[guy] = toggle;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"raffleId","type":"uint256"}],"name":"AlreadyFinalised","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"},{"internalType":"address","name":"expectedRandomProvider","type":"address"}],"name":"CallerNotRandomProvider","type":"error"},{"inputs":[],"name":"NotRolledYet","type":"error"},{"inputs":[{"internalType":"uint256","name":"receivedRequestId","type":"uint256"},{"internalType":"uint256","name":"expectedRequestId","type":"uint256"}],"name":"RequestIdMismatch","type":"error"},{"inputs":[{"internalType":"uint256","name":"secondsLeft","type":"uint256"}],"name":"RerollNotYetPossible","type":"error"},{"inputs":[],"name":"Uninitialised","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"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"},{"inputs":[],"name":"CALLBACK_GAS_LIMIT","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_REROLL_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"factory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"raffleChef_","type":"address"},{"internalType":"address","name":"randomiser_","type":"address"},{"internalType":"bytes32","name":"participantsMerkleRoot_","type":"bytes32"},{"internalType":"uint256","name":"nParticipants_","type":"uint256"},{"internalType":"uint256","name":"nWinners_","type":"uint256"},{"internalType":"string","name":"provenance_","type":"string"},{"internalType":"uint16","name":"minBlocksToWait_","type":"uint16"}],"name":"init","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"lastRolledAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBlocksToWait","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nParticipants","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nWinners","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"participantsMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"provenance","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"raffleChef","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"raffleId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randomiser","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId_","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"receiveRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reroll","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"typeAndVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}]

608060405234801561001057600080fd5b5061001961001e565b610106565b600054610100900460ff161561004f5760405162461bcd60e51b8152600401610046906100a6565b60405180910390fd5b60005460ff90811610156100a4576000805460ff191660ff9081179091556040517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989161009b916100f7565b60405180910390a15b565b602080825281016100f181602781527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469602082015266616c697a696e6760c81b604082015260600190565b92915050565b60ff82168152602081016100f1565b61125b806101156000396000f3fe60806040526004361061015e5760003560e01c8063995e8ce7116100c0578063c45a015511610074578063efed571611610059578063efed571614610366578063f2e8e7601461037d578063f2fde38b146103a557600080fd5b8063c45a01551461033e578063e3943ccb1461035e57600080fd5b8063b375603c116100a5578063b375603c146102fc578063b63bc3b414610312578063bb8946681461032857600080fd5b8063995e8ce7146102c9578063a0c4615c146102dc57600080fd5b8063336f528a116101175780634d7779e1116100fc5780634d7779e11461027e578063715018a6146102945780638da5cb5b146102ab57600080fd5b8063336f528a1461023a57806333d608f11461025a57600080fd5b806312c3783b1161014857806312c3783b146101b1578063181f5a77146101c75780631f87b5c81461020d57600080fd5b80626d6cae146101635780630f7309e81461018f575b600080fd5b34801561016f57600080fd5b50610179606d5481565b6040516101869190610a14565b60405180910390f35b34801561019b57600080fd5b506101a46103c5565b6040516101869190610a7e565b3480156101bd57600080fd5b50610179606a5481565b3480156101d357600080fd5b5060408051808201909152601181527f4661697279526166666c6520312e312e3000000000000000000000000000000060208201526101a4565b34801561021957600080fd5b5060655461022d906001600160a01b031681565b6040516101869190610ab0565b34801561024657600080fd5b5060665461022d906001600160a01b031681565b34801561026657600080fd5b506102716207a12081565b6040516101869190610aca565b34801561028a57600080fd5b5061017960685481565b3480156102a057600080fd5b506102a9610453565b005b3480156102b757600080fd5b506033546001600160a01b031661022d565b6102a96102d7366004610b6f565b610467565b3480156102e857600080fd5b506102a96102f7366004610c78565b6105db565b34801561030857600080fd5b50610179606e5481565b34801561031e57600080fd5b5061017960695481565b34801561033457600080fd5b50610179606f5481565b34801561034a57600080fd5b5060675461022d906001600160a01b031681565b6102a9610759565b34801561037257600080fd5b506101796201518081565b34801561038957600080fd5b50606c546103989061ffff1681565b6040516101869190610cde565b3480156103b157600080fd5b506102a96103c0366004610cec565b610808565b606b80546103d290610d2b565b80601f01602080910402602001604051908101604052809291908181526020018280546103fe90610d2b565b801561044b5780601f106104205761010080835404028352916020019161044b565b820191906000526020600020905b81548152906001019060200180831161042e57829003601f168201915b505050505081565b61045b610842565b610465600061086c565b565b600054610100900460ff16158080156104875750600054600160ff909116105b806104a15750303b1580156104a1575060005460ff166001145b6104c65760405162461bcd60e51b81526004016104bd90610db4565b60405180910390fd5b6000805460ff1916600117905580156104e9576000805461ff0019166101001790555b6104f16108cb565b606580546001600160a01b03808c1673ffffffffffffffffffffffffffffffffffffffff199283161790925560668054928b169290911691909117905560688790556069869055606a859055606b61054a848683610e7e565b50606c805461ffff841661ffff199091161790556067805473ffffffffffffffffffffffffffffffffffffffff1916331790556105856108fa565b80156105d0576000805461ff00191690556040517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906105c790600190610f56565b60405180910390a15b505050505050505050565b6066546001600160a01b03163314610630576066546040517f04e191720000000000000000000000000000000000000000000000000000000081526104bd9133916001600160a01b0390911690600401610f64565b606d54600081900361066e576040517f3bba014300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8084146106ab5783816040517f1bd434330000000000000000000000000000000000000000000000000000000081526004016104bd929190610f7f565b6106b361099e565b606554606854606954606a546001600160a01b039093169263c6faa975929190606b88886000816106e6576106e6610f9a565b905060200201356040518663ffffffff1660e01b815260040161070d95949392919061102a565b6020604051808303816000875af115801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190611088565b606e5550505050565b610761610842565b61076961099e565b606d546000036107a5576040517fcffb2a1d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62015180606f54426107b791906110bf565b116108005762015180606f546107cd91906110d2565b6040517f67759d280000000000000000000000000000000000000000000000000000000081526004016104bd9190610a14565b6104656108fa565b610810610842565b6001600160a01b0381166108365760405162461bcd60e51b81526004016104bd9061113f565b61083f8161086c565b50565b6033546001600160a01b031633146104655760405162461bcd60e51b81526004016104bd9061114f565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166108f25760405162461bcd60e51b81526004016104bd906111e3565b6104656109dc565b42606f55606754606c546040517fd48df9c20000000000000000000000000000000000000000000000000000000081526001600160a01b039092169163d48df9c2913491610956916207a1209161ffff9091169060040161120a565b60206040518083038185885af1158015610974573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109999190611088565b606d55565b606e541561046557606e546040517f1ffebc2c0000000000000000000000000000000000000000000000000000000081526004016104bd9190610a14565b600054610100900460ff16610a035760405162461bcd60e51b81526004016104bd906111e3565b6104653361086c565b805b82525050565b60208101610a228284610a0c565b92915050565b60005b83811015610a43578181015183820152602001610a2b565b50506000910152565b6000610a56825190565b808452602084019350610a6d818560208601610a28565b601f01601f19169290920192915050565b60208082528101610a8f8184610a4c565b9392505050565b60006001600160a01b038216610a22565b610a0e81610a96565b60208101610a228284610aa7565b63ffffffff8116610a0e565b60208101610a228284610abe565b610ae181610a96565b811461083f57600080fd5b8035610a2281610ad8565b80610ae1565b8035610a2281610af7565b60008083601f840112610b1d57610b1d600080fd5b50813567ffffffffffffffff811115610b3857610b38600080fd5b602083019150836001820283011115610b5357610b53600080fd5b9250929050565b61ffff8116610ae1565b8035610a2281610b5a565b60008060008060008060008060e0898b031215610b8e57610b8e600080fd5b6000610b9a8b8b610aec565b9850506020610bab8b828c01610aec565b9750506040610bbc8b828c01610afd565b9650506060610bcd8b828c01610afd565b9550506080610bde8b828c01610afd565b94505060a089013567ffffffffffffffff811115610bfe57610bfe600080fd5b610c0a8b828c01610b08565b935093505060c0610c1d8b828c01610b64565b9150509295985092959890939650565b60008083601f840112610c4257610c42600080fd5b50813567ffffffffffffffff811115610c5d57610c5d600080fd5b602083019150836020820283011115610b5357610b53600080fd5b600080600060408486031215610c9057610c90600080fd5b6000610c9c8686610afd565b935050602084013567ffffffffffffffff811115610cbc57610cbc600080fd5b610cc886828701610c2d565b92509250509250925092565b61ffff8116610a0e565b60208101610a228284610cd4565b600060208284031215610d0157610d01600080fd5b6000610d0d8484610aec565b949350505050565b634e487b7160e01b600052602260045260246000fd5b600281046001821680610d3f57607f821691505b602082108103610d5157610d51610d15565b50919050565b602e81526000602082017f496e697469616c697a61626c653a20636f6e747261637420697320616c72656181527f647920696e697469616c697a6564000000000000000000000000000000000000602082015291505b5060400190565b60208082528101610a2281610d57565b634e487b7160e01b600052604160045260246000fd5b6000610a22610de68381565b90565b610df283610dda565b815460001960089490940293841b1916921b91909117905550565b6000610e1a818484610de9565b505050565b81811015610e3a57610e32600082610e0d565b600101610e1f565b5050565b601f821115610e1a576000818152602090206020601f85010481016020851015610e655750805b610e776020601f860104830182610e1f565b5050505050565b8267ffffffffffffffff811115610e9757610e97610dc4565b610ea18254610d2b565b610eac828285610e3e565b6000601f831160018114610ee05760008415610ec85750858201355b600019600886021c1981166002860217865550610f39565b600085815260208120601f198616915b82811015610f105788850135825560209485019460019092019101610ef0565b86831015610f2c57600019601f88166008021c19858a01351682555b6001600288020188555050505b50505050505050565b600060ff8216610a22565b610a0e81610f42565b60208101610a228284610f4d565b60408101610f728285610aa7565b610a8f6020830184610aa7565b60408101610f8d8285610a0c565b610a8f6020830184610a0c565b634e487b7160e01b600052603260045260246000fd5b60008154610fbd81610d2b565b808552602085019450600182168015610fdd5760018114610ff357611021565b60ff198316865260208215150286019350611021565b60008581526020902060005b8381101561101b57815488820152600190910190602001610fff565b87019450505b50505092915050565b60a081016110388288610a0c565b6110456020830187610a0c565b6110526040830186610a0c565b81810360608301526110648185610fb0565b90506110736080830184610a0c565b9695505050505050565b8051610a2281610af7565b60006020828403121561109d5761109d600080fd5b6000610d0d848461107d565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a2257610a226110a9565b80820180821115610a2257610a226110a9565b602681526000602082017f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181527f646472657373000000000000000000000000000000000000000000000000000060208201529150610dad565b60208082528101610a22816110e5565b60208082528181019081527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604083015260608201610a22565b602b81526000602082017f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206981527f6e697469616c697a696e6700000000000000000000000000000000000000000060208201529150610dad565b60208082528101610a2281611189565b600063ffffffff8216610a22565b610a0e816111f3565b604081016112188285611201565b610a8f6020830184610cd456fea2646970667358221220d3ee8962b597ef11134f457c01b654cd734e481447f073edcb3def079d62c69364736f6c63430008120033

Deployed Bytecode

0x60806040526004361061015e5760003560e01c8063995e8ce7116100c0578063c45a015511610074578063efed571611610059578063efed571614610366578063f2e8e7601461037d578063f2fde38b146103a557600080fd5b8063c45a01551461033e578063e3943ccb1461035e57600080fd5b8063b375603c116100a5578063b375603c146102fc578063b63bc3b414610312578063bb8946681461032857600080fd5b8063995e8ce7146102c9578063a0c4615c146102dc57600080fd5b8063336f528a116101175780634d7779e1116100fc5780634d7779e11461027e578063715018a6146102945780638da5cb5b146102ab57600080fd5b8063336f528a1461023a57806333d608f11461025a57600080fd5b806312c3783b1161014857806312c3783b146101b1578063181f5a77146101c75780631f87b5c81461020d57600080fd5b80626d6cae146101635780630f7309e81461018f575b600080fd5b34801561016f57600080fd5b50610179606d5481565b6040516101869190610a14565b60405180910390f35b34801561019b57600080fd5b506101a46103c5565b6040516101869190610a7e565b3480156101bd57600080fd5b50610179606a5481565b3480156101d357600080fd5b5060408051808201909152601181527f4661697279526166666c6520312e312e3000000000000000000000000000000060208201526101a4565b34801561021957600080fd5b5060655461022d906001600160a01b031681565b6040516101869190610ab0565b34801561024657600080fd5b5060665461022d906001600160a01b031681565b34801561026657600080fd5b506102716207a12081565b6040516101869190610aca565b34801561028a57600080fd5b5061017960685481565b3480156102a057600080fd5b506102a9610453565b005b3480156102b757600080fd5b506033546001600160a01b031661022d565b6102a96102d7366004610b6f565b610467565b3480156102e857600080fd5b506102a96102f7366004610c78565b6105db565b34801561030857600080fd5b50610179606e5481565b34801561031e57600080fd5b5061017960695481565b34801561033457600080fd5b50610179606f5481565b34801561034a57600080fd5b5060675461022d906001600160a01b031681565b6102a9610759565b34801561037257600080fd5b506101796201518081565b34801561038957600080fd5b50606c546103989061ffff1681565b6040516101869190610cde565b3480156103b157600080fd5b506102a96103c0366004610cec565b610808565b606b80546103d290610d2b565b80601f01602080910402602001604051908101604052809291908181526020018280546103fe90610d2b565b801561044b5780601f106104205761010080835404028352916020019161044b565b820191906000526020600020905b81548152906001019060200180831161042e57829003601f168201915b505050505081565b61045b610842565b610465600061086c565b565b600054610100900460ff16158080156104875750600054600160ff909116105b806104a15750303b1580156104a1575060005460ff166001145b6104c65760405162461bcd60e51b81526004016104bd90610db4565b60405180910390fd5b6000805460ff1916600117905580156104e9576000805461ff0019166101001790555b6104f16108cb565b606580546001600160a01b03808c1673ffffffffffffffffffffffffffffffffffffffff199283161790925560668054928b169290911691909117905560688790556069869055606a859055606b61054a848683610e7e565b50606c805461ffff841661ffff199091161790556067805473ffffffffffffffffffffffffffffffffffffffff1916331790556105856108fa565b80156105d0576000805461ff00191690556040517f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498906105c790600190610f56565b60405180910390a15b505050505050505050565b6066546001600160a01b03163314610630576066546040517f04e191720000000000000000000000000000000000000000000000000000000081526104bd9133916001600160a01b0390911690600401610f64565b606d54600081900361066e576040517f3bba014300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8084146106ab5783816040517f1bd434330000000000000000000000000000000000000000000000000000000081526004016104bd929190610f7f565b6106b361099e565b606554606854606954606a546001600160a01b039093169263c6faa975929190606b88886000816106e6576106e6610f9a565b905060200201356040518663ffffffff1660e01b815260040161070d95949392919061102a565b6020604051808303816000875af115801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190611088565b606e5550505050565b610761610842565b61076961099e565b606d546000036107a5576040517fcffb2a1d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62015180606f54426107b791906110bf565b116108005762015180606f546107cd91906110d2565b6040517f67759d280000000000000000000000000000000000000000000000000000000081526004016104bd9190610a14565b6104656108fa565b610810610842565b6001600160a01b0381166108365760405162461bcd60e51b81526004016104bd9061113f565b61083f8161086c565b50565b6033546001600160a01b031633146104655760405162461bcd60e51b81526004016104bd9061114f565b603380546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166108f25760405162461bcd60e51b81526004016104bd906111e3565b6104656109dc565b42606f55606754606c546040517fd48df9c20000000000000000000000000000000000000000000000000000000081526001600160a01b039092169163d48df9c2913491610956916207a1209161ffff9091169060040161120a565b60206040518083038185885af1158015610974573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906109999190611088565b606d55565b606e541561046557606e546040517f1ffebc2c0000000000000000000000000000000000000000000000000000000081526004016104bd9190610a14565b600054610100900460ff16610a035760405162461bcd60e51b81526004016104bd906111e3565b6104653361086c565b805b82525050565b60208101610a228284610a0c565b92915050565b60005b83811015610a43578181015183820152602001610a2b565b50506000910152565b6000610a56825190565b808452602084019350610a6d818560208601610a28565b601f01601f19169290920192915050565b60208082528101610a8f8184610a4c565b9392505050565b60006001600160a01b038216610a22565b610a0e81610a96565b60208101610a228284610aa7565b63ffffffff8116610a0e565b60208101610a228284610abe565b610ae181610a96565b811461083f57600080fd5b8035610a2281610ad8565b80610ae1565b8035610a2281610af7565b60008083601f840112610b1d57610b1d600080fd5b50813567ffffffffffffffff811115610b3857610b38600080fd5b602083019150836001820283011115610b5357610b53600080fd5b9250929050565b61ffff8116610ae1565b8035610a2281610b5a565b60008060008060008060008060e0898b031215610b8e57610b8e600080fd5b6000610b9a8b8b610aec565b9850506020610bab8b828c01610aec565b9750506040610bbc8b828c01610afd565b9650506060610bcd8b828c01610afd565b9550506080610bde8b828c01610afd565b94505060a089013567ffffffffffffffff811115610bfe57610bfe600080fd5b610c0a8b828c01610b08565b935093505060c0610c1d8b828c01610b64565b9150509295985092959890939650565b60008083601f840112610c4257610c42600080fd5b50813567ffffffffffffffff811115610c5d57610c5d600080fd5b602083019150836020820283011115610b5357610b53600080fd5b600080600060408486031215610c9057610c90600080fd5b6000610c9c8686610afd565b935050602084013567ffffffffffffffff811115610cbc57610cbc600080fd5b610cc886828701610c2d565b92509250509250925092565b61ffff8116610a0e565b60208101610a228284610cd4565b600060208284031215610d0157610d01600080fd5b6000610d0d8484610aec565b949350505050565b634e487b7160e01b600052602260045260246000fd5b600281046001821680610d3f57607f821691505b602082108103610d5157610d51610d15565b50919050565b602e81526000602082017f496e697469616c697a61626c653a20636f6e747261637420697320616c72656181527f647920696e697469616c697a6564000000000000000000000000000000000000602082015291505b5060400190565b60208082528101610a2281610d57565b634e487b7160e01b600052604160045260246000fd5b6000610a22610de68381565b90565b610df283610dda565b815460001960089490940293841b1916921b91909117905550565b6000610e1a818484610de9565b505050565b81811015610e3a57610e32600082610e0d565b600101610e1f565b5050565b601f821115610e1a576000818152602090206020601f85010481016020851015610e655750805b610e776020601f860104830182610e1f565b5050505050565b8267ffffffffffffffff811115610e9757610e97610dc4565b610ea18254610d2b565b610eac828285610e3e565b6000601f831160018114610ee05760008415610ec85750858201355b600019600886021c1981166002860217865550610f39565b600085815260208120601f198616915b82811015610f105788850135825560209485019460019092019101610ef0565b86831015610f2c57600019601f88166008021c19858a01351682555b6001600288020188555050505b50505050505050565b600060ff8216610a22565b610a0e81610f42565b60208101610a228284610f4d565b60408101610f728285610aa7565b610a8f6020830184610aa7565b60408101610f8d8285610a0c565b610a8f6020830184610a0c565b634e487b7160e01b600052603260045260246000fd5b60008154610fbd81610d2b565b808552602085019450600182168015610fdd5760018114610ff357611021565b60ff198316865260208215150286019350611021565b60008581526020902060005b8381101561101b57815488820152600190910190602001610fff565b87019450505b50505092915050565b60a081016110388288610a0c565b6110456020830187610a0c565b6110526040830186610a0c565b81810360608301526110648185610fb0565b90506110736080830184610a0c565b9695505050505050565b8051610a2281610af7565b60006020828403121561109d5761109d600080fd5b6000610d0d848461107d565b634e487b7160e01b600052601160045260246000fd5b81810381811115610a2257610a226110a9565b80820180821115610a2257610a226110a9565b602681526000602082017f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206181527f646472657373000000000000000000000000000000000000000000000000000060208201529150610dad565b60208082528101610a22816110e5565b60208082528181019081527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604083015260608201610a22565b602b81526000602082017f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206981527f6e697469616c697a696e6700000000000000000000000000000000000000000060208201529150610dad565b60208082528101610a2281611189565b600063ffffffff8216610a22565b610a0e816111f3565b604081016112188285611201565b610a8f6020830184610cd456fea2646970667358221220d3ee8962b597ef11134f457c01b654cd734e481447f073edcb3def079d62c69364736f6c63430008120033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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