MATIC Price: $0.749877 (+9.65%)
Gas: 67 GWei
 

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

MATIC Value

$0.00

Sponsored

Transaction Hash
Method
Block
From
To
Value
Collect Vrf Fee549103682024-03-21 10:06:1761 days ago1711015577IN
0xbD0CD803...D30e3B9bC
0 MATIC0.0035119691.24362661
Collect Vrf Fee549103682024-03-21 10:06:1761 days ago1711015577IN
0xbD0CD803...D30e3B9bC
0 MATIC0.0039172890.69889699
Play548701122024-03-20 7:39:0962 days ago1710920349IN
0xbD0CD803...D30e3B9bC
0.13085684 MATIC0.030025489.59944517
Play548700982024-03-20 7:38:3962 days ago1710920319IN
0xbD0CD803...D30e3B9bC
0.13741727 MATIC0.0320712695.70455952
Play548700822024-03-20 7:38:0562 days ago1710920285IN
0xbD0CD803...D30e3B9bC
0.14640379 MATIC0.03517264104.963211
Play548384012024-03-19 11:25:2463 days ago1710847524IN
0xbD0CD803...D30e3B9bC
0.23463094 MATIC0.05416557161.64824385
Play548383842024-03-19 11:24:4863 days ago1710847488IN
0xbD0CD803...D30e3B9bC
0.251224 MATIC0.05718078170.64663832
Play548383672024-03-19 11:24:0363 days ago1710847443IN
0xbD0CD803...D30e3B9bC
0.2624702 MATIC0.06213905185.44375678
Play548383532024-03-19 11:23:3563 days ago1710847415IN
0xbD0CD803...D30e3B9bC
0.2841751 MATIC0.06770667202.05941645
Play548382462024-03-19 11:18:4363 days ago1710847123IN
0xbD0CD803...D30e3B9bC
0.22941127 MATIC0.05601242167.15386582
Play548382082024-03-19 11:17:2363 days ago1710847043IN
0xbD0CD803...D30e3B9bC
0.26077117 MATIC0.06216224185.51297492
Play548381922024-03-19 11:16:4963 days ago1710847009IN
0xbD0CD803...D30e3B9bC
0.28119988 MATIC0.06613636197.36600724
Play548381752024-03-19 11:16:1163 days ago1710846971IN
0xbD0CD803...D30e3B9bC
0.2673907 MATIC0.06614601197.39480204
Play541757422024-03-02 11:37:2880 days ago1709379448IN
0xbD0CD803...D30e3B9bC
0.08695462 MATIC0.0186073155.52847942
Play537069352024-02-19 12:42:1192 days ago1708346531IN
0xbD0CD803...D30e3B9bC
0.14990242 MATIC0.0332699599.28513454
Play537060442024-02-19 12:10:0192 days ago1708344601IN
0xbD0CD803...D30e3B9bC
0.19243476 MATIC0.04670274139.37165032
Play537060282024-02-19 12:09:2792 days ago1708344567IN
0xbD0CD803...D30e3B9bC
0.20631675 MATIC0.04556652135.98091741
Play537060142024-02-19 12:08:5792 days ago1708344537IN
0xbD0CD803...D30e3B9bC
0.21843426 MATIC0.05206288155.36754959
Play537059492024-02-19 12:06:3992 days ago1708344399IN
0xbD0CD803...D30e3B9bC
0.21757148 MATIC0.06087302181.65900647
Play537059322024-02-19 12:06:0392 days ago1708344363IN
0xbD0CD803...D30e3B9bC
0.19689976 MATIC0.0467466139.50754345
Play537058522024-02-19 12:03:1392 days ago1708344193IN
0xbD0CD803...D30e3B9bC
0.21015936 MATIC0.05050229150.71038903
Play537058352024-02-19 12:02:3792 days ago1708344157IN
0xbD0CD803...D30e3B9bC
0.22789612 MATIC0.05163257154.08339322
Play521956582024-01-11 11:03:40131 days ago1704971020IN
0xbD0CD803...D30e3B9bC
0.11758424 MATIC0.0260593677.76988634
Play521879012024-01-11 6:13:22131 days ago1704953602IN
0xbD0CD803...D30e3B9bC
0.05187518 MATIC0.0105823831.58139293
Play521878212024-01-11 6:10:28131 days ago1704953428IN
0xbD0CD803...D30e3B9bC
0.05149466 MATIC0.0105614631.51895997
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To Value
549103682024-03-21 10:06:1761 days ago1711015577
0xbD0CD803...D30e3B9bC
9.96627049 MATIC
548701122024-03-20 7:39:0962 days ago1710920349
0xbD0CD803...D30e3B9bC
0.03235324 MATIC
548700982024-03-20 7:38:3962 days ago1710920319
0xbD0CD803...D30e3B9bC
0.03280856 MATIC
548700822024-03-20 7:38:0562 days ago1710920285
0xbD0CD803...D30e3B9bC
0.03253643 MATIC
548384012024-03-19 11:25:2463 days ago1710847524
0xbD0CD803...D30e3B9bC
0.06384379 MATIC
548383842024-03-19 11:24:4863 days ago1710847488
0xbD0CD803...D30e3B9bC
0.07143845 MATIC
548383672024-03-19 11:24:0363 days ago1710847443
0xbD0CD803...D30e3B9bC
0.06788754 MATIC
548383532024-03-19 11:23:3563 days ago1710847415
0xbD0CD803...D30e3B9bC
0.07297678 MATIC
548382462024-03-19 11:18:4363 days ago1710847123
0xbD0CD803...D30e3B9bC
0.0531185 MATIC
548382082024-03-19 11:17:2363 days ago1710847043
0xbD0CD803...D30e3B9bC
0.06611929 MATIC
548381922024-03-19 11:16:4963 days ago1710847009
0xbD0CD803...D30e3B9bC
0.07469497 MATIC
548381752024-03-19 11:16:1163 days ago1710846971
0xbD0CD803...D30e3B9bC
0.06085699 MATIC
541757422024-03-02 11:37:2880 days ago1709379448
0xbD0CD803...D30e3B9bC
0.02167963 MATIC
537069352024-02-19 12:42:1192 days ago1708346531
0xbD0CD803...D30e3B9bC
0.04068645 MATIC
537060442024-02-19 12:10:0192 days ago1708344601
0xbD0CD803...D30e3B9bC
0.04313227 MATIC
537060282024-02-19 12:09:2792 days ago1708344567
0xbD0CD803...D30e3B9bC
0.060405 MATIC
537060142024-02-19 12:08:5792 days ago1708344537
0xbD0CD803...D30e3B9bC
0.05313587 MATIC
537059492024-02-19 12:06:3992 days ago1708344399
0xbD0CD803...D30e3B9bC
0.02598163 MATIC
537059322024-02-19 12:06:0392 days ago1708344363
0xbD0CD803...D30e3B9bC
0.04746137 MATIC
537058522024-02-19 12:03:1392 days ago1708344193
0xbD0CD803...D30e3B9bC
0.04951813 MATIC
537058352024-02-19 12:02:3792 days ago1708344157
0xbD0CD803...D30e3B9bC
0.06388188 MATIC
521956582024-01-11 11:03:40131 days ago1704971020
0xbD0CD803...D30e3B9bC
0.03159474 MATIC
521879012024-01-11 6:13:22131 days ago1704953602
0xbD0CD803...D30e3B9bC
0.01199055 MATIC
521878212024-01-11 6:10:28131 days ago1704953428
0xbD0CD803...D30e3B9bC
0.01167247 MATIC
521878082024-01-11 6:09:36131 days ago1704953376
0xbD0CD803...D30e3B9bC
0.01152431 MATIC
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ZapankiRange

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion, GNU GPLv3 license
File 1 of 12 : ZapankiRange.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

import "./common/ZapankiGames.sol";

contract ZapankiRange is ZapankiGames {
    using SafeERC20 for IERC20;

    constructor(
        address _vrfCoordinator,
        IBankroll _bankroll,
        address _trustedForwarder,
        address _link_eth_feed,
        bytes32 _vrfKeyHash,
        uint64 _vrfSubId,
        uint32 _vrfCallbackGasLimit
    )
        ZapankiGames(
            _vrfCoordinator,
            _bankroll,
            _trustedForwarder,
            _link_eth_feed,
            _vrfKeyHash,
            _vrfSubId,
            _vrfCallbackGasLimit
        )
    {}

    struct RangeGame {
        uint256 wager;
        uint256 stopGain;
        uint256 stopLoss;
        uint256 vrfId;
        address tokenAddress;
        uint64 blockNumber;
        uint32 numBets;
        uint32 multiplier;
        bool isOver;
    }

    mapping(address => RangeGame) rangeGames;
    mapping(uint256 => address) vrfPendingPlayer;
    struct RangeFulfilledData {
        address playerAddress;
        uint256 wager;
        uint256 payout;
        address tokenAddress;
        uint32 multiplier;
        bool isOver;
        uint256[] rangeOutcomes;
        uint256[] payouts;
        uint32 numGames;
        uint256 l2eAmount;
    }
    event RangeFulfilled(RangeFulfilledData eventData);
    event RangeRefund(address indexed player, uint256 wager, address tokenAddress);

    function getCurrentUserState(address player) external view returns (RangeGame memory) {
        return (rangeGames[player]);
    }

    function play(
        uint256 wager,
        uint32 multiplier,
        address tokenAddress,
        bool isOver,
        uint32 numBets,
        uint256 stopGain,
        uint256 stopLoss
    ) external payable nonReentrant {
        address msgSender = _msgSender();
        require(10421 <= multiplier && multiplier <= 9900000, "Invalid multiplier");
        require(rangeGames[msgSender].vrfId == 0, "Waiting VRF request");
        require(0 < numBets && numBets <= 100, "Invalid numBets");

        _checkMaxWager(wager, tokenAddress, multiplier);
        _processWager(tokenAddress, wager * numBets, 1000000, msgSender);

        uint256 id = _requestRandomWords(numBets);

        rangeGames[msgSender] = RangeGame(
            wager,
            stopGain,
            stopLoss,
            id,
            tokenAddress,
            uint64(block.number),
            numBets,
            multiplier,
            isOver
        );
        vrfPendingPlayer[id] = msgSender;
    }

    /**
     * @dev Function to refund user in case of VRF request failling
     */
    function refund() external nonReentrant {
        address msgSender = _msgSender();
        RangeGame storage game = rangeGames[msgSender];
        require(rangeGames[msgSender].vrfId != 0, "Not waiting VRF request");
        require(game.blockNumber + BLOCK_REFUND_COOLDOWN + 10 <= block.number, "Too early");

        uint256 wager = game.wager * game.numBets;
        address tokenAddress = game.tokenAddress;

        if (tokenAddress == address(0)) {
            (bool success, ) = payable(msgSender).call{value: wager}("");
            require(success, "Transfer failed");
        } else {
            IERC20(tokenAddress).safeTransfer(msgSender, wager);
        }
        emit RangeRefund(msgSender, wager, tokenAddress);

        delete (vrfPendingPlayer[game.vrfId]);
        delete (rangeGames[msgSender]);
    }

    function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override {
        address playerAddress = vrfPendingPlayer[requestId];
        if (playerAddress == address(0)) return;
        RangeGame storage game = rangeGames[playerAddress];
        if (block.number > game.blockNumber + BLOCK_REFUND_COOLDOWN) return;

        int256 totalValue;
        uint256 payout;
        uint32 gamePlayed;
        uint256[] memory rangeOutcomes = new uint256[](game.numBets);
        uint256[] memory payouts = new uint256[](game.numBets);

        uint256 winChance = 99000000000 / game.multiplier;
        uint256 numberToRollOver = 10000000 - winChance;
        uint256 gamePayout = (game.multiplier * game.wager) / 10000;

        address tokenAddress = game.tokenAddress;

        for (gamePlayed = 0; gamePlayed < game.numBets; gamePlayed++) {
            if (totalValue >= int256(game.stopGain)) {
                break;
            }
            if (totalValue <= -int256(game.stopLoss)) {
                break;
            }

            rangeOutcomes[gamePlayed] = randomWords[gamePlayed] % 10000000;
            if (rangeOutcomes[gamePlayed] >= numberToRollOver && game.isOver == true) {
                totalValue += int256(gamePayout - game.wager);
                payout += gamePayout;
                payouts[gamePlayed] = gamePayout;
                continue;
            }

            if (rangeOutcomes[gamePlayed] <= winChance && game.isOver == false) {
                totalValue += int256(gamePayout - game.wager);
                payout += gamePayout;
                payouts[gamePlayed] = gamePayout;
                continue;
            }

            totalValue -= int256(game.wager);
        }

        payout += (game.numBets - gamePlayed) * game.wager;

        _transferToBankroll(tokenAddress, game.wager * game.numBets);
        if (payout != 0) {
            _payoutBankrollToPlayer(playerAddress, payout, tokenAddress);
        }

        delete (vrfPendingPlayer[requestId]);
        uint256 totalWager = game.wager * game.numBets;
        uint256 l2eAmount = bankroll.payoutL2E(playerAddress, tokenAddress, totalWager, payout);

        RangeFulfilledData memory data = RangeFulfilledData(
            playerAddress,
            game.wager,
            payout,
            tokenAddress,
            game.multiplier,
            game.isOver,
            rangeOutcomes,
            payouts,
            gamePlayed,
            l2eAmount
        );

        emit RangeFulfilled(data);

        delete (rangeGames[playerAddress]);
    }

    /**
     * @dev calculates the maximum wager allowed based on the bankroll size
     */
    function _checkMaxWager(uint256 wager, address tokenAddress, uint256 multiplier) internal view {
        uint256 balance;
        if (tokenAddress == address(0)) {
            balance = address(bankroll).balance;
        } else {
            balance = IERC20(tokenAddress).balanceOf(address(bankroll));
        }
        uint256 maxWager = (balance * (11000 - 10890)) / (multiplier - 10000);
        require(wager <= maxWager, "Too many wager");
    }
}

File 1 of 12 : AggregatorV3Interface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface AggregatorV3Interface {
  function decimals() external view returns (uint8);

  function description() external view returns (string memory);

  function version() external view returns (uint256);

  function getRoundData(
    uint80 _roundId
  ) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

  function latestRoundData()
    external
    view
    returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}

File 1 of 12 : 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 1 of 12 : 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 1 of 12 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

File 1 of 12 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 1 of 12 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

File 1 of 12 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

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

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

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

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

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}

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

import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol";
import "@chainlink/contracts/src/v0.8/vrf/VRFConsumerBaseV2.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {SafeERC20, IERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../../../interfaces/IVRFCoordinator.sol";
import "../../../interfaces/IBankroll.sol";

abstract contract ZapankiGames is ReentrancyGuard, VRFConsumerBaseV2 {
    using SafeERC20 for IERC20;

    AggregatorV3Interface public LINK_ETH_FEED;
    IVRFCoordinatorV2 public vrfCoordinator;
    IBankroll public bankroll;
    address public trustedForwarder;

    bytes32 vrfKeyHash;
    uint256 public claimableVRFFee;
    uint64 constant BLOCK_REFUND_COOLDOWN = 1000;
    uint64 vrfSubId;
    uint32 vrfCallbackGasLimit;

    modifier onlyOwner() {
        require(msg.sender == bankroll.owner(), "Not Owner");
        _;
    }

    constructor(
        address _vrfCoordinator,
        IBankroll _bankroll,
        address _trustedForwarder,
        address _link_eth_feed,
        bytes32 _vrfKeyHash,
        uint64 _vrfSubId,
        uint32 _vrfCallbackGasLimit
    ) VRFConsumerBaseV2(_vrfCoordinator) {
        vrfCoordinator = IVRFCoordinatorV2(_vrfCoordinator);
        bankroll = _bankroll;
        LINK_ETH_FEED = AggregatorV3Interface(_link_eth_feed);
        vrfKeyHash = _vrfKeyHash;
        vrfSubId = _vrfSubId;
        vrfCallbackGasLimit = _vrfCallbackGasLimit;
        trustedForwarder = _trustedForwarder;
    }

    function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
        return forwarder == trustedForwarder;
    }

    function _msgSender() internal view returns (address sender) {
        if (isTrustedForwarder(msg.sender)) {
            // The assembly code is more direct than the Solidity version using `abi.decode`.
            /// @solidity memory-safe-assembly
            assembly {
                sender := shr(96, calldataload(sub(calldatasize(), 20)))
            }
        } else {
            return msg.sender;
        }
    }

    function _shouldStop(int256 value, uint256 stopGain, uint256 stopLoss) internal pure returns (bool) {
        return value >= int256(stopGain) || value <= -int256(stopLoss);
    }

    function _processWager(address tokenAddress, uint256 wager, uint256 gasAmount, address msgSender) internal {
        require(bankroll.getIsValidWager(address(this), tokenAddress), "Token not approved");
        require(wager != 0, "Wager must be greater than 0");
        if (tokenAddress == address(0)) {
            _chargeVRFFee(msg.value - wager, gasAmount);
        } else {
            _chargeVRFFee(msg.value, gasAmount);
            IERC20(tokenAddress).safeTransferFrom(msgSender, address(this), wager);
        }
    }

    function _transferToBankroll(address tokenAddress, uint256 amount) internal {
        if (tokenAddress == address(0)) {
            (bool success, ) = payable(address(bankroll)).call{value: amount}("");
            require(success, "refund failed");
        } else {
            IERC20(tokenAddress).safeTransfer(address(bankroll), amount);
        }
    }

    function getVRFFee(uint256 gasAmount) public view returns (uint256 fee) {
        (, int256 answer, , , ) = LINK_ETH_FEED.latestRoundData();
        (uint32 fulfillmentFlatFeeLinkPPMTier1, , , , , , , , ) = vrfCoordinator.getFeeConfig();

        fee = tx.gasprice * (gasAmount) + ((1e12 * uint256(fulfillmentFlatFeeLinkPPMTier1) * uint256(answer)) / 1e18);
    }

    function _refundVRFFee(uint256 refundableAmount) internal {
        if (refundableAmount > 0) {
            (bool success, ) = payable(msg.sender).call{value: refundableAmount}("");
            require(success, "refund failed");
        }
    }

    function _chargeVRFFee(uint256 vrfFeeProvided, uint256 gasAmount) internal {
        uint256 _vrfFee = getVRFFee(gasAmount);
        require(vrfFeeProvided >= _vrfFee, "Insufficient vrf fee");
        _refundVRFFee(vrfFeeProvided - _vrfFee);
        claimableVRFFee += _vrfFee;
    }

    function collectVrfFee() external nonReentrant onlyOwner {
        uint256 fee = claimableVRFFee;
        claimableVRFFee = 0;
        (bool success, ) = payable(address(msg.sender)).call{value: fee}("");
        require(success, "transfer failed");
    }

    function _payoutBankrollToPlayer(address player, uint256 payout, address tokenAddress) internal {
        bankroll.transferPayout(player, payout, tokenAddress);
    }

    function _requestRandomWords(uint32 numWords) internal returns (uint256 s_requestId) {
        s_requestId = vrfCoordinator.requestRandomWords(vrfKeyHash, vrfSubId, 3, vrfCallbackGasLimit, numWords);
    }
}

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

interface IBankroll {
    function getIsGame(address game) external view returns (bool);

    function getIsValidWager(address game, address tokenAddress) external view returns (bool);

    function transferPayout(address player, uint256 payout, address token) external;

    function owner() external view returns (address);

    function payoutL2E(
        address player,
        address wagerToken,
        uint256 wager,
        uint256 payout
    ) external returns (uint256 l2eAmount);
}

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

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

interface IVRFCoordinatorV2 is VRFCoordinatorV2Interface {
    function getFeeConfig()
        external
        view
        returns (uint32, uint32, uint32, uint32, uint32, uint24, uint24, uint24, uint24);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_vrfCoordinator","type":"address"},{"internalType":"contract IBankroll","name":"_bankroll","type":"address"},{"internalType":"address","name":"_trustedForwarder","type":"address"},{"internalType":"address","name":"_link_eth_feed","type":"address"},{"internalType":"bytes32","name":"_vrfKeyHash","type":"bytes32"},{"internalType":"uint64","name":"_vrfSubId","type":"uint64"},{"internalType":"uint32","name":"_vrfCallbackGasLimit","type":"uint32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"playerAddress","type":"address"},{"internalType":"uint256","name":"wager","type":"uint256"},{"internalType":"uint256","name":"payout","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint32","name":"multiplier","type":"uint32"},{"internalType":"bool","name":"isOver","type":"bool"},{"internalType":"uint256[]","name":"rangeOutcomes","type":"uint256[]"},{"internalType":"uint256[]","name":"payouts","type":"uint256[]"},{"internalType":"uint32","name":"numGames","type":"uint32"},{"internalType":"uint256","name":"l2eAmount","type":"uint256"}],"indexed":false,"internalType":"struct ZapankiRange.RangeFulfilledData","name":"eventData","type":"tuple"}],"name":"RangeFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"wager","type":"uint256"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"}],"name":"RangeRefund","type":"event"},{"inputs":[],"name":"LINK_ETH_FEED","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bankroll","outputs":[{"internalType":"contract IBankroll","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimableVRFFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collectVrfFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"getCurrentUserState","outputs":[{"components":[{"internalType":"uint256","name":"wager","type":"uint256"},{"internalType":"uint256","name":"stopGain","type":"uint256"},{"internalType":"uint256","name":"stopLoss","type":"uint256"},{"internalType":"uint256","name":"vrfId","type":"uint256"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint64","name":"blockNumber","type":"uint64"},{"internalType":"uint32","name":"numBets","type":"uint32"},{"internalType":"uint32","name":"multiplier","type":"uint32"},{"internalType":"bool","name":"isOver","type":"bool"}],"internalType":"struct ZapankiRange.RangeGame","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gasAmount","type":"uint256"}],"name":"getVRFFee","outputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"wager","type":"uint256"},{"internalType":"uint32","name":"multiplier","type":"uint32"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"bool","name":"isOver","type":"bool"},{"internalType":"uint32","name":"numBets","type":"uint32"},{"internalType":"uint256","name":"stopGain","type":"uint256"},{"internalType":"uint256","name":"stopLoss","type":"uint256"}],"name":"play","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"refund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfCoordinator","outputs":[{"internalType":"contract IVRFCoordinatorV2","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60a06040523480156200001157600080fd5b5060405162002252380380620022528339810160408190526200003491620000ea565b600160008190556001600160a01b039788166080819052600280546001600160a01b0319908116909217905560038054988a16988216989098179097558054948816948716949094179093556005919091556007805463ffffffff90931668010000000000000000026001600160601b03199093166001600160401b0390921691909117919091179055600480549190931691161790556200019c565b6001600160a01b0381168114620000e757600080fd5b50565b600080600080600080600060e0888a0312156200010657600080fd5b87516200011381620000d1565b60208901519097506200012681620000d1565b60408901519096506200013981620000d1565b60608901519095506200014c81620000d1565b608089015160a08a015191955093506001600160401b03811681146200017157600080fd5b60c089015190925063ffffffff811681146200018c57600080fd5b8091505092959891949750929550565b608051612093620001bf6000396000818161068601526106c801526120936000f3fe6080604052600436106100a75760003560e01c806376fca03d1161006457806376fca03d146101875780637da0a877146102a057806380cfa527146102c05780638bd16114146102e4578063a3e56fa814610304578063ad1783611461032457600080fd5b80630c657eb0146100ac5780631f330218146100e95780631fe543e3146100fe578063572b6c051461011e578063590e1ae31461015d57806374b0a78914610172575b600080fd5b3480156100b857600080fd5b506003546100cc906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100fc6100f73660046119e0565b610344565b005b34801561010a57600080fd5b506100fc610119366004611a70565b61067b565b34801561012a57600080fd5b5061014d610139366004611b39565b6004546001600160a01b0391821691161490565b60405190151581526020016100e0565b34801561016957600080fd5b506100fc610703565b34801561017e57600080fd5b506100fc610992565b34801561019357600080fd5b506102936101a2366004611b39565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810191909152506001600160a01b03908116600090815260086020908152604091829020825161012081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201549283166080820152600160a01b83046001600160401b031660a0820152600160e01b90920463ffffffff90811660c084015260059091015490811660e0830152640100000000900460ff16151561010082015290565b6040516100e09190611b56565b3480156102ac57600080fd5b506004546100cc906001600160a01b031681565b3480156102cc57600080fd5b506102d660065481565b6040519081526020016100e0565b3480156102f057600080fd5b506102d66102ff366004611bed565b610afd565b34801561031057600080fd5b506002546100cc906001600160a01b031681565b34801561033057600080fd5b506001546100cc906001600160a01b031681565b61034c610c52565b6000610356610c7c565b90508663ffffffff166128b511158015610379575062970fe08763ffffffff1611155b6103bf5760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21036bab63a34b83634b2b960711b60448201526064015b60405180910390fd5b6001600160a01b0381166000908152600860205260409020600301541561041e5760405162461bcd60e51b815260206004820152601360248201527215d85a5d1a5b99c8159491881c995c5d595cdd606a1b60448201526064016103b6565b8363ffffffff16600010801561043b575060648463ffffffff1611155b6104795760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206e756d4265747360881b60448201526064016103b6565b61048a88878963ffffffff16610ca3565b6104a88661049e63ffffffff87168b611c1c565b620f424084610da4565b60006104b385610ef4565b90506040518061012001604052808a8152602001858152602001848152602001828152602001886001600160a01b03168152602001436001600160401b031681526020018663ffffffff1681526020018963ffffffff16815260200187151581525060086000846001600160a01b03166001600160a01b031681526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a08201518160040160146101000a8154816001600160401b0302191690836001600160401b0316021790555060c082015181600401601c6101000a81548163ffffffff021916908363ffffffff16021790555060e08201518160050160006101000a81548163ffffffff021916908363ffffffff1602179055506101008201518160050160046101000a81548160ff021916908315150217905550905050816009600083815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555050506106726001600055565b50505050505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146106f55760405163073e64fd60e21b81523360048201526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001660248201526044016103b6565b6106ff8282610fa7565b5050565b61070b610c52565b6000610715610c7c565b6001600160a01b038116600090815260086020526040812060038101549293509190036107845760405162461bcd60e51b815260206004820152601760248201527f4e6f742077616974696e6720565246207265717565737400000000000000000060448201526064016103b6565b600481015443906107a8906103e890600160a01b90046001600160401b0316611c33565b6107b390600a611c33565b6001600160401b031611156107f65760405162461bcd60e51b8152602060048201526009602482015268546f6f206561726c7960b81b60448201526064016103b6565b6004810154815460009161081891600160e01b90910463ffffffff1690611c1c565b60048301549091506001600160a01b0316806108c9576000846001600160a01b03168360405160006040518083038185875af1925050503d806000811461087b576040519150601f19603f3d011682016040523d82523d6000602084013e610880565b606091505b50509050806108c35760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b60448201526064016103b6565b506108dd565b6108dd6001600160a01b038216858461153c565b604080518381526001600160a01b0383811660208301528616917f97708e28150f34c8526fef7a5eb506b2b08e2e667a559124edb8697980df604f910160405180910390a25050600390810154600090815260096020908152604080832080546001600160a01b03191690556001600160a01b039490941682526008905291822082815560018181018490556002820184905591810183905560048101839055600501805464ffffffffff191690559055565b565b61099a610c52565b600360009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a119190611c5a565b6001600160a01b0316336001600160a01b031614610a5d5760405162461bcd60e51b81526020600482015260096024820152682737ba1027bbb732b960b91b60448201526064016103b6565b60068054600091829055604051909190339083908381818185875af1925050503d8060008114610aa9576040519150601f19603f3d011682016040523d82523d6000602084013e610aae565b606091505b5050905080610af15760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016103b6565b50506109906001600055565b600080600160009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610b53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b779190611c96565b5050509150506000600260009054906101000a90046001600160a01b03166001600160a01b0316635fbbc0d26040518163ffffffff1660e01b815260040161012060405180830381865afa158015610bd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf79190611cf9565b50505050505050509050670de0b6b3a7640000828263ffffffff1664e8d4a51000610c229190611c1c565b610c2c9190611c1c565b610c369190611dc5565b610c40853a611c1c565b610c4a9190611dd9565b949350505050565b600260005403610c7557604051633ee5aeb560e01b815260040160405180910390fd5b6002600055565b6004546000906001600160a01b03163303610c9e575060131936013560601c90565b503390565b60006001600160a01b038316610cc657506003546001600160a01b031631610d37565b6003546040516370a0823160e01b81526001600160a01b039182166004820152908416906370a0823190602401602060405180830381865afa158015610d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d349190611dec565b90505b6000610d4561271084611e05565b610d5083606e611c1c565b610d5a9190611dc5565b905080851115610d9d5760405162461bcd60e51b815260206004820152600e60248201526d2a37b79036b0b73c903bb0b3b2b960911b60448201526064016103b6565b5050505050565b600354604051632ff5fe7360e21b81523060048201526001600160a01b0386811660248301529091169063bfd7f9cc90604401602060405180830381865afa158015610df4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e189190611e18565b610e595760405162461bcd60e51b8152602060048201526012602482015271151bdad95b881b9bdd08185c1c1c9bdd995960721b60448201526064016103b6565b82600003610ea95760405162461bcd60e51b815260206004820152601c60248201527f5761676572206d7573742062652067726561746572207468616e20300000000060448201526064016103b6565b6001600160a01b038416610ecf57610eca610ec48434611e05565b836115a0565b610eee565b610ed934836115a0565b610eee6001600160a01b038516823086611622565b50505050565b6002546005546007546040516305d3b1d360e41b815260048101929092526001600160401b03811660248301526003604483015268010000000000000000900463ffffffff9081166064830152831660848201526000916001600160a01b031690635d3b1d309060a4016020604051808303816000875af1158015610f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa19190611dec565b92915050565b6000828152600960205260409020546001600160a01b031680610fc957505050565b6001600160a01b03811660009081526008602052604090206004810154611003906103e890600160a01b90046001600160401b0316611c33565b6001600160401b03164311156110195750505050565b6004810154600090819081908190600160e01b900463ffffffff166001600160401b0381111561104b5761104b611a5a565b604051908082528060200260200182016040528015611074578160200160208202803683370190505b506004860154909150600090600160e01b900463ffffffff166001600160401b038111156110a4576110a4611a5a565b6040519080825280602002602001820160405280156110cd578160200160208202803683370190505b5060058701549091506000906110ee9063ffffffff1664170cdc1e00611e35565b64ffffffffff16905060006111068262989680611e05565b885460058a0154919250600091612710916111269163ffffffff16611c1c565b6111309190611dc5565b60048a0154600097509091506001600160a01b03165b60048a015463ffffffff600160e01b909104811690881610156112d75789600101548912156112d757896002015461117d90611e59565b8913156112d757629896808c8863ffffffff16815181106111a0576111a0611e75565b60200260200101516111b29190611e8b565b868863ffffffff16815181106111ca576111ca611e75565b60200260200101818152505082868863ffffffff16815181106111ef576111ef611e75565b602002602001015110158015611216575060058a0154640100000000900460ff1615156001145b156112695789546112279083611e05565b611231908a611e9f565b985061123d8289611dd9565b975081858863ffffffff168151811061125857611258611e75565b6020026020010181815250506112c5565b83868863ffffffff168151811061128257611282611e75565b6020026020010151111580156112a5575060058a0154640100000000900460ff16155b156112b65789546112279083611e05565b89546112c2908a611ebf565b98505b866112cf81611edf565b975050611146565b895460048b01546112f6908990600160e01b900463ffffffff16611f02565b63ffffffff166113069190611c1c565b6113109089611dd9565b60048b01548b5491995061133d91839161133891600160e01b90910463ffffffff1690611c1c565b61165b565b871561134e5761134e8b8983611716565b60008d815260096020526040812080546001600160a01b031916905560048b01548b5461138891600160e01b900463ffffffff1690611c1c565b60035460405160016292610160e01b031981526001600160a01b038f81166004830152858116602483015260448201849052606482018d90529293506000929091169063ff6d9eff906084016020604051808303816000875af11580156113f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114179190611dec565b905060006040518061014001604052808f6001600160a01b031681526020018e6000015481526020018c8152602001856001600160a01b031681526020018e60050160009054906101000a900463ffffffff1663ffffffff1681526020018e60050160049054906101000a900460ff16151581526020018a81526020018981526020018b63ffffffff1681526020018381525090507f8796220875a792521dbd0c98d237f91e8d7f59f8a477af4d30995874aef93be8816040516114db9190611f5a565b60405180910390a15050506001600160a01b03909a1660009081526008602052604081208181556001810182905560028101829055600381018290556004810191909155600501805464ffffffffff19169055505050505050505050505050565b6040516001600160a01b0383811660248301526044820183905261159b91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611780565b505050565b60006115ab82610afd565b9050808310156115f45760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e74207672662066656560601b60448201526064016103b6565b6116066116018285611e05565b6117e3565b80600660008282546116189190611dd9565b9091555050505050565b6040516001600160a01b038481166024830152838116604483015260648201839052610eee9186918216906323b872dd90608401611569565b6001600160a01b0382166116fc576003546040516000916001600160a01b03169083908381818185875af1925050503d80600081146116b6576040519150601f19603f3d011682016040523d82523d6000602084013e6116bb565b606091505b505090508061159b5760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b60448201526064016103b6565b6003546106ff906001600160a01b0384811691168361153c565b6003546040516336012f6160e11b81526001600160a01b03858116600483015260248201859052838116604483015290911690636c025ec290606401600060405180830381600087803b15801561176c57600080fd5b505af1158015610672573d6000803e3d6000fd5b60006117956001600160a01b03841683611874565b905080516000141580156117ba5750808060200190518101906117b89190611e18565b155b1561159b57604051635274afe760e01b81526001600160a01b03841660048201526024016103b6565b801561187157604051600090339083908381818185875af1925050503d806000811461182b576040519150601f19603f3d011682016040523d82523d6000602084013e611830565b606091505b50509050806106ff5760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b60448201526064016103b6565b50565b606061188283836000611889565b9392505050565b6060814710156118ae5760405163cd78605960e01b81523060048201526024016103b6565b600080856001600160a01b031684866040516118ca919061202e565b60006040518083038185875af1925050503d8060008114611907576040519150601f19603f3d011682016040523d82523d6000602084013e61190c565b606091505b509150915061191c868383611926565b9695505050505050565b60608261193b5761193682611982565b611882565b815115801561195257506001600160a01b0384163b155b1561197b57604051639996b31560e01b81526001600160a01b03851660048201526024016103b6565b5080611882565b8051156119925780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b63ffffffff8116811461187157600080fd5b6001600160a01b038116811461187157600080fd5b801515811461187157600080fd5b600080600080600080600060e0888a0312156119fb57600080fd5b873596506020880135611a0d816119ab565b95506040880135611a1d816119bd565b94506060880135611a2d816119d2565b93506080880135611a3d816119ab565b9699959850939692959460a0840135945060c09093013592915050565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215611a8357600080fd5b823591506020808401356001600160401b0380821115611aa257600080fd5b818601915086601f830112611ab657600080fd5b813581811115611ac857611ac8611a5a565b8060051b604051601f19603f83011681018181108582111715611aed57611aed611a5a565b604052918252848201925083810185019189831115611b0b57600080fd5b938501935b82851015611b2957843584529385019392850192611b10565b8096505050505050509250929050565b600060208284031215611b4b57600080fd5b8135611882816119bd565b6000610120820190508251825260208301516020830152604083015160408301526060830151606083015260018060a01b0360808401511660808301526001600160401b0360a08401511660a083015260c0830151611bbd60c084018263ffffffff169052565b5060e0830151611bd560e084018263ffffffff169052565b5061010083810151801515848301525b505092915050565b600060208284031215611bff57600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610fa157610fa1611c06565b6001600160401b03818116838216019080821115611c5357611c53611c06565b5092915050565b600060208284031215611c6c57600080fd5b8151611882816119bd565b805169ffffffffffffffffffff81168114611c9157600080fd5b919050565b600080600080600060a08688031215611cae57600080fd5b611cb786611c77565b9450602086015193506040860151925060608601519150611cda60808701611c77565b90509295509295909350565b805162ffffff81168114611c9157600080fd5b60008060008060008060008060006101208a8c031215611d1857600080fd5b8951611d23816119ab565b60208b0151909950611d34816119ab565b60408b0151909850611d45816119ab565b60608b0151909750611d56816119ab565b60808b0151909650611d67816119ab565b9450611d7560a08b01611ce6565b9350611d8360c08b01611ce6565b9250611d9160e08b01611ce6565b9150611da06101008b01611ce6565b90509295985092959850929598565b634e487b7160e01b600052601260045260246000fd5b600082611dd457611dd4611daf565b500490565b80820180821115610fa157610fa1611c06565b600060208284031215611dfe57600080fd5b5051919050565b81810381811115610fa157610fa1611c06565b600060208284031215611e2a57600080fd5b8151611882816119d2565b600064ffffffffff80841680611e4d57611e4d611daf565b92169190910492915050565b6000600160ff1b8201611e6e57611e6e611c06565b5060000390565b634e487b7160e01b600052603260045260246000fd5b600082611e9a57611e9a611daf565b500690565b8082018281126000831280158216821582161715611be557611be5611c06565b8181036000831280158383131683831282161715611c5357611c53611c06565b600063ffffffff808316818103611ef857611ef8611c06565b6001019392505050565b63ffffffff828116828216039080821115611c5357611c53611c06565b600081518084526020808501945080840160005b83811015611f4f57815187529582019590820190600101611f33565b509495945050505050565b60208152611f746020820183516001600160a01b03169052565b602082015160408201526040820151606082015260006060830151611fa460808401826001600160a01b03169052565b50608083015163ffffffff811660a08401525060a083015180151560c08401525060c08301516101408060e0850152611fe1610160850183611f1f565b915060e0850151610100601f1986850301818701526120008483611f1f565b93508087015191505061012061201d8187018363ffffffff169052565b959095015193019290925250919050565b6000825160005b8181101561204f5760208186018101518583015201612035565b50600092019182525091905056fea264697066735822122066df6adf77159c670133f65f239d7de922018c2561dd539ffe720c80199eac7964736f6c63430008140033000000000000000000000000ae975071be8f8ee67addbc1a82488f1c2485806700000000000000000000000041cb3a2e51635f680acf3e6c043498782a4f37a500000000000000000000000041cb3a2e51635f680acf3e6c043498782a4f37a50000000000000000000000005787befdc0ecd210dfa948264631cd53e68f7802d729dc84e21ae57ffb6be0053bf2b0668aa2aaf300a2a7b2ddf7dc0bb6e875a8000000000000000000000000000000000000000000000000000000000000038e00000000000000000000000000000000000000000000000000000000002625a0

Deployed Bytecode

0x6080604052600436106100a75760003560e01c806376fca03d1161006457806376fca03d146101875780637da0a877146102a057806380cfa527146102c05780638bd16114146102e4578063a3e56fa814610304578063ad1783611461032457600080fd5b80630c657eb0146100ac5780631f330218146100e95780631fe543e3146100fe578063572b6c051461011e578063590e1ae31461015d57806374b0a78914610172575b600080fd5b3480156100b857600080fd5b506003546100cc906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b6100fc6100f73660046119e0565b610344565b005b34801561010a57600080fd5b506100fc610119366004611a70565b61067b565b34801561012a57600080fd5b5061014d610139366004611b39565b6004546001600160a01b0391821691161490565b60405190151581526020016100e0565b34801561016957600080fd5b506100fc610703565b34801561017e57600080fd5b506100fc610992565b34801561019357600080fd5b506102936101a2366004611b39565b6040805161012081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810191909152506001600160a01b03908116600090815260086020908152604091829020825161012081018452815481526001820154928101929092526002810154928201929092526003820154606082015260048201549283166080820152600160a01b83046001600160401b031660a0820152600160e01b90920463ffffffff90811660c084015260059091015490811660e0830152640100000000900460ff16151561010082015290565b6040516100e09190611b56565b3480156102ac57600080fd5b506004546100cc906001600160a01b031681565b3480156102cc57600080fd5b506102d660065481565b6040519081526020016100e0565b3480156102f057600080fd5b506102d66102ff366004611bed565b610afd565b34801561031057600080fd5b506002546100cc906001600160a01b031681565b34801561033057600080fd5b506001546100cc906001600160a01b031681565b61034c610c52565b6000610356610c7c565b90508663ffffffff166128b511158015610379575062970fe08763ffffffff1611155b6103bf5760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21036bab63a34b83634b2b960711b60448201526064015b60405180910390fd5b6001600160a01b0381166000908152600860205260409020600301541561041e5760405162461bcd60e51b815260206004820152601360248201527215d85a5d1a5b99c8159491881c995c5d595cdd606a1b60448201526064016103b6565b8363ffffffff16600010801561043b575060648463ffffffff1611155b6104795760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206e756d4265747360881b60448201526064016103b6565b61048a88878963ffffffff16610ca3565b6104a88661049e63ffffffff87168b611c1c565b620f424084610da4565b60006104b385610ef4565b90506040518061012001604052808a8152602001858152602001848152602001828152602001886001600160a01b03168152602001436001600160401b031681526020018663ffffffff1681526020018963ffffffff16815260200187151581525060086000846001600160a01b03166001600160a01b031681526020019081526020016000206000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a08201518160040160146101000a8154816001600160401b0302191690836001600160401b0316021790555060c082015181600401601c6101000a81548163ffffffff021916908363ffffffff16021790555060e08201518160050160006101000a81548163ffffffff021916908363ffffffff1602179055506101008201518160050160046101000a81548160ff021916908315150217905550905050816009600083815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b0316021790555050506106726001600055565b50505050505050565b336001600160a01b037f000000000000000000000000ae975071be8f8ee67addbc1a82488f1c2485806716146106f55760405163073e64fd60e21b81523360048201526001600160a01b037f000000000000000000000000ae975071be8f8ee67addbc1a82488f1c248580671660248201526044016103b6565b6106ff8282610fa7565b5050565b61070b610c52565b6000610715610c7c565b6001600160a01b038116600090815260086020526040812060038101549293509190036107845760405162461bcd60e51b815260206004820152601760248201527f4e6f742077616974696e6720565246207265717565737400000000000000000060448201526064016103b6565b600481015443906107a8906103e890600160a01b90046001600160401b0316611c33565b6107b390600a611c33565b6001600160401b031611156107f65760405162461bcd60e51b8152602060048201526009602482015268546f6f206561726c7960b81b60448201526064016103b6565b6004810154815460009161081891600160e01b90910463ffffffff1690611c1c565b60048301549091506001600160a01b0316806108c9576000846001600160a01b03168360405160006040518083038185875af1925050503d806000811461087b576040519150601f19603f3d011682016040523d82523d6000602084013e610880565b606091505b50509050806108c35760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b60448201526064016103b6565b506108dd565b6108dd6001600160a01b038216858461153c565b604080518381526001600160a01b0383811660208301528616917f97708e28150f34c8526fef7a5eb506b2b08e2e667a559124edb8697980df604f910160405180910390a25050600390810154600090815260096020908152604080832080546001600160a01b03191690556001600160a01b039490941682526008905291822082815560018181018490556002820184905591810183905560048101839055600501805464ffffffffff191690559055565b565b61099a610c52565b600360009054906101000a90046001600160a01b03166001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a119190611c5a565b6001600160a01b0316336001600160a01b031614610a5d5760405162461bcd60e51b81526020600482015260096024820152682737ba1027bbb732b960b91b60448201526064016103b6565b60068054600091829055604051909190339083908381818185875af1925050503d8060008114610aa9576040519150601f19603f3d011682016040523d82523d6000602084013e610aae565b606091505b5050905080610af15760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016103b6565b50506109906001600055565b600080600160009054906101000a90046001600160a01b03166001600160a01b031663feaf968c6040518163ffffffff1660e01b815260040160a060405180830381865afa158015610b53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b779190611c96565b5050509150506000600260009054906101000a90046001600160a01b03166001600160a01b0316635fbbc0d26040518163ffffffff1660e01b815260040161012060405180830381865afa158015610bd3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf79190611cf9565b50505050505050509050670de0b6b3a7640000828263ffffffff1664e8d4a51000610c229190611c1c565b610c2c9190611c1c565b610c369190611dc5565b610c40853a611c1c565b610c4a9190611dd9565b949350505050565b600260005403610c7557604051633ee5aeb560e01b815260040160405180910390fd5b6002600055565b6004546000906001600160a01b03163303610c9e575060131936013560601c90565b503390565b60006001600160a01b038316610cc657506003546001600160a01b031631610d37565b6003546040516370a0823160e01b81526001600160a01b039182166004820152908416906370a0823190602401602060405180830381865afa158015610d10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d349190611dec565b90505b6000610d4561271084611e05565b610d5083606e611c1c565b610d5a9190611dc5565b905080851115610d9d5760405162461bcd60e51b815260206004820152600e60248201526d2a37b79036b0b73c903bb0b3b2b960911b60448201526064016103b6565b5050505050565b600354604051632ff5fe7360e21b81523060048201526001600160a01b0386811660248301529091169063bfd7f9cc90604401602060405180830381865afa158015610df4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e189190611e18565b610e595760405162461bcd60e51b8152602060048201526012602482015271151bdad95b881b9bdd08185c1c1c9bdd995960721b60448201526064016103b6565b82600003610ea95760405162461bcd60e51b815260206004820152601c60248201527f5761676572206d7573742062652067726561746572207468616e20300000000060448201526064016103b6565b6001600160a01b038416610ecf57610eca610ec48434611e05565b836115a0565b610eee565b610ed934836115a0565b610eee6001600160a01b038516823086611622565b50505050565b6002546005546007546040516305d3b1d360e41b815260048101929092526001600160401b03811660248301526003604483015268010000000000000000900463ffffffff9081166064830152831660848201526000916001600160a01b031690635d3b1d309060a4016020604051808303816000875af1158015610f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fa19190611dec565b92915050565b6000828152600960205260409020546001600160a01b031680610fc957505050565b6001600160a01b03811660009081526008602052604090206004810154611003906103e890600160a01b90046001600160401b0316611c33565b6001600160401b03164311156110195750505050565b6004810154600090819081908190600160e01b900463ffffffff166001600160401b0381111561104b5761104b611a5a565b604051908082528060200260200182016040528015611074578160200160208202803683370190505b506004860154909150600090600160e01b900463ffffffff166001600160401b038111156110a4576110a4611a5a565b6040519080825280602002602001820160405280156110cd578160200160208202803683370190505b5060058701549091506000906110ee9063ffffffff1664170cdc1e00611e35565b64ffffffffff16905060006111068262989680611e05565b885460058a0154919250600091612710916111269163ffffffff16611c1c565b6111309190611dc5565b60048a0154600097509091506001600160a01b03165b60048a015463ffffffff600160e01b909104811690881610156112d75789600101548912156112d757896002015461117d90611e59565b8913156112d757629896808c8863ffffffff16815181106111a0576111a0611e75565b60200260200101516111b29190611e8b565b868863ffffffff16815181106111ca576111ca611e75565b60200260200101818152505082868863ffffffff16815181106111ef576111ef611e75565b602002602001015110158015611216575060058a0154640100000000900460ff1615156001145b156112695789546112279083611e05565b611231908a611e9f565b985061123d8289611dd9565b975081858863ffffffff168151811061125857611258611e75565b6020026020010181815250506112c5565b83868863ffffffff168151811061128257611282611e75565b6020026020010151111580156112a5575060058a0154640100000000900460ff16155b156112b65789546112279083611e05565b89546112c2908a611ebf565b98505b866112cf81611edf565b975050611146565b895460048b01546112f6908990600160e01b900463ffffffff16611f02565b63ffffffff166113069190611c1c565b6113109089611dd9565b60048b01548b5491995061133d91839161133891600160e01b90910463ffffffff1690611c1c565b61165b565b871561134e5761134e8b8983611716565b60008d815260096020526040812080546001600160a01b031916905560048b01548b5461138891600160e01b900463ffffffff1690611c1c565b60035460405160016292610160e01b031981526001600160a01b038f81166004830152858116602483015260448201849052606482018d90529293506000929091169063ff6d9eff906084016020604051808303816000875af11580156113f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114179190611dec565b905060006040518061014001604052808f6001600160a01b031681526020018e6000015481526020018c8152602001856001600160a01b031681526020018e60050160009054906101000a900463ffffffff1663ffffffff1681526020018e60050160049054906101000a900460ff16151581526020018a81526020018981526020018b63ffffffff1681526020018381525090507f8796220875a792521dbd0c98d237f91e8d7f59f8a477af4d30995874aef93be8816040516114db9190611f5a565b60405180910390a15050506001600160a01b03909a1660009081526008602052604081208181556001810182905560028101829055600381018290556004810191909155600501805464ffffffffff19169055505050505050505050505050565b6040516001600160a01b0383811660248301526044820183905261159b91859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611780565b505050565b60006115ab82610afd565b9050808310156115f45760405162461bcd60e51b8152602060048201526014602482015273496e73756666696369656e74207672662066656560601b60448201526064016103b6565b6116066116018285611e05565b6117e3565b80600660008282546116189190611dd9565b9091555050505050565b6040516001600160a01b038481166024830152838116604483015260648201839052610eee9186918216906323b872dd90608401611569565b6001600160a01b0382166116fc576003546040516000916001600160a01b03169083908381818185875af1925050503d80600081146116b6576040519150601f19603f3d011682016040523d82523d6000602084013e6116bb565b606091505b505090508061159b5760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b60448201526064016103b6565b6003546106ff906001600160a01b0384811691168361153c565b6003546040516336012f6160e11b81526001600160a01b03858116600483015260248201859052838116604483015290911690636c025ec290606401600060405180830381600087803b15801561176c57600080fd5b505af1158015610672573d6000803e3d6000fd5b60006117956001600160a01b03841683611874565b905080516000141580156117ba5750808060200190518101906117b89190611e18565b155b1561159b57604051635274afe760e01b81526001600160a01b03841660048201526024016103b6565b801561187157604051600090339083908381818185875af1925050503d806000811461182b576040519150601f19603f3d011682016040523d82523d6000602084013e611830565b606091505b50509050806106ff5760405162461bcd60e51b815260206004820152600d60248201526c1c99599d5b990819985a5b1959609a1b60448201526064016103b6565b50565b606061188283836000611889565b9392505050565b6060814710156118ae5760405163cd78605960e01b81523060048201526024016103b6565b600080856001600160a01b031684866040516118ca919061202e565b60006040518083038185875af1925050503d8060008114611907576040519150601f19603f3d011682016040523d82523d6000602084013e61190c565b606091505b509150915061191c868383611926565b9695505050505050565b60608261193b5761193682611982565b611882565b815115801561195257506001600160a01b0384163b155b1561197b57604051639996b31560e01b81526001600160a01b03851660048201526024016103b6565b5080611882565b8051156119925780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b63ffffffff8116811461187157600080fd5b6001600160a01b038116811461187157600080fd5b801515811461187157600080fd5b600080600080600080600060e0888a0312156119fb57600080fd5b873596506020880135611a0d816119ab565b95506040880135611a1d816119bd565b94506060880135611a2d816119d2565b93506080880135611a3d816119ab565b9699959850939692959460a0840135945060c09093013592915050565b634e487b7160e01b600052604160045260246000fd5b60008060408385031215611a8357600080fd5b823591506020808401356001600160401b0380821115611aa257600080fd5b818601915086601f830112611ab657600080fd5b813581811115611ac857611ac8611a5a565b8060051b604051601f19603f83011681018181108582111715611aed57611aed611a5a565b604052918252848201925083810185019189831115611b0b57600080fd5b938501935b82851015611b2957843584529385019392850192611b10565b8096505050505050509250929050565b600060208284031215611b4b57600080fd5b8135611882816119bd565b6000610120820190508251825260208301516020830152604083015160408301526060830151606083015260018060a01b0360808401511660808301526001600160401b0360a08401511660a083015260c0830151611bbd60c084018263ffffffff169052565b5060e0830151611bd560e084018263ffffffff169052565b5061010083810151801515848301525b505092915050565b600060208284031215611bff57600080fd5b5035919050565b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610fa157610fa1611c06565b6001600160401b03818116838216019080821115611c5357611c53611c06565b5092915050565b600060208284031215611c6c57600080fd5b8151611882816119bd565b805169ffffffffffffffffffff81168114611c9157600080fd5b919050565b600080600080600060a08688031215611cae57600080fd5b611cb786611c77565b9450602086015193506040860151925060608601519150611cda60808701611c77565b90509295509295909350565b805162ffffff81168114611c9157600080fd5b60008060008060008060008060006101208a8c031215611d1857600080fd5b8951611d23816119ab565b60208b0151909950611d34816119ab565b60408b0151909850611d45816119ab565b60608b0151909750611d56816119ab565b60808b0151909650611d67816119ab565b9450611d7560a08b01611ce6565b9350611d8360c08b01611ce6565b9250611d9160e08b01611ce6565b9150611da06101008b01611ce6565b90509295985092959850929598565b634e487b7160e01b600052601260045260246000fd5b600082611dd457611dd4611daf565b500490565b80820180821115610fa157610fa1611c06565b600060208284031215611dfe57600080fd5b5051919050565b81810381811115610fa157610fa1611c06565b600060208284031215611e2a57600080fd5b8151611882816119d2565b600064ffffffffff80841680611e4d57611e4d611daf565b92169190910492915050565b6000600160ff1b8201611e6e57611e6e611c06565b5060000390565b634e487b7160e01b600052603260045260246000fd5b600082611e9a57611e9a611daf565b500690565b8082018281126000831280158216821582161715611be557611be5611c06565b8181036000831280158383131683831282161715611c5357611c53611c06565b600063ffffffff808316818103611ef857611ef8611c06565b6001019392505050565b63ffffffff828116828216039080821115611c5357611c53611c06565b600081518084526020808501945080840160005b83811015611f4f57815187529582019590820190600101611f33565b509495945050505050565b60208152611f746020820183516001600160a01b03169052565b602082015160408201526040820151606082015260006060830151611fa460808401826001600160a01b03169052565b50608083015163ffffffff811660a08401525060a083015180151560c08401525060c08301516101408060e0850152611fe1610160850183611f1f565b915060e0850151610100601f1986850301818701526120008483611f1f565b93508087015191505061012061201d8187018363ffffffff169052565b959095015193019290925250919050565b6000825160005b8181101561204f5760208186018101518583015201612035565b50600092019182525091905056fea264697066735822122066df6adf77159c670133f65f239d7de922018c2561dd539ffe720c80199eac7964736f6c63430008140033

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

000000000000000000000000ae975071be8f8ee67addbc1a82488f1c2485806700000000000000000000000041cb3a2e51635f680acf3e6c043498782a4f37a500000000000000000000000041cb3a2e51635f680acf3e6c043498782a4f37a50000000000000000000000005787befdc0ecd210dfa948264631cd53e68f7802d729dc84e21ae57ffb6be0053bf2b0668aa2aaf300a2a7b2ddf7dc0bb6e875a8000000000000000000000000000000000000000000000000000000000000038e00000000000000000000000000000000000000000000000000000000002625a0

-----Decoded View---------------
Arg [0] : _vrfCoordinator (address): 0xAE975071Be8F8eE67addBC1A82488F1C24858067
Arg [1] : _bankroll (address): 0x41cb3a2e51635F680Acf3E6C043498782a4F37A5
Arg [2] : _trustedForwarder (address): 0x41cb3a2e51635F680Acf3E6C043498782a4F37A5
Arg [3] : _link_eth_feed (address): 0x5787BefDc0ECd210Dfa948264631CD53E68F7802
Arg [4] : _vrfKeyHash (bytes32): 0xd729dc84e21ae57ffb6be0053bf2b0668aa2aaf300a2a7b2ddf7dc0bb6e875a8
Arg [5] : _vrfSubId (uint64): 910
Arg [6] : _vrfCallbackGasLimit (uint32): 2500000

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 000000000000000000000000ae975071be8f8ee67addbc1a82488f1c24858067
Arg [1] : 00000000000000000000000041cb3a2e51635f680acf3e6c043498782a4f37a5
Arg [2] : 00000000000000000000000041cb3a2e51635f680acf3e6c043498782a4f37a5
Arg [3] : 0000000000000000000000005787befdc0ecd210dfa948264631cd53e68f7802
Arg [4] : d729dc84e21ae57ffb6be0053bf2b0668aa2aaf300a2a7b2ddf7dc0bb6e875a8
Arg [5] : 000000000000000000000000000000000000000000000000000000000000038e
Arg [6] : 00000000000000000000000000000000000000000000000000000000002625a0


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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