ETH Price: $3,280.28 (-3.82%)
Gas: 16 Gwei

Contract

0xc61d923A863833cB8a1A83FDb8241F8eA2e5fb3c
 

Overview

ETH Balance

0.819 ETH

Eth Value

$2,686.55 (@ $3,280.28/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
Cancel Raffle187767132023-12-13 10:39:35203 days ago1702463975IN
0xc61d923A...eA2e5fb3c
0 ETH0.0012115534.54866677
Create H2H Raffl...186988762023-12-02 12:59:59214 days ago1701521999IN
0xc61d923A...eA2e5fb3c
0 ETH0.0036237234.59996283
Set Winner186988332023-12-02 12:51:11214 days ago1701521471IN
0xc61d923A...eA2e5fb3c
0 ETH0.0047254929.84267094
Buy Entry186988312023-12-02 12:50:47214 days ago1701521447IN
0xc61d923A...eA2e5fb3c
2.55 ETH0.0038362530.27705157
Buy Entry186865482023-11-30 19:37:47215 days ago1701373067IN
0xc61d923A...eA2e5fb3c
2.55 ETH0.0093365664.92516244
Create H2H Raffl...186863912023-11-30 19:06:11216 days ago1701371171IN
0xc61d923A...eA2e5fb3c
0 ETH0.0062202959.39249079
Create H2H Raffl...186168162023-11-21 1:18:47225 days ago1700529527IN
0xc61d923A...eA2e5fb3c
0 ETH0.0046323744.2205891
Set Winner186168152023-11-21 1:18:35225 days ago1700529515IN
0xc61d923A...eA2e5fb3c
0 ETH0.0066711442.12992057
Buy Entry186168132023-11-21 1:18:11225 days ago1700529491IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0046916937.02845404
Buy Entry186162822023-11-20 23:29:59225 days ago1700522999IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0043704730.39165196
Create H2H Raffl...185877062023-11-16 23:24:47229 days ago1700177087IN
0xc61d923A...eA2e5fb3c
0 ETH0.0033820832.28540332
Set Winner185877022023-11-16 23:23:59229 days ago1700177039IN
0xc61d923A...eA2e5fb3c
0 ETH0.0055716535.1863739
Buy Entry185877012023-11-16 23:23:47229 days ago1700177027IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0042604833.62520124
Buy Entry185874962023-11-16 22:42:11229 days ago1700174531IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0042704529.6961707
Create H2H Raffl...185862172023-11-16 18:23:47230 days ago1700159027IN
0xc61d923A...eA2e5fb3c
0 ETH0.0058418555.76635113
Set Winner185862162023-11-16 18:23:35230 days ago1700159015IN
0xc61d923A...eA2e5fb3c
0 ETH0.008974456.67553397
Buy Entry185862152023-11-16 18:23:23230 days ago1700159003IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0073138857.72369864
Buy Entry185861782023-11-16 18:15:59230 days ago1700158559IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0072700550.5549363
Create H2H Raffl...185808982023-11-16 0:34:47230 days ago1700094887IN
0xc61d923A...eA2e5fb3c
0 ETH0.0037408635.71027036
Set Winner185808932023-11-16 0:33:47230 days ago1700094827IN
0xc61d923A...eA2e5fb3c
0 ETH0.0054124434.18093991
Buy Entry185808922023-11-16 0:33:35230 days ago1700094815IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0039897331.48840771
Buy Entry185807052023-11-15 23:55:47230 days ago1700092547IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0049068334.12143129
Create H2H Raffl...185771982023-11-15 12:10:47231 days ago1700050247IN
0xc61d923A...eA2e5fb3c
0 ETH0.0034151332.60083517
Set Winner185771962023-11-15 12:10:23231 days ago1700050223IN
0xc61d923A...eA2e5fb3c
0 ETH0.0053785733.96701589
Buy Entry185771952023-11-15 12:10:11231 days ago1700050211IN
0xc61d923A...eA2e5fb3c
0.2625 ETH0.0041457132.71942506
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To Value
186988372023-12-02 12:51:59214 days ago1701521519
0xc61d923A...eA2e5fb3c
0.1 ETH
186988372023-12-02 12:51:59214 days ago1701521519
0xc61d923A...eA2e5fb3c
5 ETH
186168192023-11-21 1:19:23225 days ago1700529563
0xc61d923A...eA2e5fb3c
0.025 ETH
186168192023-11-21 1:19:23225 days ago1700529563
0xc61d923A...eA2e5fb3c
0.5 ETH
185877062023-11-16 23:24:47229 days ago1700177087
0xc61d923A...eA2e5fb3c
0.025 ETH
185877062023-11-16 23:24:47229 days ago1700177087
0xc61d923A...eA2e5fb3c
0.5 ETH
185862202023-11-16 18:24:23230 days ago1700159063
0xc61d923A...eA2e5fb3c
0.025 ETH
185862202023-11-16 18:24:23230 days ago1700159063
0xc61d923A...eA2e5fb3c
0.5 ETH
185808972023-11-16 0:34:35230 days ago1700094875
0xc61d923A...eA2e5fb3c
0.025 ETH
185808972023-11-16 0:34:35230 days ago1700094875
0xc61d923A...eA2e5fb3c
0.5 ETH
185772002023-11-15 12:11:11231 days ago1700050271
0xc61d923A...eA2e5fb3c
0.025 ETH
185772002023-11-15 12:11:11231 days ago1700050271
0xc61d923A...eA2e5fb3c
0.5 ETH
185762282023-11-15 8:53:47231 days ago1700038427
0xc61d923A...eA2e5fb3c
0.025 ETH
185762282023-11-15 8:53:47231 days ago1700038427
0xc61d923A...eA2e5fb3c
0.5 ETH
185761862023-11-15 8:45:23231 days ago1700037923
0xc61d923A...eA2e5fb3c
0.025 ETH
185761862023-11-15 8:45:23231 days ago1700037923
0xc61d923A...eA2e5fb3c
0.5 ETH
185759632023-11-15 7:59:47231 days ago1700035187
0xc61d923A...eA2e5fb3c
0.025 ETH
185759632023-11-15 7:59:47231 days ago1700035187
0xc61d923A...eA2e5fb3c
0.5 ETH
185759362023-11-15 7:54:23231 days ago1700034863
0xc61d923A...eA2e5fb3c
0.025 ETH
185759362023-11-15 7:54:23231 days ago1700034863
0xc61d923A...eA2e5fb3c
0.5 ETH
185759182023-11-15 7:50:47231 days ago1700034647
0xc61d923A...eA2e5fb3c
0.025 ETH
185759182023-11-15 7:50:47231 days ago1700034647
0xc61d923A...eA2e5fb3c
0.5 ETH
185755942023-11-15 6:45:23231 days ago1700030723
0xc61d923A...eA2e5fb3c
0.025 ETH
185755942023-11-15 6:45:23231 days ago1700030723
0xc61d923A...eA2e5fb3c
0.5 ETH
185747832023-11-15 4:01:47231 days ago1700020907
0xc61d923A...eA2e5fb3c
0.025 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
H2HVRF2

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 16 : H2HVRF2.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; // used for the required collections check
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

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

import "@openzeppelin/contracts/utils/math/Math.sol";

import "./BlackListManager.sol";

/// @title H2H competitions
/// @author Luis Pando
/// @notice It consumes VRF v2 from Chainlink. It has the role
/// "operator" that is the one used by a backend app to make some calls
/// @dev It saves in an ordered array the player wallet and the current
/// entries count. So buying entries has a complexity of O(1)
/// For calculating the winner, from the huge random number generated by Chainlink
/// a normalized random is generated by using the module method, adding 1 to have
/// a random from 1 to entriesCount.
/// So next step is to perform a binary search on the ordered array to get the
/// player O(log n)
/// Example:
/// 0 -> { 1, player1} as player1 buys 1 entry
/// 1 -> {51, player2} as player2 buys 50 entries
/// 2 -> {52, player3} as player3 buys 1 entry
/// 3 -> {53, player4} as player4 buys 1 entry
/// 4 -> {153, player5} as player5 buys 100 entries
/// So the setWinner method performs a binary search on that sorted array to get the upper bound.
/// If the random number generated is 150, the winner is player5. If the random number is 20, winner is player2
///
/// There are 3 possible scenarios for a competition
/// -SCENARIO 1. If there are enough players, it calls chainlink VRF v2 to get a winner
/// that takes all.
/// -SCENARIO 2. If there are players, but not enough, the first one will get unfulfilledAmount
/// (for example 0.6 ETH) instead of the amount entered to buy (for example 0.55 ETH).
/// The rest of the players get the amount entered to buy (0.55 ETH) so there is an incentive
/// to be the first to participate. It is designed to allow n participants, not only 2.
/// The contract must have some ETH in the balance to cover the difference between the amount used
/// to buy and the failureAmount (0.05 ETH in this competition).
/// But there is no need to call stake, just transfer ETH to the contract
/// -SCENARIO 3. If there are no players at all, the competition is canceled, and no fund is sent
/// to anyone
/// In scenario 1, the status of the competition is ENDED. In scenario 2 is UNFULFILLED and in 3,
/// the status of the competition is CANCELED
contract H2HVRF2 is
    AccessControl,
    ReentrancyGuard,
    VRFConsumerBaseV2,
    ConfirmedOwner
{
    ////////// CHAINLINK VRF v2 /////////////////

    VRFCoordinatorV2Interface COORDINATOR;

    // Your subscription ID.
    uint64 immutable s_subscriptionId;

    // Goerli coordinator. For other networks,
    // see https://docs.chain.link/docs/vrf-contracts/#configurations
    address immutable vrfCoordinator; // = 0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D;

    // The gas lane to use, which specifies the maximum gas price to bump to.
    // For a list of available gas lanes on each network,
    // see https://docs.chain.link/docs/vrf-contracts/#configurations
    bytes32 immutable keyHash; // = 0x79d3d8832d904592c0bf9818b621522c988bb8b0c05cdc3b15aea1b6e8db0c15;

    // Depends on the number of requested values that you want sent to the
    // fulfillRandomWords() function. Storing each word costs about 20,000 gas,
    // so 100,000 is a safe default for this example contract. Test and adjust
    // this limit based on the network that you select, the size of the request,
    // and the processing of the callback request in the fulfillRandomWords()
    // function.
    uint32 callbackGasLimit = 300000;

    // The default is 3, but you can set this higher.
    uint16 immutable requestConfirmations = 3;

    // Cannot exceed VRFCoordinatorV2.MAX_NUM_WORDS.
    uint32 immutable numWords = 5;

    address s_owner;

    uint256 internal fee; // fee paid in LINK to chainlink. 0.1 in Rinkeby, 2 in mainnet

    struct RequestStatus {
        bool fulfilled; // whether the request has been successfully fulfilled
        bool exists; // whether a requestId exists
        uint256[] randomWords; // array with random numbers generated
        uint256 id; // competition Id
        uint256 size; // number of players
    }
    mapping(uint256 => RequestStatus) public s_requests;

    /////////////// END CHAINKINK VRF V2 //////////////

    // event sent when the smart contract calls Chainlink´s VRF v2 to generate a set of random numbers
    event RandomNumberRequested(uint256 indexed raffleId, uint256 size);

    // event sent when the random number is generated by the VRF. In SCENARIO 1 so there is a winner
    event RandomNumberCreated(
        uint256 indexed idFromMetawin,
        uint256 randomNumber,
        uint256 normalizedRandomNumber
    );

    // Event generated in SCENARIO 2, when there are players but not enough so no winner is selected
    // so players are refunded except the first player to buy, who gets an extra
    event RaffleUnfulfilled(
        uint256 indexed raffleId,
        address winner,
        uint256 unfunfilledAmount,
        uint256 randomNumber,
        uint256 amountRaised
    );
    struct RaffleInfo {
        uint256 id; // raffleId
        uint256 size; // length of the entries array of that raffle
    }

    // Event sent when the raffle is created by the operator
    event RaffleCreated(uint256 indexed raffleId, uint256 indexed prizeAmount);
    // Event sent when the raffle is finished (either early cashout or successful completion)
    event RaffleEnded(
        uint256 indexed raffleId,
        address indexed winner,
        uint256 amountRaised,
        uint256 randomNumber
    );
    // Event sent when one or more entries are sold (info from the price structure)
    event EntrySold(
        uint256 indexed raffleId,
        address indexed buyer,
        uint256 currentSize,
        uint256 priceStructureId
    );
    // Event sent when a free entry is added by the hamburguer
    event FreeEntry(
        uint256 indexed raffleId,
        address[] buyer,
        uint256 amount,
        uint256 currentSize
    );
    // Event sent when a raffle is asked to cancel by the operator
    event RaffleCancelled(uint256 indexed raffleId, uint256 amountRaised);
    // The raffle is closed successfully and the platform receives the fee
    event FeeTransferredToPlatform(
        uint256 indexed raffleId,
        uint256 amountTransferred
    );
    event SetWinnerTriggered(uint256 indexed raffleId, uint256 amountRaised);
    // Emitted when an entry is cancelled
    event EntryCancelled(
        uint256 indexed raffleId,
        uint256 amountOfEntriesCanceled,
        address player
    );

    // In order to calculate the winner, in this struct is saved for each bought the data
    struct EntriesBought {
        uint256 currentEntriesLength; // current amount of entries bought in the raffle
        address player; // wallet address of the player
    }
    // every raffle has a sorted array of EntriesBought. Each element is created when calling
    // either buyEntry or giveBatchEntriesForFree
    mapping(uint256 => EntriesBought[]) public entriesList;

    // Main raffle data struct
    struct RaffleStruct {
        STATUS status; // status of the raffle. Can be created, accepted, ended, etc
        uint48 totalEntriesCap;
        uint48 randomNumber; // normalized (0-Entries array size) random number generated by the VRF
        uint48 entriesLength; // to easy frontend, the length of the entries array is saved here
        uint48 cancellingDate;
        address[] collectionWhitelist; // addresses of the required nfts. Will be empty if no NFT is required to buy
        address winner; // address of thed winner of the raffle. Address(0) if no winner yet
        ENTRY_TYPE entryType;
        uint128 unfulfilledAmount; // amount paid to the first player that bought if the compt is canceled
        uint128 price; // price to pay to buy a single entry
        uint128 amountOfETH; // Amount of ETH of the prize
        uint128 amountRaised; // funds raised so far in wei
    }
    // The main structure is an array of raffles
    RaffleStruct[] public raffles;

    // Map that contains the number of entries each user has bought, to prevent abuse
    /*  struct ClaimStruct {
        uint48 numEntriesPerUser;
    }*/
    mapping(bytes32 => bool) public claimsData;

    // Map with the addresses linked to a particular raffle + nft
    mapping(bytes32 => address) public requiredNFTWallets;

    // All the different status a competition can have
    enum STATUS {
        CREATED, // the operator creates the raffle
        ACCEPTED, // the seller stakes the ETH for the raffle
        EARLY_CASHOUT, // the seller wants to cashout early
        CANCELLED, // the operator cancels the raffle and transfer the remaining funds after 30 days passes
        CLOSING_REQUESTED, // the operator sets a winner
        ENDED, // the raffle is finished, and the funds were transferred
        CANCEL_REQUESTED, // operator asks to cancel the raffle. Players has 30 days to ask for a refund
        UNFULFILLED // there are players, but not enough. First player that bought get an extra as incentive
    }

    enum ENTRY_TYPE {
        ONLY_DIRECTLY,
        ONLY_EXTERNAL_CONTRACT,
        MIXED
    }

    // The operator role is operated by a backend application
    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR");
    // requested by Hamburger. Role for the buy method of the hamburger (only that contract)
    bytes32 public constant MINTERCONTRACT_ROLE = keccak256("MINTERCONTRACT");

    // address of the wallet controlled by the platform that will receive the platform fee
    address payable public destinationWallet =
        payable(0x52a032cF59eA274f9D745f29b6D514fe95Ba192D);

    // contract that contains the black list
    BlackListManager blackListManager;

    constructor(
        address _blacklistManager,
        uint64 subscriptionId,
        address _vrfCoordinator,
        bytes32 _keyHash
    ) VRFConsumerBaseV2(_vrfCoordinator) ConfirmedOwner(msg.sender) {
        COORDINATOR = VRFCoordinatorV2Interface(_vrfCoordinator);
        vrfCoordinator = _vrfCoordinator;
        keyHash = _keyHash;
        s_owner = msg.sender;
        s_subscriptionId = subscriptionId;

        _setupRole(OPERATOR_ROLE, 0x13503B622abC0bD30A7e9687057DF6E8c42Fb928);
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(OPERATOR_ROLE, msg.sender);

        blackListManager = BlackListManager(_blacklistManager);
    }

    function callVRFAndGetRequestId() internal returns (uint256 requestId) {
        // Will revert if subscription is not set and funded.
        requestId = COORDINATOR.requestRandomWords(
            keyHash,
            s_subscriptionId,
            requestConfirmations,
            callbackGasLimit,
            numWords
        );
        return requestId;
    }

    /// @dev this is the method that will be called by the smart contract to get a random number
    /// @param _id Id of the raffle
    /// @param _entriesSize length of the entries array of that raffle
    function getRandomNumber(
        uint256 _id,
        uint256 _entriesSize,
        uint256 _requestId
    ) internal {
        s_requests[_requestId] = RequestStatus({
            randomWords: new uint256[](0),
            exists: true,
            fulfilled: false,
            id: _id,
            size: _entriesSize
        });

        emit RandomNumberRequested(_id, _entriesSize);
    }

    function setWinnerActions(
        uint256 _raffleId
    ) internal returns (RaffleStruct memory, bool) {
        RaffleStruct storage raffle = raffles[_raffleId];

        // if there are no participants, when calculating the winner will trigger a division by zero
        require(raffle.entriesLength != 0, "No participants in the raffle");

        // Check if the raffle is already accepted or is called again because early cashout failed
        require(raffle.status == STATUS.ACCEPTED, "Raffle in wrong status");
        raffle.status = STATUS.CLOSING_REQUESTED;

        emit SetWinnerTriggered(_raffleId, raffle.amountRaised);

        if (raffle.entriesLength < raffle.totalEntriesCap) {
            closeRaffleAndRefund(_raffleId, 1);
            return (raffle, false);
        }
        return (raffle, true);
    }

    /// @param _raffleId Id of the raffle
    /// @notice the operator finish the raffle, if the desired funds has been reached
    /// @dev it triggers Chainlink VRF1 consumer, and generates a random number that is normalized and checked that corresponds to a MW player
    function setWinner(
        uint256 _raffleId
    ) external nonReentrant onlyRole(OPERATOR_ROLE) {
        (RaffleStruct memory raffle, bool shouldDoCallback) = setWinnerActions(
            _raffleId
        );
        if (shouldDoCallback) {
            uint256 requestId = callVRFAndGetRequestId();
            getRandomNumber(_raffleId, raffle.entriesLength, requestId);
        }
    }

    function getRequestStatus(
        uint256 _requestId
    ) external view returns (bool fulfilled, uint256[] memory randomWords) {
        require(s_requests[_requestId].exists, "request not found");
        RequestStatus memory request = s_requests[_requestId];
        return (request.fulfilled, request.randomWords);
    }

    // Called by Chainlink
    function fulfillRandomWords(
        uint256 _requestId,
        uint256[] memory _randomWords
    ) internal override {
        require(s_requests[_requestId].exists, "request not found");
        s_requests[_requestId].fulfilled = true;
        s_requests[_requestId].randomWords = _randomWords;

        uint256 normalizedRandomNumber = (_randomWords[0] %
            s_requests[_requestId].size) + 1;

        uint256 raffleId = s_requests[_requestId].id;
        RaffleStruct storage raffle = raffles[raffleId];
        raffle.status = STATUS.CLOSING_REQUESTED;

        // SCENARIO 1
        if (raffle.totalEntriesCap == raffle.entriesLength) {
            emit RandomNumberCreated(
                raffleId,
                _randomWords[0],
                normalizedRandomNumber
            );
            transferFunds(raffleId, normalizedRandomNumber);
        }
        // SCENARIOS 2 AND 3. Theoretically should never be called as
        // the scenario is managed in setwinner
        else closeRaffleAndRefund(raffleId, normalizedRandomNumber);
    }

    //////////////////////////////////////////////

    /// @dev callable by players. Depending on the number of entries assigned to the price structure the player buys (_id parameter)
    /// one or more entries will be assigned to the player.
    /// Also it is checked the maximum number of entries per user is not reached
    /// As the method is payable, in msg.value there will be the amount paid by the user
    /// @notice If the operator set requiredNFTs when creating the raffle, only the owners of nft on that collection can make a call to this method. This will be
    /// used for special raffles
    /// @param _raffleId: id of the raffle
    /// @param _collection: collection of the tokenId used. Not used if there is no required nft on the raffle
    /// @param _tokenIdUsed: id of the token used in private raffles (to avoid abuse can not be reused on the same raffle)
    function buyEntry(
        uint256 _raffleId,
        address _collection,
        uint256 _tokenIdUsed
    ) external payable nonReentrant {
        RaffleStruct storage raffle = raffles[_raffleId];
        uint256 collectionWLLength = raffle.collectionWhitelist.length;

        require(raffle.price == msg.value, "Price not reached");
        require(
            raffle.entryType == ENTRY_TYPE.MIXED ||
                raffle.entryType == ENTRY_TYPE.ONLY_DIRECTLY,
            "Entry type not allowed"
        );
        require(
            blackListManager.isBlackListed(msg.sender) == false,
            "Blacklisted!"
        );
        // if the raffle requires an nft
        if (collectionWLLength > 0) {
            bool hasRequiredCollection = false;
            for (uint256 i = 0; i < collectionWLLength; i++) {
                if (raffle.collectionWhitelist[i] == _collection) {
                    hasRequiredCollection = true;
                    break;
                }
            }
            require(
                hasRequiredCollection == true,
                "Not in required collection"
            );
            IERC721 requiredNFT = IERC721(_collection);
            require(
                requiredNFT.ownerOf(_tokenIdUsed) == msg.sender,
                "Not the owner of tokenId"
            );
            bytes32 hashRequiredNFT = keccak256(
                abi.encode(_collection, _raffleId, _tokenIdUsed)
            );
            // check the tokenId has not been using yet in the raffle, to avoid abuse
            if (requiredNFTWallets[hashRequiredNFT] == address(0)) {
                requiredNFTWallets[hashRequiredNFT] = msg.sender;
            } else
                require(
                    requiredNFTWallets[hashRequiredNFT] == msg.sender,
                    "tokenId used"
                );
        }

        require(msg.sender != address(0), "msg.sender is null"); // 37
        require(raffle.status == STATUS.ACCEPTED, "Raffle is not in accepted"); // 1808

        require(
            (raffle.totalEntriesCap == 0 ||
                (raffle.entriesLength + 1 <= raffle.totalEntriesCap)),
            "Total Cap Entries reached"
        );

        bytes32 hash = keccak256(abi.encode(msg.sender, _raffleId));
        // check there are enough entries left for this particular user
        require(claimsData[hash] == false, "Bought too many entries");

        EntriesBought memory entryBought = EntriesBought({
            player: msg.sender,
            currentEntriesLength: raffle.entriesLength + 1
        });
        entriesList[_raffleId].push(entryBought);

        raffle.amountRaised += uint128(msg.value);
        // update the field entriesLength, used in frontend to avoid making extra calls
        raffle.entriesLength = raffle.entriesLength + 1;
        // the player already participated on the H2H raffle
        claimsData[hash] = true;

        emit EntrySold(_raffleId, msg.sender, raffle.entriesLength, 0);
    }

    // helper method to get the winner address of a raffle
    /// @param _raffleId Id of the raffle
    /// @param _normalizedRandomNumber Generated by chainlink
    /// @return the wallet that won the raffle
    /// @dev Uses a binary search on the sorted array to retreive the winner
    /// but if the winner candidate is blacklisted, loop through the left looking for
    /// a candidate not blacklisted
    function getWinnerAddressFromRandom(
        uint256 _raffleId,
        uint256 _normalizedRandomNumber
    ) public view returns (address) {
        uint256 position = findUpperBound(
            entriesList[_raffleId],
            _normalizedRandomNumber
        );

        address candidate = entriesList[_raffleId][position].player;
        // general case
        if (candidate != address(0)) return candidate;
        // special case. The user is blacklisted, so try next on the left until find a non-blacklisted
        else {
            bool ended = false;
            uint256 i = position;
            while (
                ended == false && entriesList[_raffleId][i].player == address(0)
            ) {
                if (i == 0) i = entriesList[_raffleId].length - 1;
                else i = i - 1;
                // we came to the beginning without finding a non blacklisted player
                if (i == position) ended == true;
            }
            require(!ended, "All users blacklisted");
            return entriesList[_raffleId][i].player;
        }
    }

    /// @param array sorted array of EntriesBought. CurrentEntriesLength is the numeric field used to sort
    /// @param element uint256 to find. Goes from 1 to entriesLength
    /// @dev based on openzeppelin code (v4.0), modified to use an array of EntriesBought
    /// Searches a sorted array and returns the first index that contains a value greater or equal to element.
    /// If no such index exists (i.e. all values in the array are strictly less than element), the array length is returned. Time complexity O(log n).
    /// array is expected to be sorted in ascending order, and to contain no repeated elements.
    /// https://docs.openzeppelin.com/contracts/3.x/api/utils#Arrays-findUpperBound-uint256---uint256-
    function findUpperBound(
        EntriesBought[] memory array,
        uint256 element
    ) internal pure returns (uint256) {
        if (array.length == 0) {
            return 0;
        }

        uint256 low = 0;
        uint256 high = array.length;

        while (low < high) {
            uint256 mid = Math.average(low, high);

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because Math.average rounds down (it does integer division with truncation).
            if (array[mid].currentEntriesLength > element) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
        if (low > 0 && array[low - 1].currentEntriesLength == element) {
            return low - 1;
        } else {
            return low;
        }
    }

    // The operator can call this method once they receive the event "RandomNumberCreated"
    // triggered by the VRF v2 consumer contract (RandomNumber.sol)
    /// @param _raffleId Id of the raffle
    /// @param _normalizedRandomNumber index of the array that contains the winner of the raffle. Generated by chainlink
    /// @notice it is the method that sets the winner and transfers funds
    /// @dev called by Chainlink callback
    function transferFunds(
        uint256 _raffleId,
        uint256 _normalizedRandomNumber
    ) internal nonReentrant {
        RaffleStruct storage raffle = raffles[_raffleId];
        // Only when the raffle has been asked to be closed and the platform
        require(
            raffle.status == STATUS.EARLY_CASHOUT ||
                raffle.status == STATUS.CLOSING_REQUESTED,
            "Raffle in wrong status"
        );

        raffle.randomNumber = uint48(_normalizedRandomNumber);
        raffle.winner = getWinnerAddressFromRandom(
            _raffleId,
            _normalizedRandomNumber
        );
        raffle.status = STATUS.ENDED;

        (bool sentPrize, ) = raffle.winner.call{value: raffle.amountOfETH}("");
        require(sentPrize, "Failed to send Ether");

        // The amount for the platform is not a percentage but raised - prize
        uint256 amountForPlatform = (raffle.amountRaised - raffle.amountOfETH);
        // transfer the amount to the platform
        (bool sent2, ) = destinationWallet.call{value: amountForPlatform}("");
        require(sent2, "Failed send Eth to MW");
        emit FeeTransferredToPlatform(_raffleId, amountForPlatform);

        emit RaffleEnded(
            _raffleId,
            raffle.winner,
            raffle.amountRaised,
            _normalizedRandomNumber
        );
    }

    /// @param _newAddress new address of the platform
    /// @dev Change the wallet of the platform. The one that will receive the platform fee when the raffle is closed.
    /// Only the admin can change this
    function setDestinationAddress(
        address payable _newAddress
    ) external onlyRole(DEFAULT_ADMIN_ROLE) {
        destinationWallet = _newAddress;
    }

    /// @param _raffleId Id of the raffle
    /// @return array of entries bougth of that particular raffle
    function getEntriesBought(
        uint256 _raffleId
    ) external view returns (EntriesBought[] memory) {
        return entriesList[_raffleId];
    }

    /// @dev if a player has been blacklisted, their entries must be void
    /// this has a cost in gas, but this makes cheaper in gas the callback from chainlink
    /// This method has to be called for every raffle of the blacklisted player
    /// @param _raffleId Id of the raffle
    /// @param entriesToCancel array that contains the index of the entries to cancel. 0 based
    /// @param _player blacklisted player who owns the entry to be voided
    function cancelEntry(
        uint256 _raffleId,
        uint256[] calldata entriesToCancel,
        address _player
    ) external onlyRole(OPERATOR_ROLE) {
        uint256 totalEntriesBoughtCancelled = 0;
        for (uint256 i = 0; i < entriesToCancel.length; i++) {
            EntriesBought storage entry = entriesList[_raffleId][
                entriesToCancel[i]
            ];

            require(entry.player == _player, "Entry did not belong to player");

            entry.player = address(0);

            uint256 previousTotalEntriesLength;
            if (entriesToCancel[i] == 0) previousTotalEntriesLength = 0;
            else
                previousTotalEntriesLength = entriesList[_raffleId][
                    entriesToCancel[i] - 1
                ].currentEntriesLength;
            totalEntriesBoughtCancelled +=
                entry.currentEntriesLength -
                previousTotalEntriesLength;
        }
        emit EntryCancelled(_raffleId, totalEntriesBoughtCancelled, _player);
    }

    // When the contract is replaced, or if there was sent too much ETH to the contract for the
    // case of SCENARIO 2, calling this method will sent some ETH from the contract to the
    // destination wallet
    function withdraw(
        uint256 amount
    ) external nonReentrant onlyRole(OPERATOR_ROLE) {
        (bool sent, ) = destinationWallet.call{value: amount}("");
        require(sent, "Fail send Eth to MW");
    }

    /// @notice Creates a H2H (with multiple players, not only 2)
    /// Each player funds the competition by buying entries. So no need to
    /// stake on the raffle like in previous versions
    /// @dev unfulfilledAmount is the total amount paid to the first buyer in
    /// SCENARIO 2. Not an extra fee to add to the amount paid.
    /// @param _amountOfETH the prize in weis the winner will get if SCENARIO 1 occurs
    /// @param _unfulfilledAmount paid price + extra the first player will get in SCENARIO 2
    /// @param _price Amount in weis a player must enter to participate in the H2H competition
    function createH2HRaffle(
        uint128 _amountOfETH,
        uint128 _unfulfilledAmount,
        uint128 _price,
        address[] calldata _collectionWhitelist,
        ENTRY_TYPE _entryType,
        uint48 _totalEntriesCap
    ) external onlyRole(OPERATOR_ROLE) returns (uint256) {
        unchecked {
            require(_amountOfETH != 0, "Prize is 0");

            RaffleStruct memory raffle = RaffleStruct({
                status: STATUS.ACCEPTED, // no stake, so it is automatically in accepted
                amountOfETH: _amountOfETH,
                winner: address(0),
                randomNumber: 0,
                amountRaised: 0,
                entriesLength: 0,
                cancellingDate: 0,
                collectionWhitelist: _collectionWhitelist,
                entryType: _entryType,
                totalEntriesCap: _totalEntriesCap,
                unfulfilledAmount: _unfulfilledAmount,
                price: _price
            });

            raffles.push(raffle);

            uint256 raffleId = raffles.length - 1;

            emit RaffleCreated(raffleId, _amountOfETH);

            return raffleId;
        }
    }

    /// @dev This method manages SCENARIO 2 and SCENARIO 3
    /// So when a raffle cannot be fulfilled because either there are no purchases
    /// or there are only a few players.
    /// @param _raffleId Id of the raffle
    /// @param _normalizedRandomNumber index of the array that contains the winner of the raffle. Generated by chainlink
    function closeRaffleAndRefund(
        uint256 _raffleId,
        uint256 _normalizedRandomNumber
    ) internal {
        RaffleStruct storage raffle = raffles[_raffleId];
        require(raffle.status == STATUS.CLOSING_REQUESTED, "Wrong status");
        uint256 amountOfEntries = raffle.entriesLength;

        // SCENARIO 2
        // There are boughts, but not enough to reach the required amount
        // The first player to bought, gets an extra amount to incentivate players to participate
        // The status of the competition is not cancelled but UNFULFILLED, and a new event is sent
        if (amountOfEntries != 0) {
            uint256 amountToRefundPerPlayer = raffle.price;
            require(
                address(this).balance >
                    raffle.unfulfilledAmount +
                        (amountToRefundPerPlayer * (amountOfEntries - 1)),
                "Not enough balance"
            );

            raffle.status = STATUS.UNFULFILLED;
            raffle.winner = entriesList[_raffleId][0].player;
            raffle.randomNumber = uint48(_normalizedRandomNumber);
            emit RaffleUnfulfilled(
                _raffleId,
                raffle.winner,
                raffle.unfulfilledAmount,
                _normalizedRandomNumber,
                raffle.amountRaised
            );

            for (uint256 i; i < amountOfEntries; ++i) {
                if (i == 0) // first player has special bonus
                {
                    (bool sentFundsBack, ) = entriesList[_raffleId][i]
                        .player
                        .call{value: raffle.unfulfilledAmount}("");
                    require(sentFundsBack, "Failed to send Ether 1");
                } else {
                    (bool sentFundsBack, ) = entriesList[_raffleId][i]
                        .player
                        .call{value: amountToRefundPerPlayer}("");
                    require(sentFundsBack, "Failed to send Ether 2");
                }
            }
        }
        // SCENARIO 3.
        // Nobody boughts, no need to refund anything. Just set status to cancelled and send event
        // Theoretically this branch should never be reached, as there are checks done both back
        // and in method SetWinner to avoid calling chainlink if there are 0 entries bought
        else {
            raffle.status = STATUS.CANCELLED;
            raffle.cancellingDate = uint48(block.timestamp);
            emit RaffleCancelled(_raffleId, raffle.amountRaised);
        }
    }

    /// @notice Will receive any eth sent to the contract. We will use it to send some ETH
    /// for the case of the extra amount paid to first player to buy in SCENARIO 2
    receive() external payable {}

    /// @dev lets the operator to change the blacklist contract used. For example in case
    /// of updating the blacklistManager contract
    /// @param _blacklistManager address of the new BlacklistManager contract
    function changeBlackList(
        address _blacklistManager
    ) external onlyRole(OPERATOR_ROLE) {
        blackListManager = BlackListManager(_blacklistManager);
    }

    /// @dev cancels a raffle, and in the case of having some entries bought, it refunds them
    /// Avoid cancelling two times the same raffle
    function cancelRaffle(uint256 _raffleId) external onlyRole(OPERATOR_ROLE) {
        RaffleStruct storage raffle = raffles[_raffleId];
        require(raffle.status != STATUS.CANCELLED, "Already canceled");
        uint256 amountOfEntries = raffle.entriesLength;

        // if there are already players
        if (amountOfEntries > 0) {
            // send funds back to existing players
            for (uint256 i; i < amountOfEntries; ++i) {
                (bool sentFundsBack, ) = entriesList[_raffleId][i].player.call{
                    value: raffle.price
                }("");
                require(sentFundsBack, "Failed to refund");
            }
        }
        raffle.status = STATUS.CANCELLED;
        raffle.cancellingDate = uint48(block.timestamp);
        emit RaffleCancelled(_raffleId, raffle.amountRaised);
    }
}

File 2 of 16 : BlackListManager.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/AccessControl.sol";

/// @title Blacklist manager
/// @author Luis Pando
/// @notice Manages the players that are blacklisted
/// @dev A player is blacklisted for all the raffles at once.
contract BlackListManager is AccessControl {
    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR");

    struct BlackListStruct {
        bool blacklisted;   // is blacklisted the user
        uint256 dateBlacklisted; // when was blacklisted for the first time
    }
    // map with the wallet of the player as key
    mapping(address => BlackListStruct) public blackList;

    constructor() {
        _setupRole(OPERATOR_ROLE, msg.sender);
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    /// @notice Add a player to the blacklist. The blacklist is common for all the raffles
    /// @dev the user could be added and removed from the blacklist several times, but the
    /// field dateBlacklisted will contain the date of when the user was added, even if was removed
    /// @param _player User that has suspicious behaviour and that will be blacklisted
    function addToBlackList(address _player) external onlyRole(OPERATOR_ROLE) {
        BlackListStruct memory blElement = BlackListStruct({
            blacklisted: true,
            dateBlacklisted: block.timestamp
        });
        blackList[_player] = blElement;
    }

    /// @notice remove a player from the blacklist
    /// @param _player that will be removed from the blacklist and will be able to buy entries again
    function removeFromBlackList(address _player)
        external
        onlyRole(OPERATOR_ROLE)
    {
        blackList[_player].blacklisted = false;
    }

    /// @notice returns if a player is in the blacklist
    /// @param _player User to check if blacklisted or not
    /// @return true if the user wallet is in the blacklist. False otherwise
    function isBlackListed(address _player) external view returns (bool) {
        return blackList[_player].blacklisted;
    }

    /// @notice returns the date (if any) when the user was blacklisted for first time
    /// @dev The returned value will exists even if the user was removed from the blacklist
    /// Do not use it without calling isBlacklisted first
    /// @param _player User to return the date when blacklisted
    /// @return a number with the epoch of when the player was blacklisted. 0 if never blacklisted
    function getBlackListedDate(address _player) external view returns (uint256) {
        return blackList[_player].dateBlacklisted;
    }
}

File 3 of 16 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }

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

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
        // good first aproximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 1;
        }

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        uint256 result = sqrt(a);
        if (rounding == Rounding.Up && result * result < a) {
            result += 1;
        }
        return result;
    }
}

File 4 of 16 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 5 of 16 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 6 of 16 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 7 of 16 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 8 of 16 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 9 of 16 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

    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() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 10 of 16 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 11 of 16 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 12 of 16 : 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;
}

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

interface OwnableInterface {
  function owner() external returns (address);

  function transferOwnership(address recipient) external;

  function acceptOwnership() external;
}

File 14 of 16 : 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 15 of 16 : ConfirmedOwnerWithProposal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./interfaces/OwnableInterface.sol";

/**
 * @title The ConfirmedOwner contract
 * @notice A contract with helpers for basic contract ownership.
 */
contract ConfirmedOwnerWithProposal is OwnableInterface {
  address private s_owner;
  address private s_pendingOwner;

  event OwnershipTransferRequested(address indexed from, address indexed to);
  event OwnershipTransferred(address indexed from, address indexed to);

  constructor(address newOwner, address pendingOwner) {
    require(newOwner != address(0), "Cannot set owner to zero");

    s_owner = newOwner;
    if (pendingOwner != address(0)) {
      _transferOwnership(pendingOwner);
    }
  }

  /**
   * @notice Allows an owner to begin transferring ownership to a new address,
   * pending.
   */
  function transferOwnership(address to) public override onlyOwner {
    _transferOwnership(to);
  }

  /**
   * @notice Allows an ownership transfer to be completed by the recipient.
   */
  function acceptOwnership() external override {
    require(msg.sender == s_pendingOwner, "Must be proposed owner");

    address oldOwner = s_owner;
    s_owner = msg.sender;
    s_pendingOwner = address(0);

    emit OwnershipTransferred(oldOwner, msg.sender);
  }

  /**
   * @notice Get the current owner
   */
  function owner() public view override returns (address) {
    return s_owner;
  }

  /**
   * @notice validate, transfer ownership, and emit relevant events
   */
  function _transferOwnership(address to) private {
    require(to != msg.sender, "Cannot transfer to self");

    s_pendingOwner = to;

    emit OwnershipTransferRequested(s_owner, to);
  }

  /**
   * @notice validate access
   */
  function _validateOwnership() internal view {
    require(msg.sender == s_owner, "Only callable by owner");
  }

  /**
   * @notice Reverts if called by anyone other than the contract owner.
   */
  modifier onlyOwner() {
    _validateOwnership();
    _;
  }
}

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

import "./ConfirmedOwnerWithProposal.sol";

/**
 * @title The ConfirmedOwner contract
 * @notice A contract with helpers for basic contract ownership.
 */
contract ConfirmedOwner is ConfirmedOwnerWithProposal {
  constructor(address newOwner) ConfirmedOwnerWithProposal(newOwner, address(0)) {}
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_blacklistManager","type":"address"},{"internalType":"uint64","name":"subscriptionId","type":"uint64"},{"internalType":"address","name":"_vrfCoordinator","type":"address"},{"internalType":"bytes32","name":"_keyHash","type":"bytes32"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"},{"internalType":"address","name":"want","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOfEntriesCanceled","type":"uint256"},{"indexed":false,"internalType":"address","name":"player","type":"address"}],"name":"EntryCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"currentSize","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceStructureId","type":"uint256"}],"name":"EntrySold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountTransferred","type":"uint256"}],"name":"FeeTransferredToPlatform","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":false,"internalType":"address[]","name":"buyer","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"currentSize","type":"uint256"}],"name":"FreeEntry","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountRaised","type":"uint256"}],"name":"RaffleCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"prizeAmount","type":"uint256"}],"name":"RaffleCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":true,"internalType":"address","name":"winner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountRaised","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"RaffleEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":false,"internalType":"address","name":"winner","type":"address"},{"indexed":false,"internalType":"uint256","name":"unfunfilledAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountRaised","type":"uint256"}],"name":"RaffleUnfulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"idFromMetawin","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"normalizedRandomNumber","type":"uint256"}],"name":"RandomNumberCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"size","type":"uint256"}],"name":"RandomNumberRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"raffleId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountRaised","type":"uint256"}],"name":"SetWinnerTriggered","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTERCONTRACT_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raffleId","type":"uint256"},{"internalType":"address","name":"_collection","type":"address"},{"internalType":"uint256","name":"_tokenIdUsed","type":"uint256"}],"name":"buyEntry","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raffleId","type":"uint256"},{"internalType":"uint256[]","name":"entriesToCancel","type":"uint256[]"},{"internalType":"address","name":"_player","type":"address"}],"name":"cancelEntry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raffleId","type":"uint256"}],"name":"cancelRaffle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_blacklistManager","type":"address"}],"name":"changeBlackList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"claimsData","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_amountOfETH","type":"uint128"},{"internalType":"uint128","name":"_unfulfilledAmount","type":"uint128"},{"internalType":"uint128","name":"_price","type":"uint128"},{"internalType":"address[]","name":"_collectionWhitelist","type":"address[]"},{"internalType":"enum H2HVRF2.ENTRY_TYPE","name":"_entryType","type":"uint8"},{"internalType":"uint48","name":"_totalEntriesCap","type":"uint48"}],"name":"createH2HRaffle","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"destinationWallet","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"entriesList","outputs":[{"internalType":"uint256","name":"currentEntriesLength","type":"uint256"},{"internalType":"address","name":"player","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raffleId","type":"uint256"}],"name":"getEntriesBought","outputs":[{"components":[{"internalType":"uint256","name":"currentEntriesLength","type":"uint256"},{"internalType":"address","name":"player","type":"address"}],"internalType":"struct H2HVRF2.EntriesBought[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_requestId","type":"uint256"}],"name":"getRequestStatus","outputs":[{"internalType":"bool","name":"fulfilled","type":"bool"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raffleId","type":"uint256"},{"internalType":"uint256","name":"_normalizedRandomNumber","type":"uint256"}],"name":"getWinnerAddressFromRandom","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"raffles","outputs":[{"internalType":"enum H2HVRF2.STATUS","name":"status","type":"uint8"},{"internalType":"uint48","name":"totalEntriesCap","type":"uint48"},{"internalType":"uint48","name":"randomNumber","type":"uint48"},{"internalType":"uint48","name":"entriesLength","type":"uint48"},{"internalType":"uint48","name":"cancellingDate","type":"uint48"},{"internalType":"address","name":"winner","type":"address"},{"internalType":"enum H2HVRF2.ENTRY_TYPE","name":"entryType","type":"uint8"},{"internalType":"uint128","name":"unfulfilledAmount","type":"uint128"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"uint128","name":"amountOfETH","type":"uint128"},{"internalType":"uint128","name":"amountRaised","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"requiredNFTWallets","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"s_requests","outputs":[{"internalType":"bool","name":"fulfilled","type":"bool"},{"internalType":"bool","name":"exists","type":"bool"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"_newAddress","type":"address"}],"name":"setDestinationAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_raffleId","type":"uint256"}],"name":"setWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101406040526004805461249f60a51b63ffffffff60a01b19909116179055600360f01b61010052600560e01b61012052600c80546001600160a01b0319167352a032cf59ea274f9d745f29b6d514fe95ba192d1790553480156200006357600080fd5b506040516200403438038062004034833981016040819052620000869162000378565b600180556001600160601b0319606083901b166080523380600081620000f35760405162461bcd60e51b815260206004820152601860248201527f43616e6e6f7420736574206f776e657220746f207a65726f000000000000000060448201526064015b60405180910390fd5b600280546001600160a01b0319166001600160a01b038481169190911790915581161562000126576200012681620001fe565b5050600480546001600160a01b0385166001600160a01b0319918216179091556001600160601b0319606085901b1660c090815260e08490526005805490921633179091556001600160c01b03199085901b1660a05250620001ac600080516020620040148339815191527313503b622abc0bd30a7e9687057df6e8c42fb928620002ab565b620001b9600033620002ab565b620001d46000805160206200401483398151915233620002ab565b5050600d80546001600160a01b0319166001600160a01b03939093169290921790915550620003d6565b6001600160a01b038116331415620002595760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401620000ea565b600380546001600160a01b0319166001600160a01b03838116918217909255600254604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b620002b78282620002bb565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16620002b7576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620003173390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b80516001600160a01b03811681146200037357600080fd5b919050565b600080600080608085870312156200038e578384fd5b62000399856200035b565b60208601519094506001600160401b0381168114620003b6578384fd5b9250620003c6604086016200035b565b6060959095015193969295505050565b60805160601c60a05160c01c60c05160601c60e0516101005160f01c6101205160e01c613bdb6200043960003960006123780152600061233b015260006122e3015260005050600061230b015260008181610f9c0152610fde0152613bdb6000f3fe6080604052600436106101d15760003560e01c80635fba3171116100f7578063a217fddf11610095578063d8a4676f11610064578063d8a4676f1461060a578063f2fde38b14610638578063f369145514610658578063f5b541a61461067857600080fd5b8063a217fddf14610585578063baf029051461059a578063d547741f146105ca578063d649214c146105ea57600080fd5b80637fa4cacb116100d15780637fa4cacb146104bd5780638da5cb5b146104dd57806391d14854146104fb578063a168fa891461051b57600080fd5b80635fba31711461045457806379ba5097146104745780637c903fc01461048957600080fd5b80632e1a7d4d1161016f5780633c891f291161013e5780633c891f29146103bd5780633fa2c575146103dd57806353b7a59b146103fd5780635d4bc0ce1461041d57600080fd5b80632e1a7d4d146103305780632f2ff15d1461035057806336568abe14610370578063365e36581461039057600080fd5b806315614f3e116101ab57806315614f3e146102715780631a0187f5146102845780631fe543e3146102d2578063248a9ca3146102f257600080fd5b8063013805c5146101dd57806301ffc9a71461021f5780630df716021461024f57600080fd5b366101d857005b600080fd5b3480156101e957600080fd5b506101fd6101f836600461376c565b61069a565b604080519283526001600160a01b039091166020830152015b60405180910390f35b34801561022b57600080fd5b5061023f61023a366004613525565b6106df565b6040519015158152602001610216565b34801561025b57600080fd5b5061026f61026a3660046134de565b610716565b005b61026f61027f36600461360c565b6107a4565b34801561029057600080fd5b506102ba61029f3660046134de565b600b602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610216565b3480156102de57600080fd5b5061026f6102ed3660046136a0565b610f91565b3480156102fe57600080fd5b5061032261030d3660046134de565b60009081526020819052604090206001015490565b604051908152602001610216565b34801561033c57600080fd5b5061026f61034b3660046134de565b611019565b34801561035c57600080fd5b5061026f61036b3660046134f6565b6110fb565b34801561037c57600080fd5b5061026f61038b3660046134f6565b611125565b34801561039c57600080fd5b506103b06103ab3660046134de565b61119f565b6040516102169190613816565b3480156103c957600080fd5b506103226103d836600461354d565b611227565b3480156103e957600080fd5b5061026f6103f8366004613486565b611565565b34801561040957600080fd5b50600c546102ba906001600160a01b031681565b34801561042957600080fd5b5061043d6104383660046134de565b6115a0565b6040516102169b9a999897969594939291906138bd565b34801561046057600080fd5b5061026f61046f3660046134de565b611642565b34801561048057600080fd5b5061026f61188c565b34801561049557600080fd5b506103227fde5ee446972f4e39ab62c03aa34b2096680a875c3fdb3eb2f947cbb93341c05881565b3480156104c957600080fd5b5061026f6104d8366004613486565b61193a565b3480156104e957600080fd5b506002546001600160a01b03166102ba565b34801561050757600080fd5b5061023f6105163660046134f6565b611968565b34801561052757600080fd5b506105636105363660046134de565b60076020526000908152604090208054600282015460039092015460ff8083169361010090930416919084565b6040805194151585529215156020850152918301526060820152608001610216565b34801561059157600080fd5b50610322600081565b3480156105a657600080fd5b5061023f6105b53660046134de565b600a6020526000908152604090205460ff1681565b3480156105d657600080fd5b5061026f6105e53660046134f6565b611991565b3480156105f657600080fd5b5061026f610605366004613643565b6119b6565b34801561061657600080fd5b5061062a6106253660046134de565b611bd8565b60405161021692919061386e565b34801561064457600080fd5b5061026f610653366004613486565b611cdb565b34801561066457600080fd5b506102ba61067336600461376c565b611cef565b34801561068457600080fd5b50610322600080516020613b8683398151915281565b600860205281600052604060002081815481106106b657600080fd5b6000918252602090912060029091020180546001909101549092506001600160a01b0316905082565b60006001600160e01b03198216637965db0b60e01b148061071057506301ffc9a760e01b6001600160e01b03198316145b92915050565b600260015414156107425760405162461bcd60e51b815260040161073990613999565b60405180910390fd5b6002600155600080516020613b8683398151915261075f81611f00565b60008061076b84611f0a565b91509150801561079a57600061077f6122d0565b905061079885846060015165ffffffffffff168361240c565b505b5050600180555050565b600260015414156107c75760405162461bcd60e51b815260040161073990613999565b60026001819055506000600984815481106107f257634e487b7160e01b600052603260045260246000fd5b60009182526020909120600590910201600181015460038201549192509034600160801b9091046001600160801b0316146108635760405162461bcd60e51b8152602060048201526011602482015270141c9a58d9481b9bdd081c995858da1959607a1b6044820152606401610739565b60028083810154600160a01b900460ff169081111561089257634e487b7160e01b600052602160045260246000fd5b14806108cb57506000600283810154600160a01b900460ff16908111156108c957634e487b7160e01b600052602160045260246000fd5b145b6109105760405162461bcd60e51b8152602060048201526016602482015275115b9d1c9e481d1e5c19481b9bdd08185b1b1bddd95960521b6044820152606401610739565b600d54604051630723eb0360e51b81523360048201526001600160a01b039091169063e47d60609060240160206040518083038186803b15801561095357600080fd5b505afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b91906134be565b156109c75760405162461bcd60e51b815260206004820152600c60248201526b426c61636b6c69737465642160a01b6044820152606401610739565b8015610c38576000805b82811015610a3c57856001600160a01b0316846001018281548110610a0657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610a2a5760019150610a3c565b80610a3481613ae9565b9150506109d1565b50600181151514610a8f5760405162461bcd60e51b815260206004820152601a60248201527f4e6f7420696e20726571756972656420636f6c6c656374696f6e0000000000006044820152606401610739565b6040516331a9108f60e11b815260048101859052859033906001600160a01b03831690636352211e9060240160206040518083038186803b158015610ad357600080fd5b505afa158015610ae7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0b91906134a2565b6001600160a01b031614610b615760405162461bcd60e51b815260206004820152601860248201527f4e6f7420746865206f776e6572206f6620746f6b656e496400000000000000006044820152606401610739565b604080516001600160a01b03881660208201529081018890526060810186905260009060800160408051601f1981840301815291815281516020928301206000818152600b9093529120549091506001600160a01b0316610bdf576000818152600b6020526040902080546001600160a01b03191633179055610c34565b6000818152600b60205260409020546001600160a01b03163314610c345760405162461bcd60e51b815260206004820152600c60248201526b1d1bdad95b9259081d5cd95960a21b6044820152606401610739565b5050505b33610c7a5760405162461bcd60e51b81526020600482015260126024820152711b5cd9cb9cd95b99195c881a5cc81b9d5b1b60721b6044820152606401610739565b6001825460ff166007811115610ca057634e487b7160e01b600052602160045260246000fd5b14610ced5760405162461bcd60e51b815260206004820152601960248201527f526166666c65206973206e6f7420696e206163636570746564000000000000006044820152606401610739565b8154610100900465ffffffffffff161580610d335750815465ffffffffffff6101008204811691610d2891600160681b909104166001613a13565b65ffffffffffff1611155b610d7f5760405162461bcd60e51b815260206004820152601960248201527f546f74616c2043617020456e74726965732072656163686564000000000000006044820152606401610739565b6040805133602082015290810186905260009060600160408051601f1981840301815291815281516020928301206000818152600a90935291205490915060ff1615610e0d5760405162461bcd60e51b815260206004820152601760248201527f426f7567687420746f6f206d616e7920656e74726965730000000000000000006044820152606401610739565b604080518082019091528354600091908190610e3990600160681b900465ffffffffffff166001613a13565b65ffffffffffff168152336020918201526000898152600882526040812080546001808201835591835291839020845160029093020191825591830151910180546001600160a01b0319166001600160a01b039092169190911790556004850180549192503491601090610ebe908490600160801b90046001600160801b03166139d0565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555083600001600d9054906101000a900465ffffffffffff166001610f059190613a13565b845465ffffffffffff60681b1916600160681b65ffffffffffff92831681029190911786556000848152600a60209081526040808320805460ff19166001179055885481519490049094168352820152339189917fd746af8dc82f9bed98cea0fe0264eb1c3d2e5f7bcc77fc5efb429c79df407887910160405180910390a35050600180555050505050565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461100b5760405163073e64fd60e21b81523360048201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166024820152604401610739565b61101582826124e0565b5050565b6002600154141561103c5760405162461bcd60e51b815260040161073990613999565b6002600155600080516020613b8683398151915261105981611f00565b600c546040516000916001600160a01b03169084908381818185875af1925050503d80600081146110a6576040519150601f19603f3d011682016040523d82523d6000602084013e6110ab565b606091505b50509050806110f25760405162461bcd60e51b81526020600482015260136024820152724661696c2073656e642045746820746f204d5760681b6044820152606401610739565b50506001805550565b60008281526020819052604090206001015461111681611f00565b61112083836126b9565b505050565b6001600160a01b03811633146111955760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610739565b611015828261273d565b606060086000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561121c5760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b03168284015290835290920191016111d4565b505050509050919050565b6000600080516020613b8683398151915261124181611f00565b6001600160801b0389166112845760405162461bcd60e51b815260206004820152600a60248201526905072697a6520697320360b41b6044820152606401610739565b60408051610180810190915260009080600181526020018565ffffffffffff168152602001600065ffffffffffff168152602001600065ffffffffffff168152602001600065ffffffffffff1681526020018888808060200260200160405190810160405280939291908181526020018383602002808284376000920182905250938552505050602082015260400186600281111561133357634e487b7160e01b600052602160045260246000fd5b81526001600160801b03808c1660208301528a811660408301528c16606082015260006080909101819052600980546001818101835591909252825160059092027f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180549394508493909291839160ff1916908360078111156113c757634e487b7160e01b600052602160045260246000fd5b0217905550602082810151825460408501516060860151608087015165ffffffffffff908116600160981b0265ffffffffffff60981b19928216600160681b02929092166bffffffffffffffffffffffff60681b19938216600160381b0265ffffffffffff60381b199290961661010002919091166cffffffffffffffffffffffff00199094169390931793909317161717825560a08301518051611472926001850192019061336b565b5060c0820151600280830180546001600160a01b039093166001600160a01b031984168117825560e08601519391926001600160a81b03199092161790600160a01b9084908111156114d457634e487b7160e01b600052602160045260246000fd5b02179055506101008201516101208301516001600160801b03918216600160801b918316820217600384015561014084015161016090940151938216938216029290921760049091015560095460405160001991909101918c169082907ff6f5afeb49bc62176d1efaa06a1753999cc29bf378f1004ea916f37f41d7638a90600090a39a9950505050505050505050565b600080516020613b8683398151915261157d81611f00565b50600d80546001600160a01b0319166001600160a01b0392909216919091179055565b600981815481106115b057600080fd5b6000918252602090912060059091020180546002820154600383015460049093015460ff808416955065ffffffffffff6101008504811695600160381b8604821695600160681b8104831695600160981b909104909216936001600160a01b03831693600160a01b909304909216916001600160801b0380831692600160801b9081900482169280831692919004168b565b600080516020613b8683398151915261165a81611f00565b60006009838154811061167d57634e487b7160e01b600052603260045260246000fd5b6000918252602090912060059091020190506003815460ff1660078111156116b557634e487b7160e01b600052602160045260246000fd5b14156116f65760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e4818d85b98d95b195960821b6044820152606401610739565b8054600160681b900465ffffffffffff1680156118145760005b8181101561181257600085815260086020526040812080548390811061174657634e487b7160e01b600052603260045260246000fd5b600091825260208220600291909102016001015460038601546040516001600160a01b0390921692600160801b9091046001600160801b0316919081818185875af1925050503d80600081146117b8576040519150601f19603f3d011682016040523d82523d6000602084013e6117bd565b606091505b50509050806118015760405162461bcd60e51b815260206004820152601060248201526f11985a5b1959081d1bc81c99599d5b9960821b6044820152606401610739565b5061180b81613ae9565b9050611710565b505b8154600360ff65ffffffffffff60981b0119909116600160981b4265ffffffffffff160217178255600482015460408051600160801b9092046001600160801b031682525185917fd512a34b0f0618078770fcd85d974df1ab46a7882e8b3d45aa91764f4961aed2919081900360200190a250505050565b6003546001600160a01b031633146118df5760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b6044820152606401610739565b600280546001600160a01b0319808216339081179093556003805490911690556040516001600160a01b03909116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b600061194581611f00565b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000828152602081905260409020600101546119ac81611f00565b611120838361273d565b600080516020613b868339815191526119ce81611f00565b6000805b84811015611b8c576000878152600860205260408120878784818110611a0857634e487b7160e01b600052603260045260246000fd5b9050602002013581548110611a2d57634e487b7160e01b600052603260045260246000fd5b6000918252602090912060029091020160018101549091506001600160a01b03868116911614611a9f5760405162461bcd60e51b815260206004820152601e60248201527f456e74727920646964206e6f742062656c6f6e6720746f20706c6179657200006044820152606401610739565b6001810180546001600160a01b03191690556000878784818110611ad357634e487b7160e01b600052603260045260246000fd5b9050602002013560001415611aea57506000611b5e565b60008981526008602052604090206001898986818110611b1a57634e487b7160e01b600052603260045260246000fd5b90506020020135611b2b9190613a8f565b81548110611b4957634e487b7160e01b600052603260045260246000fd5b90600052602060002090600202016000015490505b8154611b6b908290613a8f565b611b7590856139fb565b935050508080611b8490613ae9565b9150506119d2565b50604080518281526001600160a01b038516602082015287917f2cca80c1af5abb202a642a502875436822768d733462843a7c3a902b0fad99d0910160405180910390a2505050505050565b600081815260076020526040812054606090610100900460ff16611c325760405162461bcd60e51b81526020600482015260116024820152701c995c5d595cdd081b9bdd08199bdd5b99607a1b6044820152606401610739565b6000838152600760209081526040808320815160a081018352815460ff8082161515835261010090910416151581850152600182018054845181870281018701865281815292959394860193830182828015611cad57602002820191906000526020600020905b815481526020019060010190808311611c99575b5050509183525050600282015460208201526003909101546040918201528151910151909590945092505050565b611ce36127a2565b611cec816127f7565b50565b600082815260086020908152604080832080548251818502810185019093528083528493611d7193929190859084015b82821015611d675760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b0316828401529083529092019101611d1f565b50505050846128a2565b60008581526008602052604081208054929350909183908110611da457634e487b7160e01b600052603260045260246000fd5b60009182526020909120600160029092020101546001600160a01b031690508015611dd25791506107109050565b6000825b81158015611e2c57506000878152600860205260408120805483908110611e0d57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600160029092020101546001600160a01b0316145b15611e635780611e5857600087815260086020526040902054611e5190600190613a8f565b9050611dd6565b611e51600182613a8f565b8115611ea95760405162461bcd60e51b8152602060048201526015602482015274105b1b081d5cd95c9cc8189b1858dadb1a5cdd1959605a1b6044820152606401610739565b6000878152600860205260409020805482908110611ed757634e487b7160e01b600052603260045260246000fd5b60009182526020909120600160029092020101546001600160a01b031694506107109350505050565b611cec8133612986565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a082015260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915260008060098481548110611f8e57634e487b7160e01b600052603260045260246000fd5b600091825260209091206005909102018054909150600160681b900465ffffffffffff16611ffe5760405162461bcd60e51b815260206004820152601d60248201527f4e6f207061727469636970616e747320696e2074686520726166666c650000006044820152606401610739565b6001815460ff16600781111561202457634e487b7160e01b600052602160045260246000fd5b1461206a5760405162461bcd60e51b8152602060048201526016602482015275526166666c6520696e2077726f6e672073746174757360501b6044820152606401610739565b8054600460ff199091168117825581015460408051600160801b9092046001600160801b031682525185917ff2be214756d2fbc1e781d10809ddef33000009d805be55356bb348134ce21c68919081900360200190a2805465ffffffffffff61010082048116600160681b909204161015612297576120ea8460016129ea565b604080516101808101909152815482916000918390829060ff16600781111561212357634e487b7160e01b600052602160045260246000fd5b600781111561214257634e487b7160e01b600052602160045260246000fd5b8152815465ffffffffffff61010082048116602080850191909152600160381b83048216604080860191909152600160681b840483166060860152600160981b909304909116608084015260018401805483518184028101840190945280845260a09094019390918301828280156121e357602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116121c5575b50505091835250506002828101546001600160a01b0381166020840152604090920191600160a01b900460ff169081111561222e57634e487b7160e01b600052602160045260246000fd5b600281111561224d57634e487b7160e01b600052602160045260246000fd5b815260038201546001600160801b038082166020840152600160801b9182900481166040840152600490930154808416606084015204909116608090910152969095509350505050565b604080516101808101909152815482916001918390829060ff16600781111561212357634e487b7160e01b600052602160045260246000fd5b600480546040516305d3b1d360e41b81527f0000000000000000000000000000000000000000000000000000000000000000928101929092527f000000000000000000000000000000000000000000000000000000000000000067ffffffffffffffff1660248301527f000000000000000000000000000000000000000000000000000000000000000061ffff16604483015263ffffffff600160a01b8204811660648401527f00000000000000000000000000000000000000000000000000000000000000001660848301526000916001600160a01b0390911690635d3b1d309060a401602060405180830381600087803b1580156123cf57600080fd5b505af11580156123e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240791906135f4565b905090565b6040805160a081018252600080825260016020808401919091528351828152908101845291928301919050815260208082018690526040918201859052600084815260078252829020835181548584015115156101000261ff00199215159290921661ffff199091161717815591830151805161248f92600185019201906133d0565b506060820151600282015560809091015160039091015560405182815283907f05a7714ffa9c24d72553c49c132db52354eb21df8a76cefa9def229b276feeb49060200160405180910390a2505050565b600082815260076020526040902054610100900460ff166125375760405162461bcd60e51b81526020600482015260116024820152701c995c5d595cdd081b9bdd08199bdd5b99607a1b6044820152606401610739565b6000828152600760209081526040909120805460ff19166001908117825583516125689392909101918401906133d0565b5060008281526007602052604081206003015482518390839061259b57634e487b7160e01b600052603260045260246000fd5b60200260200101516125ad9190613b04565b6125b89060016139fb565b600084815260076020526040812060020154600980549394509092839081106125f157634e487b7160e01b600052603260045260246000fd5b60009182526020909120600590910201805460ff1916600417808255909150600160681b810465ffffffffffff9081166101009092041614156126a857817f7c40e661b8212d0c4f60ac6e6ebed99c28680c7b3ede5b82f3b0254543f62fca8560008151811061267157634e487b7160e01b600052603260045260246000fd5b602002602001015185604051612691929190918252602082015260400190565b60405180910390a26126a38284612e04565b6126b2565b6126b282846129ea565b5050505050565b6126c38282611968565b611015576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556126f93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6127478282611968565b15611015576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6002546001600160a01b031633146127f55760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b6044820152606401610739565b565b6001600160a01b0381163314156128505760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610739565b600380546001600160a01b0319166001600160a01b03838116918217909255600254604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b60008251600014156128b657506000610710565b82516000905b808210156129215760006128d08383613167565b9050848682815181106128f357634e487b7160e01b600052603260045260246000fd5b602002602001015160000151111561290d5780915061291b565b6129188160016139fb565b92505b506128bc565b60008211801561296557508385612939600185613a8f565b8151811061295757634e487b7160e01b600052603260045260246000fd5b602002602001015160000151145b1561297e57612975600183613a8f565b92505050610710565b509050610710565b6129908282611968565b611015576129a8816001600160a01b03166014613189565b6129b3836020613189565b6040516020016129c49291906137a1565b60408051601f198184030181529082905262461bcd60e51b825261073991600401613966565b600060098381548110612a0d57634e487b7160e01b600052603260045260246000fd5b6000918252602090912060059091020190506004815460ff166007811115612a4557634e487b7160e01b600052602160045260246000fd5b14612a815760405162461bcd60e51b815260206004820152600c60248201526b57726f6e672073746174757360a01b6044820152606401610739565b8054600160681b900465ffffffffffff168015611814576003820154600160801b90046001600160801b0316612ab8600183613a8f565b612ac29082613a48565b6003840154612ada91906001600160801b03166139fb565b4711612b1d5760405162461bcd60e51b81526020600482015260126024820152714e6f7420656e6f7567682062616c616e636560701b6044820152606401610739565b825460ff1916600717835560008581526008602052604081208054909190612b5557634e487b7160e01b600052603260045260246000fd5b60009182526020918290206002918202016001015490850180546001600160a01b039092166001600160a01b031990921682179055845465ffffffffffff60381b1916600160381b65ffffffffffff88160217855560038501546004860154604080519384526001600160801b0392831694840194909452928201879052600160801b909204909116606082015285907fbd4056fa65406f11c67bd9e859f610a1741c647300e504c129aad50a597f41589060800160405180910390a260005b82811015612dfb5780612d10576000868152600860205260408120805483908110612c5057634e487b7160e01b600052603260045260246000fd5b6000918252602082206002909102016001015460038701546040516001600160a01b03909216926001600160801b03909116919081818185875af1925050503d8060008114612cbb576040519150601f19603f3d011682016040523d82523d6000602084013e612cc0565b606091505b5050905080612d0a5760405162461bcd60e51b81526020600482015260166024820152754661696c656420746f2073656e64204574686572203160501b6044820152606401610739565b50612deb565b6000868152600860205260408120805483908110612d3e57634e487b7160e01b600052603260045260246000fd5b600091825260208220600290910201600101546040516001600160a01b039091169185919081818185875af1925050503d8060008114612d9a576040519150601f19603f3d011682016040523d82523d6000602084013e612d9f565b606091505b5050905080612de95760405162461bcd60e51b81526020600482015260166024820152752330b4b632b2103a379039b2b7321022ba3432b9101960511b6044820152606401610739565b505b612df481613ae9565b9050612c15565b50505b50505050565b60026001541415612e275760405162461bcd60e51b815260040161073990613999565b6002600181905550600060098381548110612e5257634e487b7160e01b600052603260045260246000fd5b6000918252602090912060059091020190506002815460ff166007811115612e8a57634e487b7160e01b600052602160045260246000fd5b1480612eb957506004815460ff166007811115612eb757634e487b7160e01b600052602160045260246000fd5b145b612efe5760405162461bcd60e51b8152602060048201526016602482015275526166666c6520696e2077726f6e672073746174757360501b6044820152606401610739565b805465ffffffffffff60381b1916600160381b65ffffffffffff841602178155612f288383611cef565b6002820180546001600160a01b03929092166001600160a01b031990921682179055815460ff191660051782556004820154604051600092916001600160801b0316908381818185875af1925050503d8060008114612fa3576040519150601f19603f3d011682016040523d82523d6000602084013e612fa8565b606091505b5050905080612ff05760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610739565b6004820154600090613015906001600160801b0380821691600160801b900416613a67565b600c546040516001600160801b039290921692506000916001600160a01b039091169083908381818185875af1925050503d8060008114613072576040519150601f19603f3d011682016040523d82523d6000602084013e613077565b606091505b50509050806130c05760405162461bcd60e51b81526020600482015260156024820152744661696c65642073656e642045746820746f204d5760581b6044820152606401610739565b857f7378e11c2b0ec7514bbf7ba369980eedcba0bca03e116dc9e7138f7748e211d6836040516130f291815260200190565b60405180910390a26002840154600485015460408051600160801b9092046001600160801b03168252602082018890526001600160a01b039092169188917fe0b2a72a0644b093aac275024c05c7c28851a0b572557a32241d13634a0f3e08910160405180910390a350506001805550505050565b60006131766002848418613a34565b613182908484166139fb565b9392505050565b60606000613198836002613a48565b6131a39060026139fb565b67ffffffffffffffff8111156131c957634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156131f3576020820181803683370190505b509050600360fc1b8160008151811061321c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061325957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061327d846002613a48565b6132889060016139fb565b90505b600181111561331c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106132ca57634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106132ee57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361331581613ad2565b905061328b565b5083156131825760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610739565b8280548282559060005260206000209081019282156133c0579160200282015b828111156133c057825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061338b565b506133cc92915061340b565b5090565b8280548282559060005260206000209081019282156133c0579160200282015b828111156133c05782518255916020019190600101906133f0565b5b808211156133cc576000815560010161340c565b60008083601f840112613431578182fd5b50813567ffffffffffffffff811115613448578182fd5b6020830191508360208260051b850101111561346357600080fd5b9250929050565b80356001600160801b038116811461348157600080fd5b919050565b600060208284031215613497578081fd5b813561318281613b70565b6000602082840312156134b3578081fd5b815161318281613b70565b6000602082840312156134cf578081fd5b81518015158114613182578182fd5b6000602082840312156134ef578081fd5b5035919050565b60008060408385031215613508578081fd5b82359150602083013561351a81613b70565b809150509250929050565b600060208284031215613536578081fd5b81356001600160e01b031981168114613182578182fd5b600080600080600080600060c0888a031215613567578283fd5b6135708861346a565b965061357e6020890161346a565b955061358c6040890161346a565b9450606088013567ffffffffffffffff8111156135a7578384fd5b6135b38a828b01613420565b9095509350506080880135600381106135ca578283fd5b915060a088013565ffffffffffff811681146135e4578182fd5b8091505092959891949750929550565b600060208284031215613605578081fd5b5051919050565b600080600060608486031215613620578283fd5b83359250602084013561363281613b70565b929592945050506040919091013590565b60008060008060608587031215613658578182fd5b84359350602085013567ffffffffffffffff811115613675578283fd5b61368187828801613420565b909450925050604085013561369581613b70565b939692955090935050565b600080604083850312156136b2578182fd5b8235915060208084013567ffffffffffffffff808211156136d1578384fd5b818601915086601f8301126136e4578384fd5b8135818111156136f6576136f6613b5a565b8060051b604051601f19603f8301168101818110858211171561371b5761371b613b5a565b604052828152858101935084860182860187018b1015613739578788fd5b8795505b8386101561375b57803585526001959095019493860193860161373d565b508096505050505050509250929050565b6000806040838503121561377e578182fd5b50508035926020909101359150565b6003811061379d5761379d613b44565b9052565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516137d9816017850160208801613aa6565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161380a816028840160208801613aa6565b01602801949350505050565b602080825282518282018190526000919060409081850190868401855b82811015613861578151805185528601516001600160a01b0316868501529284019290850190600101613833565b5091979650505050505050565b600060408201841515835260206040818501528185518084526060860191508287019350845b818110156138b057845183529383019391830191600101613894565b5090979650505050505050565b610160810160088d106138d2576138d2613b44565b8c825265ffffffffffff8c811660208401528b811660408401528a81166060840152891660808301526001600160a01b03881660a083015261391760c083018861378d565b6001600160801b03861660e08301526001600160801b0385166101008301526001600160801b0384166101208301526001600160801b0383166101408301529c9b505050505050505050505050565b6020815260008251806020840152613985816040850160208701613aa6565b601f01601f19169190910160400192915050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006001600160801b038083168185168083038211156139f2576139f2613b18565b01949350505050565b60008219821115613a0e57613a0e613b18565b500190565b600065ffffffffffff8083168185168083038211156139f2576139f2613b18565b600082613a4357613a43613b2e565b500490565b6000816000190483118215151615613a6257613a62613b18565b500290565b60006001600160801b0383811690831681811015613a8757613a87613b18565b039392505050565b600082821015613aa157613aa1613b18565b500390565b60005b83811015613ac1578181015183820152602001613aa9565b83811115612dfe5750506000910152565b600081613ae157613ae1613b18565b506000190190565b6000600019821415613afd57613afd613b18565b5060010190565b600082613b1357613b13613b2e565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611cec57600080fdfe523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0ca26469706673582212200d9bc7746d500ccb62f2c1552b50ccfe8445e25fd55f30a8c91781b4fa7ffe3164736f6c63430008040033523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c0000000000000000000000003be4bef162cd158887cfdca89a34fae107ab2c740000000000000000000000000000000000000000000000000000000000000254000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e699098af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef

Deployed Bytecode

0x6080604052600436106101d15760003560e01c80635fba3171116100f7578063a217fddf11610095578063d8a4676f11610064578063d8a4676f1461060a578063f2fde38b14610638578063f369145514610658578063f5b541a61461067857600080fd5b8063a217fddf14610585578063baf029051461059a578063d547741f146105ca578063d649214c146105ea57600080fd5b80637fa4cacb116100d15780637fa4cacb146104bd5780638da5cb5b146104dd57806391d14854146104fb578063a168fa891461051b57600080fd5b80635fba31711461045457806379ba5097146104745780637c903fc01461048957600080fd5b80632e1a7d4d1161016f5780633c891f291161013e5780633c891f29146103bd5780633fa2c575146103dd57806353b7a59b146103fd5780635d4bc0ce1461041d57600080fd5b80632e1a7d4d146103305780632f2ff15d1461035057806336568abe14610370578063365e36581461039057600080fd5b806315614f3e116101ab57806315614f3e146102715780631a0187f5146102845780631fe543e3146102d2578063248a9ca3146102f257600080fd5b8063013805c5146101dd57806301ffc9a71461021f5780630df716021461024f57600080fd5b366101d857005b600080fd5b3480156101e957600080fd5b506101fd6101f836600461376c565b61069a565b604080519283526001600160a01b039091166020830152015b60405180910390f35b34801561022b57600080fd5b5061023f61023a366004613525565b6106df565b6040519015158152602001610216565b34801561025b57600080fd5b5061026f61026a3660046134de565b610716565b005b61026f61027f36600461360c565b6107a4565b34801561029057600080fd5b506102ba61029f3660046134de565b600b602052600090815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610216565b3480156102de57600080fd5b5061026f6102ed3660046136a0565b610f91565b3480156102fe57600080fd5b5061032261030d3660046134de565b60009081526020819052604090206001015490565b604051908152602001610216565b34801561033c57600080fd5b5061026f61034b3660046134de565b611019565b34801561035c57600080fd5b5061026f61036b3660046134f6565b6110fb565b34801561037c57600080fd5b5061026f61038b3660046134f6565b611125565b34801561039c57600080fd5b506103b06103ab3660046134de565b61119f565b6040516102169190613816565b3480156103c957600080fd5b506103226103d836600461354d565b611227565b3480156103e957600080fd5b5061026f6103f8366004613486565b611565565b34801561040957600080fd5b50600c546102ba906001600160a01b031681565b34801561042957600080fd5b5061043d6104383660046134de565b6115a0565b6040516102169b9a999897969594939291906138bd565b34801561046057600080fd5b5061026f61046f3660046134de565b611642565b34801561048057600080fd5b5061026f61188c565b34801561049557600080fd5b506103227fde5ee446972f4e39ab62c03aa34b2096680a875c3fdb3eb2f947cbb93341c05881565b3480156104c957600080fd5b5061026f6104d8366004613486565b61193a565b3480156104e957600080fd5b506002546001600160a01b03166102ba565b34801561050757600080fd5b5061023f6105163660046134f6565b611968565b34801561052757600080fd5b506105636105363660046134de565b60076020526000908152604090208054600282015460039092015460ff8083169361010090930416919084565b6040805194151585529215156020850152918301526060820152608001610216565b34801561059157600080fd5b50610322600081565b3480156105a657600080fd5b5061023f6105b53660046134de565b600a6020526000908152604090205460ff1681565b3480156105d657600080fd5b5061026f6105e53660046134f6565b611991565b3480156105f657600080fd5b5061026f610605366004613643565b6119b6565b34801561061657600080fd5b5061062a6106253660046134de565b611bd8565b60405161021692919061386e565b34801561064457600080fd5b5061026f610653366004613486565b611cdb565b34801561066457600080fd5b506102ba61067336600461376c565b611cef565b34801561068457600080fd5b50610322600080516020613b8683398151915281565b600860205281600052604060002081815481106106b657600080fd5b6000918252602090912060029091020180546001909101549092506001600160a01b0316905082565b60006001600160e01b03198216637965db0b60e01b148061071057506301ffc9a760e01b6001600160e01b03198316145b92915050565b600260015414156107425760405162461bcd60e51b815260040161073990613999565b60405180910390fd5b6002600155600080516020613b8683398151915261075f81611f00565b60008061076b84611f0a565b91509150801561079a57600061077f6122d0565b905061079885846060015165ffffffffffff168361240c565b505b5050600180555050565b600260015414156107c75760405162461bcd60e51b815260040161073990613999565b60026001819055506000600984815481106107f257634e487b7160e01b600052603260045260246000fd5b60009182526020909120600590910201600181015460038201549192509034600160801b9091046001600160801b0316146108635760405162461bcd60e51b8152602060048201526011602482015270141c9a58d9481b9bdd081c995858da1959607a1b6044820152606401610739565b60028083810154600160a01b900460ff169081111561089257634e487b7160e01b600052602160045260246000fd5b14806108cb57506000600283810154600160a01b900460ff16908111156108c957634e487b7160e01b600052602160045260246000fd5b145b6109105760405162461bcd60e51b8152602060048201526016602482015275115b9d1c9e481d1e5c19481b9bdd08185b1b1bddd95960521b6044820152606401610739565b600d54604051630723eb0360e51b81523360048201526001600160a01b039091169063e47d60609060240160206040518083038186803b15801561095357600080fd5b505afa158015610967573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061098b91906134be565b156109c75760405162461bcd60e51b815260206004820152600c60248201526b426c61636b6c69737465642160a01b6044820152606401610739565b8015610c38576000805b82811015610a3c57856001600160a01b0316846001018281548110610a0657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03161415610a2a5760019150610a3c565b80610a3481613ae9565b9150506109d1565b50600181151514610a8f5760405162461bcd60e51b815260206004820152601a60248201527f4e6f7420696e20726571756972656420636f6c6c656374696f6e0000000000006044820152606401610739565b6040516331a9108f60e11b815260048101859052859033906001600160a01b03831690636352211e9060240160206040518083038186803b158015610ad357600080fd5b505afa158015610ae7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b0b91906134a2565b6001600160a01b031614610b615760405162461bcd60e51b815260206004820152601860248201527f4e6f7420746865206f776e6572206f6620746f6b656e496400000000000000006044820152606401610739565b604080516001600160a01b03881660208201529081018890526060810186905260009060800160408051601f1981840301815291815281516020928301206000818152600b9093529120549091506001600160a01b0316610bdf576000818152600b6020526040902080546001600160a01b03191633179055610c34565b6000818152600b60205260409020546001600160a01b03163314610c345760405162461bcd60e51b815260206004820152600c60248201526b1d1bdad95b9259081d5cd95960a21b6044820152606401610739565b5050505b33610c7a5760405162461bcd60e51b81526020600482015260126024820152711b5cd9cb9cd95b99195c881a5cc81b9d5b1b60721b6044820152606401610739565b6001825460ff166007811115610ca057634e487b7160e01b600052602160045260246000fd5b14610ced5760405162461bcd60e51b815260206004820152601960248201527f526166666c65206973206e6f7420696e206163636570746564000000000000006044820152606401610739565b8154610100900465ffffffffffff161580610d335750815465ffffffffffff6101008204811691610d2891600160681b909104166001613a13565b65ffffffffffff1611155b610d7f5760405162461bcd60e51b815260206004820152601960248201527f546f74616c2043617020456e74726965732072656163686564000000000000006044820152606401610739565b6040805133602082015290810186905260009060600160408051601f1981840301815291815281516020928301206000818152600a90935291205490915060ff1615610e0d5760405162461bcd60e51b815260206004820152601760248201527f426f7567687420746f6f206d616e7920656e74726965730000000000000000006044820152606401610739565b604080518082019091528354600091908190610e3990600160681b900465ffffffffffff166001613a13565b65ffffffffffff168152336020918201526000898152600882526040812080546001808201835591835291839020845160029093020191825591830151910180546001600160a01b0319166001600160a01b039092169190911790556004850180549192503491601090610ebe908490600160801b90046001600160801b03166139d0565b92506101000a8154816001600160801b0302191690836001600160801b0316021790555083600001600d9054906101000a900465ffffffffffff166001610f059190613a13565b845465ffffffffffff60681b1916600160681b65ffffffffffff92831681029190911786556000848152600a60209081526040808320805460ff19166001179055885481519490049094168352820152339189917fd746af8dc82f9bed98cea0fe0264eb1c3d2e5f7bcc77fc5efb429c79df407887910160405180910390a35050600180555050505050565b336001600160a01b037f000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909161461100b5760405163073e64fd60e21b81523360048201526001600160a01b037f000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909166024820152604401610739565b61101582826124e0565b5050565b6002600154141561103c5760405162461bcd60e51b815260040161073990613999565b6002600155600080516020613b8683398151915261105981611f00565b600c546040516000916001600160a01b03169084908381818185875af1925050503d80600081146110a6576040519150601f19603f3d011682016040523d82523d6000602084013e6110ab565b606091505b50509050806110f25760405162461bcd60e51b81526020600482015260136024820152724661696c2073656e642045746820746f204d5760681b6044820152606401610739565b50506001805550565b60008281526020819052604090206001015461111681611f00565b61112083836126b9565b505050565b6001600160a01b03811633146111955760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610739565b611015828261273d565b606060086000838152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b8282101561121c5760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b03168284015290835290920191016111d4565b505050509050919050565b6000600080516020613b8683398151915261124181611f00565b6001600160801b0389166112845760405162461bcd60e51b815260206004820152600a60248201526905072697a6520697320360b41b6044820152606401610739565b60408051610180810190915260009080600181526020018565ffffffffffff168152602001600065ffffffffffff168152602001600065ffffffffffff168152602001600065ffffffffffff1681526020018888808060200260200160405190810160405280939291908181526020018383602002808284376000920182905250938552505050602082015260400186600281111561133357634e487b7160e01b600052602160045260246000fd5b81526001600160801b03808c1660208301528a811660408301528c16606082015260006080909101819052600980546001818101835591909252825160059092027f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180549394508493909291839160ff1916908360078111156113c757634e487b7160e01b600052602160045260246000fd5b0217905550602082810151825460408501516060860151608087015165ffffffffffff908116600160981b0265ffffffffffff60981b19928216600160681b02929092166bffffffffffffffffffffffff60681b19938216600160381b0265ffffffffffff60381b199290961661010002919091166cffffffffffffffffffffffff00199094169390931793909317161717825560a08301518051611472926001850192019061336b565b5060c0820151600280830180546001600160a01b039093166001600160a01b031984168117825560e08601519391926001600160a81b03199092161790600160a01b9084908111156114d457634e487b7160e01b600052602160045260246000fd5b02179055506101008201516101208301516001600160801b03918216600160801b918316820217600384015561014084015161016090940151938216938216029290921760049091015560095460405160001991909101918c169082907ff6f5afeb49bc62176d1efaa06a1753999cc29bf378f1004ea916f37f41d7638a90600090a39a9950505050505050505050565b600080516020613b8683398151915261157d81611f00565b50600d80546001600160a01b0319166001600160a01b0392909216919091179055565b600981815481106115b057600080fd5b6000918252602090912060059091020180546002820154600383015460049093015460ff808416955065ffffffffffff6101008504811695600160381b8604821695600160681b8104831695600160981b909104909216936001600160a01b03831693600160a01b909304909216916001600160801b0380831692600160801b9081900482169280831692919004168b565b600080516020613b8683398151915261165a81611f00565b60006009838154811061167d57634e487b7160e01b600052603260045260246000fd5b6000918252602090912060059091020190506003815460ff1660078111156116b557634e487b7160e01b600052602160045260246000fd5b14156116f65760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e4818d85b98d95b195960821b6044820152606401610739565b8054600160681b900465ffffffffffff1680156118145760005b8181101561181257600085815260086020526040812080548390811061174657634e487b7160e01b600052603260045260246000fd5b600091825260208220600291909102016001015460038601546040516001600160a01b0390921692600160801b9091046001600160801b0316919081818185875af1925050503d80600081146117b8576040519150601f19603f3d011682016040523d82523d6000602084013e6117bd565b606091505b50509050806118015760405162461bcd60e51b815260206004820152601060248201526f11985a5b1959081d1bc81c99599d5b9960821b6044820152606401610739565b5061180b81613ae9565b9050611710565b505b8154600360ff65ffffffffffff60981b0119909116600160981b4265ffffffffffff160217178255600482015460408051600160801b9092046001600160801b031682525185917fd512a34b0f0618078770fcd85d974df1ab46a7882e8b3d45aa91764f4961aed2919081900360200190a250505050565b6003546001600160a01b031633146118df5760405162461bcd60e51b815260206004820152601660248201527526bab9ba10313290383937b837b9b2b21037bbb732b960511b6044820152606401610739565b600280546001600160a01b0319808216339081179093556003805490911690556040516001600160a01b03909116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a350565b600061194581611f00565b50600c80546001600160a01b0319166001600160a01b0392909216919091179055565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000828152602081905260409020600101546119ac81611f00565b611120838361273d565b600080516020613b868339815191526119ce81611f00565b6000805b84811015611b8c576000878152600860205260408120878784818110611a0857634e487b7160e01b600052603260045260246000fd5b9050602002013581548110611a2d57634e487b7160e01b600052603260045260246000fd5b6000918252602090912060029091020160018101549091506001600160a01b03868116911614611a9f5760405162461bcd60e51b815260206004820152601e60248201527f456e74727920646964206e6f742062656c6f6e6720746f20706c6179657200006044820152606401610739565b6001810180546001600160a01b03191690556000878784818110611ad357634e487b7160e01b600052603260045260246000fd5b9050602002013560001415611aea57506000611b5e565b60008981526008602052604090206001898986818110611b1a57634e487b7160e01b600052603260045260246000fd5b90506020020135611b2b9190613a8f565b81548110611b4957634e487b7160e01b600052603260045260246000fd5b90600052602060002090600202016000015490505b8154611b6b908290613a8f565b611b7590856139fb565b935050508080611b8490613ae9565b9150506119d2565b50604080518281526001600160a01b038516602082015287917f2cca80c1af5abb202a642a502875436822768d733462843a7c3a902b0fad99d0910160405180910390a2505050505050565b600081815260076020526040812054606090610100900460ff16611c325760405162461bcd60e51b81526020600482015260116024820152701c995c5d595cdd081b9bdd08199bdd5b99607a1b6044820152606401610739565b6000838152600760209081526040808320815160a081018352815460ff8082161515835261010090910416151581850152600182018054845181870281018701865281815292959394860193830182828015611cad57602002820191906000526020600020905b815481526020019060010190808311611c99575b5050509183525050600282015460208201526003909101546040918201528151910151909590945092505050565b611ce36127a2565b611cec816127f7565b50565b600082815260086020908152604080832080548251818502810185019093528083528493611d7193929190859084015b82821015611d675760008481526020908190206040805180820190915260028502909101805482526001908101546001600160a01b0316828401529083529092019101611d1f565b50505050846128a2565b60008581526008602052604081208054929350909183908110611da457634e487b7160e01b600052603260045260246000fd5b60009182526020909120600160029092020101546001600160a01b031690508015611dd25791506107109050565b6000825b81158015611e2c57506000878152600860205260408120805483908110611e0d57634e487b7160e01b600052603260045260246000fd5b60009182526020909120600160029092020101546001600160a01b0316145b15611e635780611e5857600087815260086020526040902054611e5190600190613a8f565b9050611dd6565b611e51600182613a8f565b8115611ea95760405162461bcd60e51b8152602060048201526015602482015274105b1b081d5cd95c9cc8189b1858dadb1a5cdd1959605a1b6044820152606401610739565b6000878152600860205260409020805482908110611ed757634e487b7160e01b600052603260045260246000fd5b60009182526020909120600160029092020101546001600160a01b031694506107109350505050565b611cec8133612986565b604080516101808101825260008082526020820181905291810182905260608082018390526080820183905260a082015260c0810182905260e0810182905261010081018290526101208101829052610140810182905261016081019190915260008060098481548110611f8e57634e487b7160e01b600052603260045260246000fd5b600091825260209091206005909102018054909150600160681b900465ffffffffffff16611ffe5760405162461bcd60e51b815260206004820152601d60248201527f4e6f207061727469636970616e747320696e2074686520726166666c650000006044820152606401610739565b6001815460ff16600781111561202457634e487b7160e01b600052602160045260246000fd5b1461206a5760405162461bcd60e51b8152602060048201526016602482015275526166666c6520696e2077726f6e672073746174757360501b6044820152606401610739565b8054600460ff199091168117825581015460408051600160801b9092046001600160801b031682525185917ff2be214756d2fbc1e781d10809ddef33000009d805be55356bb348134ce21c68919081900360200190a2805465ffffffffffff61010082048116600160681b909204161015612297576120ea8460016129ea565b604080516101808101909152815482916000918390829060ff16600781111561212357634e487b7160e01b600052602160045260246000fd5b600781111561214257634e487b7160e01b600052602160045260246000fd5b8152815465ffffffffffff61010082048116602080850191909152600160381b83048216604080860191909152600160681b840483166060860152600160981b909304909116608084015260018401805483518184028101840190945280845260a09094019390918301828280156121e357602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116121c5575b50505091835250506002828101546001600160a01b0381166020840152604090920191600160a01b900460ff169081111561222e57634e487b7160e01b600052602160045260246000fd5b600281111561224d57634e487b7160e01b600052602160045260246000fd5b815260038201546001600160801b038082166020840152600160801b9182900481166040840152600490930154808416606084015204909116608090910152969095509350505050565b604080516101808101909152815482916001918390829060ff16600781111561212357634e487b7160e01b600052602160045260246000fd5b600480546040516305d3b1d360e41b81527f8af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef928101929092527f000000000000000000000000000000000000000000000000000000000000025467ffffffffffffffff1660248301527f000000000000000000000000000000000000000000000000000000000000000361ffff16604483015263ffffffff600160a01b8204811660648401527f00000000000000000000000000000000000000000000000000000000000000051660848301526000916001600160a01b0390911690635d3b1d309060a401602060405180830381600087803b1580156123cf57600080fd5b505af11580156123e3573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240791906135f4565b905090565b6040805160a081018252600080825260016020808401919091528351828152908101845291928301919050815260208082018690526040918201859052600084815260078252829020835181548584015115156101000261ff00199215159290921661ffff199091161717815591830151805161248f92600185019201906133d0565b506060820151600282015560809091015160039091015560405182815283907f05a7714ffa9c24d72553c49c132db52354eb21df8a76cefa9def229b276feeb49060200160405180910390a2505050565b600082815260076020526040902054610100900460ff166125375760405162461bcd60e51b81526020600482015260116024820152701c995c5d595cdd081b9bdd08199bdd5b99607a1b6044820152606401610739565b6000828152600760209081526040909120805460ff19166001908117825583516125689392909101918401906133d0565b5060008281526007602052604081206003015482518390839061259b57634e487b7160e01b600052603260045260246000fd5b60200260200101516125ad9190613b04565b6125b89060016139fb565b600084815260076020526040812060020154600980549394509092839081106125f157634e487b7160e01b600052603260045260246000fd5b60009182526020909120600590910201805460ff1916600417808255909150600160681b810465ffffffffffff9081166101009092041614156126a857817f7c40e661b8212d0c4f60ac6e6ebed99c28680c7b3ede5b82f3b0254543f62fca8560008151811061267157634e487b7160e01b600052603260045260246000fd5b602002602001015185604051612691929190918252602082015260400190565b60405180910390a26126a38284612e04565b6126b2565b6126b282846129ea565b5050505050565b6126c38282611968565b611015576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556126f93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6127478282611968565b15611015576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6002546001600160a01b031633146127f55760405162461bcd60e51b815260206004820152601660248201527527b7363c9031b0b63630b1363290313c9037bbb732b960511b6044820152606401610739565b565b6001600160a01b0381163314156128505760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207472616e7366657220746f2073656c660000000000000000006044820152606401610739565b600380546001600160a01b0319166001600160a01b03838116918217909255600254604051919216907fed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae127890600090a350565b60008251600014156128b657506000610710565b82516000905b808210156129215760006128d08383613167565b9050848682815181106128f357634e487b7160e01b600052603260045260246000fd5b602002602001015160000151111561290d5780915061291b565b6129188160016139fb565b92505b506128bc565b60008211801561296557508385612939600185613a8f565b8151811061295757634e487b7160e01b600052603260045260246000fd5b602002602001015160000151145b1561297e57612975600183613a8f565b92505050610710565b509050610710565b6129908282611968565b611015576129a8816001600160a01b03166014613189565b6129b3836020613189565b6040516020016129c49291906137a1565b60408051601f198184030181529082905262461bcd60e51b825261073991600401613966565b600060098381548110612a0d57634e487b7160e01b600052603260045260246000fd5b6000918252602090912060059091020190506004815460ff166007811115612a4557634e487b7160e01b600052602160045260246000fd5b14612a815760405162461bcd60e51b815260206004820152600c60248201526b57726f6e672073746174757360a01b6044820152606401610739565b8054600160681b900465ffffffffffff168015611814576003820154600160801b90046001600160801b0316612ab8600183613a8f565b612ac29082613a48565b6003840154612ada91906001600160801b03166139fb565b4711612b1d5760405162461bcd60e51b81526020600482015260126024820152714e6f7420656e6f7567682062616c616e636560701b6044820152606401610739565b825460ff1916600717835560008581526008602052604081208054909190612b5557634e487b7160e01b600052603260045260246000fd5b60009182526020918290206002918202016001015490850180546001600160a01b039092166001600160a01b031990921682179055845465ffffffffffff60381b1916600160381b65ffffffffffff88160217855560038501546004860154604080519384526001600160801b0392831694840194909452928201879052600160801b909204909116606082015285907fbd4056fa65406f11c67bd9e859f610a1741c647300e504c129aad50a597f41589060800160405180910390a260005b82811015612dfb5780612d10576000868152600860205260408120805483908110612c5057634e487b7160e01b600052603260045260246000fd5b6000918252602082206002909102016001015460038701546040516001600160a01b03909216926001600160801b03909116919081818185875af1925050503d8060008114612cbb576040519150601f19603f3d011682016040523d82523d6000602084013e612cc0565b606091505b5050905080612d0a5760405162461bcd60e51b81526020600482015260166024820152754661696c656420746f2073656e64204574686572203160501b6044820152606401610739565b50612deb565b6000868152600860205260408120805483908110612d3e57634e487b7160e01b600052603260045260246000fd5b600091825260208220600290910201600101546040516001600160a01b039091169185919081818185875af1925050503d8060008114612d9a576040519150601f19603f3d011682016040523d82523d6000602084013e612d9f565b606091505b5050905080612de95760405162461bcd60e51b81526020600482015260166024820152752330b4b632b2103a379039b2b7321022ba3432b9101960511b6044820152606401610739565b505b612df481613ae9565b9050612c15565b50505b50505050565b60026001541415612e275760405162461bcd60e51b815260040161073990613999565b6002600181905550600060098381548110612e5257634e487b7160e01b600052603260045260246000fd5b6000918252602090912060059091020190506002815460ff166007811115612e8a57634e487b7160e01b600052602160045260246000fd5b1480612eb957506004815460ff166007811115612eb757634e487b7160e01b600052602160045260246000fd5b145b612efe5760405162461bcd60e51b8152602060048201526016602482015275526166666c6520696e2077726f6e672073746174757360501b6044820152606401610739565b805465ffffffffffff60381b1916600160381b65ffffffffffff841602178155612f288383611cef565b6002820180546001600160a01b03929092166001600160a01b031990921682179055815460ff191660051782556004820154604051600092916001600160801b0316908381818185875af1925050503d8060008114612fa3576040519150601f19603f3d011682016040523d82523d6000602084013e612fa8565b606091505b5050905080612ff05760405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606401610739565b6004820154600090613015906001600160801b0380821691600160801b900416613a67565b600c546040516001600160801b039290921692506000916001600160a01b039091169083908381818185875af1925050503d8060008114613072576040519150601f19603f3d011682016040523d82523d6000602084013e613077565b606091505b50509050806130c05760405162461bcd60e51b81526020600482015260156024820152744661696c65642073656e642045746820746f204d5760581b6044820152606401610739565b857f7378e11c2b0ec7514bbf7ba369980eedcba0bca03e116dc9e7138f7748e211d6836040516130f291815260200190565b60405180910390a26002840154600485015460408051600160801b9092046001600160801b03168252602082018890526001600160a01b039092169188917fe0b2a72a0644b093aac275024c05c7c28851a0b572557a32241d13634a0f3e08910160405180910390a350506001805550505050565b60006131766002848418613a34565b613182908484166139fb565b9392505050565b60606000613198836002613a48565b6131a39060026139fb565b67ffffffffffffffff8111156131c957634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156131f3576020820181803683370190505b509050600360fc1b8160008151811061321c57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061325957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061327d846002613a48565b6132889060016139fb565b90505b600181111561331c576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106132ca57634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106132ee57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c9361331581613ad2565b905061328b565b5083156131825760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610739565b8280548282559060005260206000209081019282156133c0579160200282015b828111156133c057825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019061338b565b506133cc92915061340b565b5090565b8280548282559060005260206000209081019282156133c0579160200282015b828111156133c05782518255916020019190600101906133f0565b5b808211156133cc576000815560010161340c565b60008083601f840112613431578182fd5b50813567ffffffffffffffff811115613448578182fd5b6020830191508360208260051b850101111561346357600080fd5b9250929050565b80356001600160801b038116811461348157600080fd5b919050565b600060208284031215613497578081fd5b813561318281613b70565b6000602082840312156134b3578081fd5b815161318281613b70565b6000602082840312156134cf578081fd5b81518015158114613182578182fd5b6000602082840312156134ef578081fd5b5035919050565b60008060408385031215613508578081fd5b82359150602083013561351a81613b70565b809150509250929050565b600060208284031215613536578081fd5b81356001600160e01b031981168114613182578182fd5b600080600080600080600060c0888a031215613567578283fd5b6135708861346a565b965061357e6020890161346a565b955061358c6040890161346a565b9450606088013567ffffffffffffffff8111156135a7578384fd5b6135b38a828b01613420565b9095509350506080880135600381106135ca578283fd5b915060a088013565ffffffffffff811681146135e4578182fd5b8091505092959891949750929550565b600060208284031215613605578081fd5b5051919050565b600080600060608486031215613620578283fd5b83359250602084013561363281613b70565b929592945050506040919091013590565b60008060008060608587031215613658578182fd5b84359350602085013567ffffffffffffffff811115613675578283fd5b61368187828801613420565b909450925050604085013561369581613b70565b939692955090935050565b600080604083850312156136b2578182fd5b8235915060208084013567ffffffffffffffff808211156136d1578384fd5b818601915086601f8301126136e4578384fd5b8135818111156136f6576136f6613b5a565b8060051b604051601f19603f8301168101818110858211171561371b5761371b613b5a565b604052828152858101935084860182860187018b1015613739578788fd5b8795505b8386101561375b57803585526001959095019493860193860161373d565b508096505050505050509250929050565b6000806040838503121561377e578182fd5b50508035926020909101359150565b6003811061379d5761379d613b44565b9052565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516137d9816017850160208801613aa6565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161380a816028840160208801613aa6565b01602801949350505050565b602080825282518282018190526000919060409081850190868401855b82811015613861578151805185528601516001600160a01b0316868501529284019290850190600101613833565b5091979650505050505050565b600060408201841515835260206040818501528185518084526060860191508287019350845b818110156138b057845183529383019391830191600101613894565b5090979650505050505050565b610160810160088d106138d2576138d2613b44565b8c825265ffffffffffff8c811660208401528b811660408401528a81166060840152891660808301526001600160a01b03881660a083015261391760c083018861378d565b6001600160801b03861660e08301526001600160801b0385166101008301526001600160801b0384166101208301526001600160801b0383166101408301529c9b505050505050505050505050565b6020815260008251806020840152613985816040850160208701613aa6565b601f01601f19169190910160400192915050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006001600160801b038083168185168083038211156139f2576139f2613b18565b01949350505050565b60008219821115613a0e57613a0e613b18565b500190565b600065ffffffffffff8083168185168083038211156139f2576139f2613b18565b600082613a4357613a43613b2e565b500490565b6000816000190483118215151615613a6257613a62613b18565b500290565b60006001600160801b0383811690831681811015613a8757613a87613b18565b039392505050565b600082821015613aa157613aa1613b18565b500390565b60005b83811015613ac1578181015183820152602001613aa9565b83811115612dfe5750506000910152565b600081613ae157613ae1613b18565b506000190190565b6000600019821415613afd57613afd613b18565b5060010190565b600082613b1357613b13613b2e565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611cec57600080fdfe523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0ca26469706673582212200d9bc7746d500ccb62f2c1552b50ccfe8445e25fd55f30a8c91781b4fa7ffe3164736f6c63430008040033

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

0000000000000000000000003be4bef162cd158887cfdca89a34fae107ab2c740000000000000000000000000000000000000000000000000000000000000254000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e699098af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef

-----Decoded View---------------
Arg [0] : _blacklistManager (address): 0x3BE4BeF162cD158887Cfdca89a34fAe107AB2c74
Arg [1] : subscriptionId (uint64): 596
Arg [2] : _vrfCoordinator (address): 0x271682DEB8C4E0901D1a1550aD2e64D568E69909
Arg [3] : _keyHash (bytes32): 0x8af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000003be4bef162cd158887cfdca89a34fae107ab2c74
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000254
Arg [2] : 000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909
Arg [3] : 8af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.