Contract 0xab12166275a93ee190fbcc0e60f8419d74b6526c

Contract Overview

Balance:
0 BNB
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xa48ff88089c28ab83b2005ddd57c40c2d89de28aa5ce7853ffdc615965ecef8e0x6000600b85145672021-05-03 9:25:07144 days 18 hrs ago0xad1f66acea98733d63cd8fc522118e4014cb3f79 IN  Contract Creation0 BNB0.03330502
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xc9167f4ab9a5b439bcf5ffbe7b7b318ffbb28a4beef9b306436b110d72a5707698141902021-06-17 14:25:1099 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x038903456c8e8b1402f03d980474a7ad900cea6cd2f2dcefc560a3d86a22edae98141882021-06-17 14:25:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x77160d98c925bdf2d2ab579ff0a2d3ed2d1a6164a7107fd2ea33f97acd49e64898139882021-06-17 14:15:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x02206d311664824fee530b365a0dfe57f897b025633e0b8548c87ca5de5962a898138902021-06-17 14:10:1099 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x8b7234530d5742ea093812683840b82fa2e8f9f01f3423560daaa89aee0cc5c198138882021-06-17 14:10:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x41f55a5322ea07d2c5b540cf6d267a4443901c3a8c2d9c04229a7d2235d60aef98136882021-06-17 14:00:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xb9cd2a55ee1b907b385b7afa4bc540cad486bf132f8fb7cd0a3f8f6ad541dd0898135902021-06-17 13:55:1099 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x2f7241fc20b94bf30ed5852c7c25ba67053f72aa9b11511caf8aa469594cf25898135882021-06-17 13:55:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x83a4f7c52991d53130145f6e0639fc8adb91e743eace562bb800b13a9fa2adad98133882021-06-17 13:45:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x77a65ba60317e68f0e4e98aac41c2d519f0aa2278b904d053df94187b4f4752a98132902021-06-17 13:40:1099 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x027d4dce3a99639dd1eb946b410ca51976dd26baabd22ebdd88b3dd8a57775f798132882021-06-17 13:40:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xe59d6796ffd4bbf9ef7af96ca8a26a841c10a3c5a44123095f6922a2496d5dfc98130882021-06-17 13:30:0499 days 13 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xb06b8894cabff557fff3da009bd5b483b722ed75b49b28e461dc09bbf825563498129902021-06-17 13:25:1099 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xecd5c1d32b84c0a6a57bb9dfe666bc439497745d499d4e532bb4d2053b8ff0ed98129882021-06-17 13:25:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x83e9d46330777a4a6d6819e49fdd4f1bf8d882a93f10f7546d805ca872477c6d98127882021-06-17 13:15:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xbaf31f533c22cd42ccb6a9ded427b91037fe3350774ae0b53c9487c7ff31157598126902021-06-17 13:10:1099 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x2ff5d78f49990ec04a93be9bd3526563bfcc366da4bfb7dd4c1bfc6e340e244f98126882021-06-17 13:10:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xf81aa1a3024668bd803d8b6872919b22a2a03c5752b9328ca910fe218d8418e398124882021-06-17 13:00:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xe1c48a93e45fc0793f77a7f1f47b7c145d5388729707ee5a952ba7617aeb167798123902021-06-17 12:55:1099 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xaddc700eb1be36facc3e207ae8a34269c940cb0fc021e8d974d7dab9be93feec98123882021-06-17 12:55:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xe4b7439d62fe679be012d82f377f921c4df67e5583cef595b282435d4205d1ac98121882021-06-17 12:45:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x9cb8bfff4b27f56cacda1e265063e4b5e802f08146611a1aeaee50b060e68bfc98120902021-06-17 12:40:1099 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x9dd7f1f4ad0af61ca430041e19025f3d8fd662e3ceedec7114837e0bb1d91e5f98120882021-06-17 12:40:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0xa73ebf2df121965331e1ef946a2662dd1843c58e61a1b904b03135aa4f2b040598118882021-06-17 12:30:0499 days 14 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
0x8f32ab30ef9453256ea3b27b77bc5fc35301445a583d92f557a9777960c3fd4898117902021-06-17 12:25:1099 days 15 hrs ago 0x6e715c1bf7a5bc8001743df10a4d33c0b4e26b01 0xab12166275a93ee190fbcc0e60f8419d74b6526c0 BNB
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Lottery

Compiler Version
v0.6.12+commit.27d51765

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 21 : Lottery.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "./LotteryNFT.sol";
import "./token/ERC20/IERC20.sol";
import "./token/ERC20/SafeERC20.sol";
import "./LotteryOwnable.sol";
import "./math/SafeMath.sol";
import "./proxy/Initializable.sol";

// 4 numbers
contract Lottery is LotteryOwnable, Initializable {
    using SafeMath for uint256;
    using SafeMath for uint8;
    using SafeERC20 for IERC20;

    uint8 constant keyLengthForEachBuy = 11;
    // Allocation for first/sencond/third reward
    uint8[4] public allocation;
    // The TOKEN to buy lottery
    IERC20 public busd;
    // The Lottery NFT for tickets
    LotteryNFT public lotteryNFT;
    // adminAddress
    address public adminAddress;
    // maxNumber
    uint8 public maxNumber;
    // minPrice, if decimal is not 18, please reset it
    uint256 public minPrice;

    // =================================

    // issueId => winningNumbers[numbers]
    mapping(uint256 => uint8[4]) public historyNumbers;
    // issueId => [tokenId]
    mapping(uint256 => uint256[]) public lotteryInfo;
    // issueId => [totalAmount, firstMatchAmount, secondMatchingAmount, thirdMatchingAmount]
    mapping(uint256 => uint256[]) public historyAmount;
    // issueId => trickyNumber => buyAmountSum
    mapping(uint256 => mapping(uint64 => uint256)) public userBuyAmountSum;
    // address => [tokenId]
    mapping(address => uint256[]) public userInfo;

    uint256 public issueIndex = 0;
    uint256 public totalAddresses = 0;
    uint256 public totalAmount = 0;
    uint256 public lastTimestamp;

    uint8[4] public winningNumbers;

    // default false
    bool public drawingPhase;

    // =================================

    event Buy(address indexed user, uint256 tokenId);
    event Drawing(uint256 indexed issueIndex, uint8[4] winningNumbers);
    event Claim(address indexed user, uint256 tokenid, uint256 amount);
    event DevWithdraw(address indexed user, uint256 amount);
    event Reset(uint256 indexed issueIndex);
    event MultiClaim(address indexed user, uint256 amount);
    event MultiBuy(address indexed user, uint256 amount);

    constructor() public {}

    function initialize(
        IERC20 _busd,
        LotteryNFT _lottery,
        uint256 _minPrice,
        uint8 _maxNumber,
        address _owner,
        address _adminAddress
    ) public initializer {
        busd = _busd;
        lotteryNFT = _lottery;
        minPrice = _minPrice;
        maxNumber = _maxNumber;
        adminAddress = _adminAddress;
        lastTimestamp = block.timestamp;
        allocation = [50, 30, 10, 10];
        initOwner(_owner);
        devAddress = _adminAddress;
    }

    uint8[4] private nullTicket = [0, 0, 0, 0];
    address public devAddress;

    modifier onlyAdmin() {
        require(
            msg.sender == adminAddress,
            "Lottery::onlyAdmin:: only admin can call"
        );
        _;
    }

    modifier inDrawingPhase() {
        require(!drawed(), "Lottery::inDrawingPhase:: drawed, can not buy now");
        require(
            !drawingPhase,
            "Lottery::inDrawingPhase:: drawing, can not buy now"
        );
        _;
    }

    function drawed() public view returns (bool) {
        return winningNumbers[0] != 0;
    }

    function reset() external onlyAdmin {
        require(drawed(), "Lottery::reset:: drawed?");
        lastTimestamp = block.timestamp;
        totalAddresses = 0;
        totalAmount = 0;
        winningNumbers[0] = 0;
        winningNumbers[1] = 0;
        winningNumbers[2] = 0;
        winningNumbers[3] = 0;
        drawingPhase = false;
        issueIndex = issueIndex + 1;
        // first prize
        if (getMatchingRewardAmount(issueIndex - 1, 4) == 0) {
            uint256 amount =
                getTotalRewards(issueIndex - 1).mul(allocation[0]).div(100);
            internalBuy(amount, nullTicket);
        }
        // second prize
        if (getMatchingRewardAmount(issueIndex - 1, 3) == 0) {
            uint256 amount =
                getTotalRewards(issueIndex - 1).mul(allocation[1]).div(100);
            internalBuy(amount, nullTicket);
        }
        // third prize
        if (getMatchingRewardAmount(issueIndex - 1, 2) == 0) {
            uint256 amount =
                getTotalRewards(issueIndex - 1).mul(allocation[2]).div(100);
            internalBuy(amount, nullTicket);
        }
        uint256 amount =
            getTotalRewards(issueIndex - 1).mul(allocation[3]).div(100);
        busd.transfer(devAddress, amount);
        emit Reset(issueIndex);
    }

    function enterDrawingPhase() external onlyAdmin {
        require(!drawed(), "Lottery::enterDrawingPhase:: already drawed");
        drawingPhase = true;
    }

    // add externalRandomNumber to prevent node validators exploiting
    function drawing(uint256 _externalRandomNumber) external onlyAdmin {
        require(!drawed(), "Lottery::drawing:: already drawed");
        require(drawingPhase, "Lottery::drawing:: enter drawing phase first");
        bytes32 _structHash;
        uint256 _randomNumber;
        uint8 _maxNumber = maxNumber;
        bytes32 _blockhash = blockhash(block.number - 1);

        // waste some gas fee here
        for (uint256 i = 0; i < 10; i++) {
            getTotalRewards(issueIndex);
        }
        uint256 gasLeft = gasleft();

        // 1
        _structHash = keccak256(
            abi.encode(
                _blockhash,
                totalAddresses,
                gasLeft,
                _externalRandomNumber
            )
        );
        _randomNumber = uint256(_structHash);
        assembly {
            _randomNumber := add(mod(_randomNumber, _maxNumber), 1)
        }
        winningNumbers[0] = uint8(_randomNumber);

        // 2
        _structHash = keccak256(
            abi.encode(totalAmount, _blockhash, gasLeft, _externalRandomNumber)
        );
        _randomNumber = uint256(_structHash);
        assembly {
            _randomNumber := add(mod(_randomNumber, _maxNumber), 1)
        }
        winningNumbers[1] = uint8(_randomNumber);

        // 3
        _structHash = keccak256(
            abi.encode(
                _blockhash,
                lastTimestamp,
                gasLeft,
                _externalRandomNumber
            )
        );
        _randomNumber = uint256(_structHash);
        assembly {
            _randomNumber := add(mod(_randomNumber, _maxNumber), 1)
        }
        winningNumbers[2] = uint8(_randomNumber);

        // 4
        _structHash = keccak256(
            abi.encode(_blockhash, gasLeft, _externalRandomNumber)
        );
        _randomNumber = uint256(_structHash);
        assembly {
            _randomNumber := add(mod(_randomNumber, _maxNumber), 1)
        }
        winningNumbers[3] = uint8(_randomNumber);

        historyNumbers[issueIndex] = winningNumbers;
        historyAmount[issueIndex] = calculateMatchingRewardAmount();
        drawingPhase = false;
        emit Drawing(issueIndex, winningNumbers);
    }

    function internalBuy(uint256 _price, uint8[4] memory _numbers) internal {
        require(!drawed(), "Lottery::internalBuy:: drawed, can not buy now");
        for (uint256 i = 0; i < 4; i++) {
            require(
                _numbers[i] <= maxNumber,
                "Lottery::internalBuy:: exceed the maximum"
            );
        }
        uint256 tokenId =
            lotteryNFT.newLotteryItem(
                address(this),
                _numbers,
                _price,
                issueIndex
            );
        lotteryInfo[issueIndex].push(tokenId);
        totalAmount = totalAmount.add(_price);
        lastTimestamp = block.timestamp;
        emit Buy(address(this), tokenId);
    }

    function injectReward(uint256 _price, uint8[4] memory _numbers)
        external
        onlyAdmin
    {
        require(!drawed(), "Lottery::injectReward:: drawed, can not buy now");
        for (uint256 i = 0; i < 4; i++) {
            require(
                _numbers[i] == 0,
                "Lottery::injectReward:: accept only null ticket"
            );
        }
        uint256 tokenId =
            lotteryNFT.newLotteryItem(
                address(this),
                _numbers,
                _price,
                issueIndex
            );
        busd.safeTransferFrom(address(msg.sender), address(this), _price);
        lotteryInfo[issueIndex].push(tokenId);
        totalAmount = totalAmount.add(_price);
        lastTimestamp = block.timestamp;
        emit Buy(address(this), tokenId);
    }

    function buy(uint256 _price, uint8[4] memory _numbers)
        external
        inDrawingPhase
    {
        require(_price >= minPrice, "Lottery:buy:: price must above minPrice");
        for (uint256 i = 0; i < 4; i++) {
            require(
                _numbers[i] <= maxNumber,
                "Lottery::buy:: exceed number scope"
            );
        }
        uint256 tokenId =
            lotteryNFT.newLotteryItem(msg.sender, _numbers, _price, issueIndex);
        lotteryInfo[issueIndex].push(tokenId);
        if (userInfo[msg.sender].length == 0) {
            totalAddresses = totalAddresses + 1;
        }
        userInfo[msg.sender].push(tokenId);
        totalAmount = totalAmount.add(_price);
        lastTimestamp = block.timestamp;
        uint64[keyLengthForEachBuy] memory userNumberIndex =
            generateNumberIndexKey(_numbers);
        for (uint256 i = 0; i < keyLengthForEachBuy; i++) {
            userBuyAmountSum[issueIndex][userNumberIndex[i]] = userBuyAmountSum[
                issueIndex
            ][userNumberIndex[i]]
                .add(_price);
        }
        busd.safeTransferFrom(address(msg.sender), address(this), _price);
        emit Buy(msg.sender, tokenId);
    }

    function multiBuy(uint256 _price, uint8[4][] memory _numbers)
        external
        inDrawingPhase
    {
        require(
            _price >= minPrice,
            "Lottery::multiBuy:: price must above minPrice"
        );
        uint256 totalPrice = 0;
        for (uint256 i = 0; i < _numbers.length; i++) {
            for (uint256 j = 0; j < 4; j++) {
                require(
                    _numbers[i][j] <= maxNumber && _numbers[i][j] > 0,
                    "Lottery::multiBuy:: exceed number scope"
                );
            }
            uint256 tokenId =
                lotteryNFT.newLotteryItem(
                    msg.sender,
                    _numbers[i],
                    _price,
                    issueIndex
                );
            lotteryInfo[issueIndex].push(tokenId);
            if (userInfo[msg.sender].length == 0) {
                totalAddresses = totalAddresses + 1;
            }
            userInfo[msg.sender].push(tokenId);
            totalAmount = totalAmount.add(_price);
            lastTimestamp = block.timestamp;
            totalPrice = totalPrice.add(_price);
            uint64[keyLengthForEachBuy] memory numberIndexKey =
                generateNumberIndexKey(_numbers[i]);
            for (uint256 k = 0; k < keyLengthForEachBuy; k++) {
                userBuyAmountSum[issueIndex][
                    numberIndexKey[k]
                ] = userBuyAmountSum[issueIndex][numberIndexKey[k]].add(_price);
            }
        }
        busd.safeTransferFrom(address(msg.sender), address(this), totalPrice);
        emit MultiBuy(msg.sender, totalPrice);
    }

    function claimReward(uint256 _tokenId) external {
        require(
            msg.sender == lotteryNFT.ownerOf(_tokenId),
            "Lottery::claimReward:: not from owner"
        );
        require(
            !lotteryNFT.getClaimStatus(_tokenId),
            "Lottery::claimReward:: claimed"
        );
        uint256 reward = getRewardView(_tokenId);
        lotteryNFT.claimReward(_tokenId);
        if (reward > 0) {
            busd.safeTransfer(address(msg.sender), reward);
        }
        emit Claim(msg.sender, _tokenId, reward);
    }

    function multiClaim(uint256[] memory _tickets) external {
        uint256 totalReward = 0;
        for (uint256 i = 0; i < _tickets.length; i++) {
            require(
                msg.sender == lotteryNFT.ownerOf(_tickets[i]),
                "Lottery::multiClaim:: not from owner"
            );
            require(
                !lotteryNFT.getClaimStatus(_tickets[i]),
                "Lottery::multiClaim:: claimed"
            );
            uint256 reward = getRewardView(_tickets[i]);
            if (reward > 0) {
                totalReward = reward.add(totalReward);
            }
        }
        lotteryNFT.multiClaimReward(_tickets);
        if (totalReward > 0) {
            busd.safeTransfer(address(msg.sender), totalReward);
        }
        emit MultiClaim(msg.sender, totalReward);
    }

    function generateNumberIndexKey(uint8[4] memory number)
        public
        pure
        returns (uint64[keyLengthForEachBuy] memory)
    {
        uint64[4] memory tempNumber;
        tempNumber[0] = uint64(number[0]);
        tempNumber[1] = uint64(number[1]);
        tempNumber[2] = uint64(number[2]);
        tempNumber[3] = uint64(number[3]);

        uint64[keyLengthForEachBuy] memory result;
        result[0] =
            tempNumber[0] *
            256 *
            256 *
            256 *
            256 *
            256 *
            256 +
            1 *
            256 *
            256 *
            256 *
            256 *
            256 +
            tempNumber[1] *
            256 *
            256 *
            256 *
            256 +
            2 *
            256 *
            256 *
            256 +
            tempNumber[2] *
            256 *
            256 +
            3 *
            256 +
            tempNumber[3];

        result[1] =
            tempNumber[0] *
            256 *
            256 *
            256 *
            256 +
            1 *
            256 *
            256 *
            256 +
            tempNumber[1] *
            256 *
            256 +
            2 *
            256 +
            tempNumber[2];
        result[2] =
            tempNumber[0] *
            256 *
            256 *
            256 *
            256 +
            1 *
            256 *
            256 *
            256 +
            tempNumber[1] *
            256 *
            256 +
            3 *
            256 +
            tempNumber[3];
        result[3] =
            tempNumber[0] *
            256 *
            256 *
            256 *
            256 +
            2 *
            256 *
            256 *
            256 +
            tempNumber[2] *
            256 *
            256 +
            3 *
            256 +
            tempNumber[3];
        result[4] =
            1 *
            256 *
            256 *
            256 *
            256 *
            256 +
            tempNumber[1] *
            256 *
            256 *
            256 *
            256 +
            2 *
            256 *
            256 *
            256 +
            tempNumber[2] *
            256 *
            256 +
            3 *
            256 +
            tempNumber[3];

        result[5] = tempNumber[0] * 256 * 256 + 1 * 256 + tempNumber[1];
        result[6] = tempNumber[0] * 256 * 256 + 2 * 256 + tempNumber[2];
        result[7] = tempNumber[0] * 256 * 256 + 3 * 256 + tempNumber[3];
        result[8] =
            1 *
            256 *
            256 *
            256 +
            tempNumber[1] *
            256 *
            256 +
            2 *
            256 +
            tempNumber[2];
        result[9] =
            1 *
            256 *
            256 *
            256 +
            tempNumber[1] *
            256 *
            256 +
            3 *
            256 +
            tempNumber[3];
        result[10] =
            2 *
            256 *
            256 *
            256 +
            tempNumber[2] *
            256 *
            256 +
            3 *
            256 +
            tempNumber[3];

        return result;
    }

    function calculateMatchingRewardAmount()
        internal
        view
        returns (uint256[4] memory)
    {
        uint64[keyLengthForEachBuy] memory numberIndexKey =
            generateNumberIndexKey(winningNumbers);

        uint256 totalAmout1 = userBuyAmountSum[issueIndex][numberIndexKey[0]];

        uint256 sumForTotalAmout2 =
            userBuyAmountSum[issueIndex][numberIndexKey[1]];
        sumForTotalAmout2 = sumForTotalAmout2.add(
            userBuyAmountSum[issueIndex][numberIndexKey[2]]
        );
        sumForTotalAmout2 = sumForTotalAmout2.add(
            userBuyAmountSum[issueIndex][numberIndexKey[3]]
        );
        sumForTotalAmout2 = sumForTotalAmout2.add(
            userBuyAmountSum[issueIndex][numberIndexKey[4]]
        );

        uint256 totalAmout2 = sumForTotalAmout2.sub(totalAmout1.mul(4));

        uint256 sumForTotalAmout3 =
            userBuyAmountSum[issueIndex][numberIndexKey[5]];
        sumForTotalAmout3 = sumForTotalAmout3.add(
            userBuyAmountSum[issueIndex][numberIndexKey[6]]
        );
        sumForTotalAmout3 = sumForTotalAmout3.add(
            userBuyAmountSum[issueIndex][numberIndexKey[7]]
        );
        sumForTotalAmout3 = sumForTotalAmout3.add(
            userBuyAmountSum[issueIndex][numberIndexKey[8]]
        );
        sumForTotalAmout3 = sumForTotalAmout3.add(
            userBuyAmountSum[issueIndex][numberIndexKey[9]]
        );
        sumForTotalAmout3 = sumForTotalAmout3.add(
            userBuyAmountSum[issueIndex][numberIndexKey[10]]
        );

        uint256 totalAmout3 =
            sumForTotalAmout3.add(totalAmout1.mul(6)).sub(
                sumForTotalAmout2.mul(3)
            );

        return [totalAmount, totalAmout1, totalAmout2, totalAmout3];
    }

    function getMatchingRewardAmount(
        uint256 _issueIndex,
        uint256 _matchingNumber
    ) public view returns (uint256) {
        return historyAmount[_issueIndex][5 - _matchingNumber];
    }

    function getTotalRewards(uint256 _issueIndex)
        public
        view
        returns (uint256)
    {
        require(
            _issueIndex <= issueIndex,
            "Lottery::getTotalRewards:: _issueIndex <= issueIndex"
        );

        if (!drawed() && _issueIndex == issueIndex) {
            return totalAmount;
        }
        return historyAmount[_issueIndex][0];
    }

    function getRewardView(uint256 _tokenId) public view returns (uint256) {
        uint256 _issueIndex = lotteryNFT.getLotteryIssueIndex(_tokenId);
        uint8[4] memory lotteryNumbers = lotteryNFT.getLotteryNumbers(_tokenId);
        uint8[4] memory _winningNumbers = historyNumbers[_issueIndex];
        require(_winningNumbers[0] != 0, "Lottery::getRewardView:: not drawed");

        uint256 matchingNumber = 0;
        for (uint256 i = 0; i < lotteryNumbers.length; i++) {
            if (_winningNumbers[i] == lotteryNumbers[i]) {
                matchingNumber = matchingNumber + 1;
            }
        }
        uint256 reward = 0;
        if (matchingNumber > 1) {
            uint256 amount = lotteryNFT.getLotteryAmount(_tokenId);
            uint256 poolAmount =
                getTotalRewards(_issueIndex)
                    .mul(allocation[3 - matchingNumber])
                    .div(100);
            reward = amount
                .mul(1e12)
                .div(getMatchingRewardAmount(_issueIndex, matchingNumber))
                .mul(poolAmount);
        }
        return reward.div(1e12);
    }

    // Update admin address by the previous dev.
    function setAdmin(address _adminAddress) public onlyOwner {
        adminAddress = _adminAddress;
    }

    // Withdraw without caring about rewards. EMERGENCY ONLY.
    function adminWithdraw(uint256 _amount) public onlyAdmin {
        busd.safeTransfer(address(msg.sender), _amount);
        emit DevWithdraw(msg.sender, _amount);
    }

    // Set the minimum price for one ticket
    function setMinPrice(uint256 _price) external onlyAdmin {
        minPrice = _price;
    }

    // Set the minimum price for one ticket
    function setMaxNumber(uint8 _maxNumber) external onlyAdmin {
        maxNumber = _maxNumber;
    }

    // Set the allocation for one reward
    function setAllocation(
        uint8 _allcation1,
        uint8 _allcation2,
        uint8 _allcation3,
        uint8 _allcation4
    ) external onlyAdmin {
        require(
            _allcation1 + _allcation2 + _allcation3 + _allcation4 <= 100,
            "Lottery::setAllocation:: exceed 100"
        );
        allocation = [_allcation1, _allcation2, _allcation3, _allcation4];
    }

    function setDevAddress(address _newAddress) external onlyAdmin {
        devAddress = _newAddress;
    }
}

File 2 of 21 : LotteryNFT.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;

import "./token/ERC721/ERC721.sol";
import "./utils/Counters.sol";
import "./access/Ownable.sol";

contract LotteryNFT is ERC721, Ownable {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    mapping(uint256 => uint8[4]) public lotteryInfo;
    mapping(uint256 => uint256) public lotteryAmount;
    mapping(uint256 => uint256) public issueIndex;
    mapping(uint256 => bool) public claimInfo;

    constructor(string memory _name, string memory _symbol)
        public
        ERC721(_name, _symbol)
    {}

    function newLotteryItem(
        address player,
        uint8[4] memory _lotteryNumbers,
        uint256 _amount,
        uint256 _issueIndex
    ) public onlyOwner returns (uint256) {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(player, newItemId);
        lotteryInfo[newItemId] = _lotteryNumbers;
        lotteryAmount[newItemId] = _amount;
        issueIndex[newItemId] = _issueIndex;
        // claimInfo[newItemId] = false; default is false here
        // _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }

    function getLotteryNumbers(uint256 tokenId)
        external
        view
        returns (uint8[4] memory)
    {
        return lotteryInfo[tokenId];
    }

    function getLotteryAmount(uint256 tokenId) external view returns (uint256) {
        return lotteryAmount[tokenId];
    }

    function getLotteryIssueIndex(uint256 tokenId)
        external
        view
        returns (uint256)
    {
        return issueIndex[tokenId];
    }

    function claimReward(uint256 tokenId) external onlyOwner {
        claimInfo[tokenId] = true;
    }

    function multiClaimReward(uint256[] memory _tokenIds) external onlyOwner {
        for (uint256 i = 0; i < _tokenIds.length; i++) {
            claimInfo[_tokenIds[i]] = true;
        }
    }

    function burn(uint256 tokenId) external onlyOwner {
        _burn(tokenId);
    }

    function getClaimStatus(uint256 tokenId) external view returns (bool) {
        return claimInfo[tokenId];
    }
}

File 3 of 21 : LotteryOwnable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

contract LotteryOwnable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() internal {}

    function initOwner(address owner) internal {
        _owner = owner;
        emit OwnershipTransferred(address(0), owner);
    }

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

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

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

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

File 4 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

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

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

File 5 of 21 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts may inherit from this and call {_registerInterface} to declare
 * their support of an interface.
 */
contract ERC165 is IERC165 {
    /*
     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
     */
    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;

    /**
     * @dev Mapping of interface ids to whether or not it's supported.
     */
    mapping(bytes4 => bool) private _supportedInterfaces;

    constructor() internal {
        // Derived contracts need only register support for their own interfaces,
        // we register support for ERC165 itself here
        _registerInterface(_INTERFACE_ID_ERC165);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     *
     * Time complexity O(1), guaranteed to always use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId)
        public
        view
        override
        returns (bool)
    {
        return _supportedInterfaces[interfaceId];
    }

    /**
     * @dev Registers the contract as an implementer of the interface defined by
     * `interfaceId`. Support of the actual ERC165 interface is automatic and
     * registering its interface id is not required.
     *
     * See {IERC165-supportsInterface}.
     *
     * Requirements:
     *
     * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
     */
    function _registerInterface(bytes4 interfaceId) internal virtual {
        require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    }
}

File 6 of 21 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @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 7 of 21 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 8 of 21 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(
            _initializing || _isConstructor() || !_initialized,
            "Initializable: contract is already initialized"
        );

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        // extcodesize checks the size of the code stored in an address, and
        // address returns the current address. Since the code is still not
        // deployed when running a constructor, any checks on its code size will
        // yield zero, making it an effective way to detect if a contract is
        // under construction or not.
        address self = address(this);
        uint256 cs;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            cs := extcodesize(self)
        }
        return cs == 0;
    }
}

File 9 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 10 of 21 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";

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

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.transfer.selector, to, value)
        );
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
        );
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(token.approve.selector, spender, value)
        );
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance =
            token.allowance(address(this), spender).add(value);
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(
                token.approve.selector,
                spender,
                newAllowance
            )
        );
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance =
            token.allowance(address(this), spender).sub(
                value,
                "SafeERC20: decreased allowance below zero"
            );
        _callOptionalReturn(
            token,
            abi.encodeWithSelector(
                token.approve.selector,
                spender,
                newAllowance
            )
        );
    }

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

        bytes memory returndata =
            address(token).functionCall(
                data,
                "SafeERC20: low-level call failed"
            );
        if (returndata.length > 0) {
            // Return data is optional
            // solhint-disable-next-line max-line-length
            require(
                abi.decode(returndata, (bool)),
                "SafeERC20: ERC20 operation did not succeed"
            );
        }
    }
}

File 11 of 21 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "../../utils/Context.sol";
import "./IERC721.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./IERC721Receiver.sol";
import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../utils/EnumerableSet.sol";
import "../../utils/EnumerableMap.sol";
import "../../utils/Strings.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
contract ERC721 is
    Context,
    ERC165,
    IERC721,
    IERC721Metadata,
    IERC721Enumerable
{
    using SafeMath for uint256;
    using Address for address;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableMap for EnumerableMap.UintToAddressMap;
    using Strings for uint256;

    // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
    // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
    bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;

    // Mapping from holder address to their (enumerable) set of owned tokens
    mapping(address => EnumerableSet.UintSet) private _holderTokens;

    // Enumerable mapping from token ids to their owners
    EnumerableMap.UintToAddressMap private _tokenOwners;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Optional mapping for token URIs
    mapping(uint256 => string) private _tokenURIs;

    // Base URI
    string private _baseURI;

    /*
     *     bytes4(keccak256('balanceOf(address)')) == 0x70a08231
     *     bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
     *     bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
     *     bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
     *
     *     => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
     *        0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
     */
    bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;

    /*
     *     bytes4(keccak256('name()')) == 0x06fdde03
     *     bytes4(keccak256('symbol()')) == 0x95d89b41
     *     bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
     *
     *     => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
     */
    bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;

    /*
     *     bytes4(keccak256('totalSupply()')) == 0x18160ddd
     *     bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
     *     bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
     *
     *     => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
     */
    bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name, string memory symbol) public {
        _name = name;
        _symbol = symbol;

        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view override returns (uint256) {
        require(
            owner != address(0),
            "ERC721: balance query for the zero address"
        );

        return _holderTokens[owner].length();
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view override returns (address) {
        return
            _tokenOwners.get(
                tokenId,
                "ERC721: owner query for nonexistent token"
            );
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId)
        public
        view
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for nonexistent token"
        );

        string memory _tokenURI = _tokenURIs[tokenId];

        // If there is no base URI, return the token URI.
        if (bytes(_baseURI).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(_baseURI, _tokenURI));
        }
        // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
        return string(abi.encodePacked(_baseURI, tokenId.toString()));
    }

    /**
     * @dev Returns the base URI set via {_setBaseURI}. This will be
     * automatically added as a prefix in {tokenURI} to each token's URI, or
     * to the token ID if no specific URI is set for that token ID.
     */
    function baseURI() public view returns (string memory) {
        return _baseURI;
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index)
        public
        view
        override
        returns (uint256)
    {
        return _holderTokens[owner].at(index);
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view override returns (uint256) {
        // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
        return _tokenOwners.length();
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index)
        public
        view
        override
        returns (uint256)
    {
        (uint256 tokenId, ) = _tokenOwners.at(index);
        return tokenId;
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId)
        public
        view
        override
        returns (address)
    {
        require(
            _exists(tokenId),
            "ERC721: approved query for nonexistent token"
        );

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved)
        public
        virtual
        override
    {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator)
        public
        view
        override
        returns (bool)
    {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            "ERC721: transfer caller is not owner nor approved"
        );

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(
            _isApprovedOrOwner(_msgSender(), tokenId),
            "ERC721: transfer caller is not owner nor approved"
        );
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @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.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mecanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(
            _checkOnERC721Received(from, to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view returns (bool) {
        return _tokenOwners.contains(tokenId);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId)
        internal
        view
        returns (bool)
    {
        require(
            _exists(tokenId),
            "ERC721: operator query for nonexistent token"
        );
        address owner = ownerOf(tokenId);
        return (spender == owner ||
            getApproved(tokenId) == spender ||
            isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     d*
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        // Clear metadata (if any)
        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }

        _holderTokens[owner].remove(tokenId);

        _tokenOwners.remove(tokenId);

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(
            ownerOf(tokenId) == from,
            "ERC721: transfer of token that is not own"
        );
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _holderTokens[from].remove(tokenId);
        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI)
        internal
        virtual
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI set of nonexistent token"
        );
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev Internal function to set the base URI for all token IDs. It is
     * automatically added as a prefix to the value returned in {tokenURI},
     * or to the token ID if {tokenURI} is empty.
     */
    function _setBaseURI(string memory baseURI_) internal virtual {
        _baseURI = baseURI_;
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (!to.isContract()) {
            return true;
        }
        bytes memory returndata =
            to.functionCall(
                abi.encodeWithSelector(
                    IERC721Receiver(to).onERC721Received.selector,
                    _msgSender(),
                    from,
                    tokenId,
                    _data
                ),
                "ERC721: transfer to non ERC721Receiver implementer"
            );
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

    function _approve(address to, uint256 tokenId) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

File 12 of 21 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transfered 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`, 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 be 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId)
        external
        view
        returns (address operator);

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

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

File 13 of 21 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index)
        external
        view
        returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 14 of 21 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "./IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 15 of 21 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 16 of 21 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
        // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
        // for accounts without code, i.e. `keccak256('')`
        bytes32 codehash;
        bytes32 accountHash =
            0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            codehash := extcodehash(account)
        }
        return (codehash != accountHash && codehash != 0x0);
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{value: amount}("");
        require(
            success,
            "Address: unable to send value, recipient may have reverted"
        );
    }

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

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

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

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

    function _functionCallWithValue(
        address target,
        bytes memory data,
        uint256 weiValue,
        string memory errorMessage
    ) private returns (bytes memory) {
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) =
            target.call{value: weiValue}(data);
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 17 of 21 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/*
 * @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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 18 of 21 : Counters.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

import "../math/SafeMath.sol";

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
 * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
 * directly accessed.
 */
library Counters {
    using SafeMath for uint256;

    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        // The {SafeMath} overflow check can be skipped here, see the comment at the top
        counter._value += 1;
    }

    function decrement(Counter storage counter) internal {
        counter._value = counter._value.sub(1);
    }
}

File 19 of 21 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMap {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;
        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function _set(
        Map storage map,
        bytes32 key,
        bytes32 value
    ) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) {
            // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({_key: key, _value: value}));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }

    /**
     * @dev Removes a key-value pair from a map. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function _remove(Map storage map, bytes32 key) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex != 0) {
            // Equivalent to contains(map, key)
            // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
            // in the array, and then remove the last entry (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = keyIndex - 1;
            uint256 lastIndex = map._entries.length - 1;

            // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            MapEntry storage lastEntry = map._entries[lastIndex];

            // Move the last entry to the index where the entry to delete is
            map._entries[toDeleteIndex] = lastEntry;
            // Update the index for the moved entry
            map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved entry was stored
            map._entries.pop();

            // Delete the index for the deleted slot
            delete map._indexes[key];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function _contains(Map storage map, bytes32 key)
        private
        view
        returns (bool)
    {
        return map._indexes[key] != 0;
    }

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._entries.length;
    }

    /**
     * @dev Returns the key-value pair stored at position `index` in the map. O(1).
     *
     * Note that there are no guarantees on the ordering of entries inside the
     * array, and it may change when more entries are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Map storage map, uint256 index)
        private
        view
        returns (bytes32, bytes32)
    {
        require(
            map._entries.length > index,
            "EnumerableMap: index out of bounds"
        );

        MapEntry storage entry = map._entries[index];
        return (entry._key, entry._value);
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        return _get(map, key, "EnumerableMap: nonexistent key");
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     */
    function _get(
        Map storage map,
        bytes32 key,
        string memory errorMessage
    ) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(
        UintToAddressMap storage map,
        uint256 key,
        address value
    ) internal returns (bool) {
        return _set(map._inner, bytes32(key), bytes32(uint256(value)));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the key was removed from the map, that is if it was present.
     */
    function remove(UintToAddressMap storage map, uint256 key)
        internal
        returns (bool)
    {
        return _remove(map._inner, bytes32(key));
    }

    /**
     * @dev Returns true if the key is in the map. O(1).
     */
    function contains(UintToAddressMap storage map, uint256 key)
        internal
        view
        returns (bool)
    {
        return _contains(map._inner, bytes32(key));
    }

    /**
     * @dev Returns the number of elements in the map. O(1).
     */
    function length(UintToAddressMap storage map)
        internal
        view
        returns (uint256)
    {
        return _length(map._inner);
    }

    /**
     * @dev Returns the element stored at position `index` in the set. O(1).
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintToAddressMap storage map, uint256 index)
        internal
        view
        returns (uint256, address)
    {
        (bytes32 key, bytes32 value) = _at(map._inner, index);
        return (uint256(key), address(uint256(value)));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key)
        internal
        view
        returns (address)
    {
        return address(uint256(_get(map._inner, bytes32(key))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     */
    function get(
        UintToAddressMap storage map,
        uint256 key,
        string memory errorMessage
    ) internal view returns (address) {
        return address(uint256(_get(map._inner, bytes32(key), errorMessage)));
    }
}

File 20 of 21 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.0.0, only sets of type `address` (`AddressSet`) and `uint256`
 * (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value)
        private
        view
        returns (bool)
    {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index)
        private
        view
        returns (bytes32)
    {
        require(
            set._values.length > index,
            "EnumerableSet: index out of bounds"
        );
        return set._values[index];
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value)
        internal
        returns (bool)
    {
        return _add(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value)
        internal
        returns (bool)
    {
        return _remove(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value)
        internal
        view
        returns (bool)
    {
        return _contains(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index)
        internal
        view
        returns (address)
    {
        return address(uint256(_at(set._inner, index)));
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value)
        internal
        returns (bool)
    {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value)
        internal
        view
        returns (bool)
    {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index)
        internal
        view
        returns (uint256)
    {
        return uint256(_at(set._inner, index));
    }
}

File 21 of 21 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity 0.6.12;

/**
 * @dev String operations.
 */
library Strings {
    /**
     * @dev Converts a `uint256` to its ASCII `string` 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);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = bytes1(uint8(48 + (temp % 10)));
            temp /= 10;
        }
        return string(buffer);
    }
}

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

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Buy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DevWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"issueIndex","type":"uint256"},{"indexed":false,"internalType":"uint8[4]","name":"winningNumbers","type":"uint8[4]"}],"name":"Drawing","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MultiBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MultiClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"issueIndex","type":"uint256"}],"name":"Reset","type":"event"},{"inputs":[],"name":"adminAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"adminWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"allocation","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"busd","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint8[4]","name":"_numbers","type":"uint8[4]"}],"name":"buy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"claimReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"devAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_externalRandomNumber","type":"uint256"}],"name":"drawing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"drawingPhase","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enterDrawingPhase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8[4]","name":"number","type":"uint8[4]"}],"name":"generateNumberIndexKey","outputs":[{"internalType":"uint64[11]","name":"","type":"uint64[11]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_issueIndex","type":"uint256"},{"internalType":"uint256","name":"_matchingNumber","type":"uint256"}],"name":"getMatchingRewardAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getRewardView","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_issueIndex","type":"uint256"}],"name":"getTotalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"historyAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"historyNumbers","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_busd","type":"address"},{"internalType":"contract LotteryNFT","name":"_lottery","type":"address"},{"internalType":"uint256","name":"_minPrice","type":"uint256"},{"internalType":"uint8","name":"_maxNumber","type":"uint8"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_adminAddress","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint8[4]","name":"_numbers","type":"uint8[4]"}],"name":"injectReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"issueIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"lotteryInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lotteryNFT","outputs":[{"internalType":"contract LotteryNFT","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxNumber","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint8[4][]","name":"_numbers","type":"uint8[4][]"}],"name":"multiBuy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_tickets","type":"uint256[]"}],"name":"multiClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_adminAddress","type":"address"}],"name":"setAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_allcation1","type":"uint8"},{"internalType":"uint8","name":"_allcation2","type":"uint8"},{"internalType":"uint8","name":"_allcation3","type":"uint8"},{"internalType":"uint8","name":"_allcation4","type":"uint8"}],"name":"setAllocation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newAddress","type":"address"}],"name":"setDevAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_maxNumber","type":"uint8"}],"name":"setMaxNumber","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setMinPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalAddresses","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint64","name":"","type":"uint64"}],"name":"userBuyAmountSum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"winningNumbers","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"}]

6000600b819055600c819055600d819055610100604052608081815260a082905260c082905260e0919091526200003b90601190600462000050565b503480156200004957600080fd5b5062000105565b600183019183908215620000d85791602002820160005b83821115620000a757835183826101000a81548160ff021916908360ff160217905550926020019260010160208160000104928301926001030262000067565b8015620000d65782816101000a81549060ff0219169055600101602081600001049283019260010302620000a7565b505b50620000e6929150620000ea565b5090565b5b80821115620000e657805460ff19168155600101620000eb565b613a2180620001156000396000f3fe608060405234801561001057600080fd5b50600436106102535760003560e01c80636a28f82811610146578063c39f49c0116100c3578063d826f88f11610087578063d826f88f146104c4578063e1345416146104cc578063e45be8eb146104d4578063e8adfbc7146104dc578063f2fde38b146104e4578063fc6f9468146104f757610253565b8063c39f49c014610470578063cfad527714610483578063d0d41fe11461048b578063d1f7dbcf1461049e578063d411b0fa146104b157610253565b8063850bad941161010a578063850bad941461040f57806385dcdf1b146104225780638da5cb5b14610442578063a42206c91461044a578063ae169a501461045d57610253565b80636a28f828146103c6578063704b6c02146103ce578063715018a6146103e15780637c5b4a37146103e957806383dd0ee4146103fc57610253565b80633a4f6999116101d45780634ed73d28116101985780634ed73d2814610367578063552164ee1461037a57806359bcbd681461038d5780635ea8cd12146103a05780636575243f146103b357610253565b80633a4f69991461030d5780633ad10ef6146103225780633ca5b23414610337578063438209f51461033f5780634e45f0951461035457610253565b806321ce919d1161021b57806321ce919d146102ae5780632bdff851146102c15780632c500414146102d45780632f506b20146102e7578063324a5562146102fa57610253565b806311e420651461025857806314c20d571461026d57806319d8ac61146102805780631a39d8ef1461029e5780631ff68866146102a6575b600080fd5b61026b610266366004612d28565b6104ff565b005b61026b61027b366004612e77565b610658565b61028861093c565b604051610295919061392e565b60405180910390f35b610288610942565b61026b610948565b6102886102bc366004612bbe565b6109a6565b61026b6102cf366004612dd0565b6109d4565b61026b6102e2366004612e77565b610d1d565b6102886102f5366004612ec4565b610ec0565b61026b610308366004612efe565b610edd565b610315610f27565b6040516102959190613945565b61032a610f37565b6040516102959190612fb7565b61032a610f46565b610347610f55565b60405161029591906130e0565b610315610362366004612da0565b610f5e565b61026b610375366004612be9565b610f85565b610288610388366004612da0565b611211565b61031561039b366004612ea3565b611285565b61026b6103ae366004612da0565b6112bb565b6102886103c1366004612ea3565b6112ea565b610288611303565b61026b6103dc366004612b86565b611309565b61026b611355565b61026b6103f7366004612da0565b6113c9565b61026b61040a366004612f1a565b61144e565b61031561041d366004612da0565b6114e2565b610435610430366004612c7d565b6114ef565b604051610295919061307b565b61032a611676565b61026b610458366004612da0565b611685565b61026b61046b366004612da0565b61190d565b61028861047e366004612ea3565b611b23565b610288611b3c565b61026b610499366004612b86565b611b42565b6102886104ac366004612ea3565b611b8e565b6102886104bf366004612da0565b611bc0565b61026b611ec1565b610347612171565b61028861217c565b61032a612182565b61026b6104f2366004612b86565b612191565b61032a61223c565b600054600160a81b900460ff168061051a575061051a61224b565b8061052f5750600054600160a01b900460ff16155b6105545760405162461bcd60e51b815260040161054b90613519565b60405180910390fd5b600054600160a81b900460ff1615801561058b576000805460ff60a01b1960ff60a81b19909116600160a81b1716600160a01b1790555b600280546001600160a01b03199081166001600160a01b038a81169190911790925560038054821689841617905560058790556004805460ff60a01b1916600160a01b60ff8916021790911691841691909117815542600e556040805160808101825260328152601e6020820152600a918101829052606081019190915261061691600191906129ab565b5061062083612251565b601280546001600160a01b0319166001600160a01b038416179055801561064f576000805460ff60a81b191690555b50505050505050565b610660612171565b1561067d5760405162461bcd60e51b815260040161054b9061389a565b60105460ff16156106a05760405162461bcd60e51b815260040161054b906132f2565b6005548210156106c25760405162461bcd60e51b815260040161054b90613274565b60005b60048110156107175760048054600160a01b900460ff16908390839081106106e957fe5b602002015160ff16111561070f5760405162461bcd60e51b815260040161054b90613344565b6001016106c5565b50600354600b54604051620dce4760ea1b81526000926001600160a01b0316916337391c009161074f91339187918991600401612fcb565b602060405180830381600087803b15801561076957600080fd5b505af115801561077d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a19190612db8565b600b546000908152600760209081526040808320805460018101825590845282842001849055338352600a9091529020549091506107e357600c805460010190555b336000908152600a6020908152604082208054600181018255908352912001819055600d54610812908461229c565b600d5542600e55610821612a3e565b61082a836114ef565b905060005b600b8110156108dc576108938560096000600b54815260200190815260200160002060008585600b811061085f57fe5b60200201516001600160401b03166001600160401b031681526020019081526020016000205461229c90919063ffffffff16565b600b80546000908152600960205260408120918590859081106108b257fe5b602090810291909101516001600160401b031682528101919091526040016000205560010161082f565b506002546108f5906001600160a01b03163330876122c8565b336001600160a01b03167fe3d4187f6ca4248660cc0ac8b8056515bac4a8132be2eca31d6d0cc170722a7e8360405161092e919061392e565b60405180910390a250505050565b600e5481565b600d5481565b6004546001600160a01b031633146109725760405162461bcd60e51b815260040161054b906131e6565b61097a612171565b156109975760405162461bcd60e51b815260040161054b9061314f565b6010805460ff19166001179055565b600a60205281600052604060002081815481106109bf57fe5b90600052602060002001600091509150505481565b6109dc612171565b156109f95760405162461bcd60e51b815260040161054b9061389a565b60105460ff1615610a1c5760405162461bcd60e51b815260040161054b906132f2565b600554821015610a3e5760405162461bcd60e51b815260040161054b906135aa565b6000805b8251811015610cbe5760005b6004811015610ae957600460149054906101000a900460ff1660ff16848381518110610a7657fe5b60200260200101518260048110610a8957fe5b602002015160ff1611158015610ac557506000848381518110610aa857fe5b60200260200101518260048110610abb57fe5b602002015160ff16115b610ae15760405162461bcd60e51b815260040161054b90613452565b600101610a4e565b5060035483516000916001600160a01b0316906337391c00903390879086908110610b1057fe5b602002602001015188600b546040518563ffffffff1660e01b8152600401610b3b9493929190612fcb565b602060405180830381600087803b158015610b5557600080fd5b505af1158015610b69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b8d9190612db8565b600b546000908152600760209081526040808320805460018101825590845282842001849055338352600a909152902054909150610bcf57600c805460010190555b336000908152600a6020908152604082208054600181018255908352912001819055600d54610bfe908661229c565b600d5542600e55610c0f838661229c565b9250610c19612a3e565b610c35858481518110610c2857fe5b60200260200101516114ef565b905060005b600b811015610cb357610c6a8760096000600b54815260200190815260200160002060008585600b811061085f57fe5b600b8054600090815260096020526040812091859085908110610c8957fe5b602090810291909101516001600160401b0316825281019190915260400160002055600101610c3a565b505050600101610a42565b50600254610cd7906001600160a01b03163330846122c8565b336001600160a01b03167f96c35ad1cc1743f26cb87980c38042de8082358ec6d171a7986d6e11dddfe85782604051610d10919061392e565b60405180910390a2505050565b6004546001600160a01b03163314610d475760405162461bcd60e51b815260040161054b906131e6565b610d4f612171565b15610d6c5760405162461bcd60e51b815260040161054b9061377c565b60005b6004811015610db157818160048110610d8457fe5b602002015160ff1615610da95760405162461bcd60e51b815260040161054b906136b2565b600101610d6f565b50600354600b54604051620dce4760ea1b81526000926001600160a01b0316916337391c0091610de991309187918991600401612fcb565b602060405180830381600087803b158015610e0357600080fd5b505af1158015610e17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e3b9190612db8565b600254909150610e56906001600160a01b03163330866122c8565b600b54600090815260076020908152604082208054600181018255908352912001819055600d54610e87908461229c565b600d5542600e5560405130907fe3d4187f6ca4248660cc0ac8b8056515bac4a8132be2eca31d6d0cc170722a7e90610d1090849061392e565b600960209081526000928352604080842090915290825290205481565b6004546001600160a01b03163314610f075760405162461bcd60e51b815260040161054b906131e6565b6004805460ff909216600160a01b0260ff60a01b19909216919091179055565b600454600160a01b900460ff1681565b6012546001600160a01b031681565b6002546001600160a01b031681565b60105460ff1681565b600f8160048110610f6b57fe5b60209182820401919006915054906101000a900460ff1681565b6000805b82518110156111495760035483516001600160a01b0390911690636352211e90859084908110610fb557fe5b60200260200101516040518263ffffffff1660e01b8152600401610fd9919061392e565b60206040518083038186803b158015610ff157600080fd5b505afa158015611005573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110299190612ba2565b6001600160a01b0316336001600160a01b0316146110595760405162461bcd60e51b815260040161054b90613701565b60035483516001600160a01b03909116906336dbd2f99085908490811061107c57fe5b60200260200101516040518263ffffffff1660e01b81526004016110a0919061392e565b60206040518083038186803b1580156110b857600080fd5b505afa1580156110cc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110f09190612d08565b1561110d5760405162461bcd60e51b815260040161054b90613386565b600061112b84838151811061111e57fe5b6020026020010151611bc0565b905080156111405761113d818461229c565b92505b50600101610f89565b50600354604051637431035560e01b81526001600160a01b039091169063743103559061117a908590600401613037565b600060405180830381600087803b15801561119457600080fd5b505af11580156111a8573d6000803e3d6000fd5b5050505060008111156111cc576002546111cc906001600160a01b03163383612326565b336001600160a01b03167f6606374655494f5c0e2d6f392656e9777afd9ac5f61527d1bcad50b7e918a03e82604051611205919061392e565b60405180910390a25050565b6000600b548211156112355760405162461bcd60e51b815260040161054b906133bd565b61123d612171565b15801561124b5750600b5482145b156112595750600d54611280565b6000828152600860205260408120805490919061127257fe5b906000526020600020015490505b919050565b6006602052816000526040600020816004811061129e57fe5b602081049091015460ff601f9092166101000a9004169150829050565b6004546001600160a01b031633146112e55760405162461bcd60e51b815260040161054b906131e6565b600555565b600760205281600052604060002081815481106109bf57fe5b600b5481565b6000546001600160a01b031633146113335760405162461bcd60e51b815260040161054b90613638565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b0316331461137f5760405162461bcd60e51b815260040161054b90613638565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6004546001600160a01b031633146113f35760405162461bcd60e51b815260040161054b906131e6565b60025461140a906001600160a01b03163383612326565b336001600160a01b03167f050d1c64cc22ce461b9bc14f6b73852566da02b03c155242bc63169d1fec42aa82604051611443919061392e565b60405180910390a250565b6004546001600160a01b031633146114785760405162461bcd60e51b815260040161054b906131e6565b60648183858701010160ff1611156114a25760405162461bcd60e51b815260040161054b906138eb565b6040805160808101825260ff808716825285811660208301528481169282019290925290821660608201526114db9060019060046129ab565b5050505050565b60018160048110610f6b57fe5b6114f7612a3e565b6114ff612a5d565b825160ff908116825260208085015182169083015260408085015182169083015260608085015190911690820152611535612a3e565b6060828101805160408086018051602080890180518a516201000094850264010000000092830266010000000000009092029190910101909601650100020003009081016001600160401b039081168b52855183518d51908702908a02010163010002009081018216948c0194909452885183518d51908702908a02010163010003009081018216978c0197909752885186518d51908702908a020101630200030090810182169a8c019a909a5288518651845190870299029890980190970101861660808a015280518a51840201610100908101871660a08b015284518b5185020161020001871660c08b015287519a518402909a0161030001861660e08a015283518151840201909101851698880198909852845197518102909701909101821661012086015291519151909402010190911661014082015292915050565b6000546001600160a01b031690565b6004546001600160a01b031633146116af5760405162461bcd60e51b815260040161054b906131e6565b6116b7612171565b156116d45760405162461bcd60e51b815260040161054b90613411565b60105460ff166116f65760405162461bcd60e51b815260040161054b9061319a565b6004546000908190600160a01b900460ff16436000190140825b600a81101561172d57611724600b54611211565b50600101611710565b5060005a905081600c54828860405160200161174c9493929190613101565b60408051601f19818403018152908290528051602091820120600f805460ff191687830660010160ff811691909117909155600d549198509650611798929091859185918b9101613101565b60408051601f19818403018152908290528051602091820120600f805460ff8884066001019081166101000261ff001990921691909117909155600e5491985096506117ea92859285918b9101613101565b60408051808303601f19018152908290528051602091820120600f805460ff600189850601908116620100000262ff00001990921691909117909155909750955061183b91849184918a91016130eb565b60408051808303601f190181529181528151602092830120600f805460ff60018985060190811663010000000263ff00000019909216919091178255600b546000908152600690955292909320909750909550611899916004612a7b565b506118a261234a565b600b5460009081526008602052604090206118be916004612aae565b506010805460ff19169055600b546040517fa13e935b188993737b3009d62bd916dcbe9e82d8236d75981eeadf26a1460d3d906118fd90600f906130ad565b60405180910390a2505050505050565b6003546040516331a9108f60e11b81526001600160a01b0390911690636352211e9061193d90849060040161392e565b60206040518083038186803b15801561195557600080fd5b505afa158015611969573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061198d9190612ba2565b6001600160a01b0316336001600160a01b0316146119bd5760405162461bcd60e51b815260040161054b9061366d565b6003546040516336dbd2f960e01b81526001600160a01b03909116906336dbd2f9906119ed90849060040161392e565b60206040518083038186803b158015611a0557600080fd5b505afa158015611a19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3d9190612d08565b15611a5a5760405162461bcd60e51b815260040161054b906134e2565b6000611a6582611bc0565b600354604051630ae169a560e41b81529192506001600160a01b03169063ae169a5090611a9690859060040161392e565b600060405180830381600087803b158015611ab057600080fd5b505af1158015611ac4573d6000803e3d6000fd5b505050506000811115611ae857600254611ae8906001600160a01b03163383612326565b336001600160a01b03167f34fcbac0073d7c3d388e51312faf357774904998eeb8fca628b9e6f65ee1cbf78383604051611205929190613937565b600860205281600052604060002081815481106109bf57fe5b600c5481565b6004546001600160a01b03163314611b6c5760405162461bcd60e51b815260040161054b906131e6565b601280546001600160a01b0319166001600160a01b0392909216919091179055565b600082815260086020526040812080546005849003908110611bac57fe5b906000526020600020015490505b92915050565b600354604051631bf1e00f60e01b815260009182916001600160a01b0390911690631bf1e00f90611bf590869060040161392e565b60206040518083038186803b158015611c0d57600080fd5b505afa158015611c21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c459190612db8565b9050611c4f612a5d565b600354604051635f8e26a760e01b81526001600160a01b0390911690635f8e26a790611c7f90879060040161392e565b60806040518083038186803b158015611c9757600080fd5b505afa158015611cab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ccf9190612c98565b9050611cd9612a5d565b600083815260066020526040808220815160808101928390529290916004918390855b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411611cfc5790505050505050905080600060048110611d3e57fe5b602002015160ff16611d625760405162461bcd60e51b815260040161054b90613567565b6000805b6004811015611dac57838160048110611d7b57fe5b602002015160ff16838260048110611d8f57fe5b602002015160ff161415611da4578160010191505b600101611d66565b5060006001821115611ea757600354604051637bd0606560e11b81526000916001600160a01b03169063f7a0c0ca90611de9908b9060040161392e565b60206040518083038186803b158015611e0157600080fd5b505afa158015611e15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e399190612db8565b90506000611e806064611e7a60018760030360048110611e5557fe5b602081049091015460ff601f9092166101000a900416611e748b611211565b906125af565b906125e9565b9050611ea281611e74611e938a88611b8e565b611e7a8664e8d4a510006125af565b925050505b611eb68164e8d4a510006125e9565b979650505050505050565b6004546001600160a01b03163314611eeb5760405162461bcd60e51b815260040161054b906131e6565b611ef3612171565b611f0f5760405162461bcd60e51b815260040161054b90613745565b42600e556000600c819055600d55600f805463ffffffff191690556010805460ff19169055600b805460018101909155611f4a906004611b8e565b611fdd576000611f836064611e7a6001845b602091828204019190069054906101000a900460ff1660ff16611e746001600b5403611211565b604080516080810191829052919250611fdb918391601190600490826000855b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411611fa3579050505050505061262b565b505b611fed6001600b54036003611b8e565b6120405760006120036064611e7a600180611f5c565b6040805160808101918290526011805460ff16825292935061203e92849260049082600160208601808411611fa3579050505050505061262b565b505b6120506001600b54036002611b8e565b6120a45760006120676064611e7a60016002611f5c565b6040805160808101918290526011805460ff1682529293506120a292849260049082600160208601808411611fa3579050505050505061262b565b505b60006120b76064611e7a60016003611f5c565b60025460125460405163a9059cbb60e01b81529293506001600160a01b039182169263a9059cbb926120ef921690859060040161301e565b602060405180830381600087803b15801561210957600080fd5b505af115801561211d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121419190612d08565b50600b546040517f01c3cbb0d62726ab09d163873ebf9aed99dd8dc08e57bc938f458132fd178cf690600090a250565b600f5460ff16151590565b60055481565b6003546001600160a01b031681565b6000546001600160a01b031633146121bb5760405162461bcd60e51b815260040161054b90613638565b6001600160a01b0381166121e15760405162461bcd60e51b815260040161054b9061322e565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6004546001600160a01b031681565b303b1590565b600080546001600160a01b0319166001600160a01b03831690811782556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350565b6000828201838110156122c15760405162461bcd60e51b815260040161054b906132bb565b9392505050565b612320846323b872dd60e01b8585856040516024016122e993929190612ffa565b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612763565b50505050565b6123458363a9059cbb60e01b84846040516024016122e992919061301e565b505050565b612352612a5d565b61235a612a3e565b6040805160808101918290526123ad91600f90600490826000855b825461010083900a900460ff1681526020600192830181810494850194909303909202910180841161237557905050505050506114ef565b600b54600081815260096020818152604080842086516001600160401b039081168652818452828620548787528585528885015190911686528184529185205495855292909152939450612434918560025b60200201516001600160401b03166001600160401b03168152602001908152602001600020548261229c90919063ffffffff16565b600b54600090815260096020526040812091925061245591908560036123ff565b600b54600090815260096020526040812091925061247691908560046123ff565b9050600061248f6124888460046125af565b83906127f2565b600b54600081815260096020818152604080842060a08b01516001600160401b031685528083529084205494845291905292935090916124d1918760066123ff565b600b5460009081526009602052604081209192506124f291908760076123ff565b600b54600090815260096020526040812091925061251391908760086123ff565b600b546000908152600960208190526040822092935061253692919088906123ff565b600b546000908152600960205260408120919250612557919087600a6123ff565b905060006125846125698560036125af565b61257e6125778860066125af565b859061229c565b906127f2565b60408051608081018252600d5481526020810197909752860193909352505060608301525091505090565b6000826125be57506000611bba565b828202828482816125cb57fe5b04146122c15760405162461bcd60e51b815260040161054b906135f7565b60006122c183836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250612834565b612633612171565b156126505760405162461bcd60e51b815260040161054b906137cb565b60005b60048110156126a55760048054600160a01b900460ff169083908390811061267757fe5b602002015160ff16111561269d5760405162461bcd60e51b815260040161054b90613499565b600101612653565b50600354600b54604051620dce4760ea1b81526000926001600160a01b0316916337391c00916126dd91309187918991600401612fcb565b602060405180830381600087803b1580156126f757600080fd5b505af115801561270b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272f9190612db8565b600b54600090815260076020908152604082208054600181018255908352912001819055600d54909150610e87908461229c565b60606127b8826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661286b9092919063ffffffff16565b80519091501561234557808060200190518101906127d69190612d08565b6123455760405162461bcd60e51b815260040161054b90613850565b60006122c183836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250612882565b600081836128555760405162461bcd60e51b815260040161054b919061311c565b50600083858161286157fe5b0495945050505050565b606061287a84846000856128ae565b949350505050565b600081848411156128a65760405162461bcd60e51b815260040161054b919061311c565b505050900390565b60606128b985612972565b6128d55760405162461bcd60e51b815260040161054b90613819565b60006060866001600160a01b031685876040516128f29190612f9b565b60006040518083038185875af1925050503d806000811461292f576040519150601f19603f3d011682016040523d82523d6000602084013e612934565b606091505b5091509150811561294857915061287a9050565b8051156129585780518082602001fd5b8360405162461bcd60e51b815260040161054b919061311c565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081811480159061287a575050151592915050565b600183019183908215612a2e5791602002820160005b838211156129ff57835183826101000a81548160ff021916908360ff16021790555092602001926001016020816000010492830192600103026129c1565b8015612a2c5782816101000a81549060ff02191690556001016020816000010492830192600103026129ff565b505b50612a3a929150612af5565b5090565b604051806101600160405280600b906020820280368337509192915050565b60405180608001604052806004906020820280368337509192915050565b600183019183908215612a2e5791601f016020900482015b82811115612a2e578254825591600101919060010190612a93565b828054828255906000526020600020908101928215612ae9579160200282015b82811115612ae9578251825591602001919060010190612ace565b50612a3a929150612b0e565b5b80821115612a3a57805460ff19168155600101612af6565b5b80821115612a3a5760008155600101612b0f565b600082601f830112612b33578081fd5b612b3d6080613953565b9050808284608085011115612b5157600080fd5b60005b6004811015612b7d578135612b68816139dc565b83526020928301929190910190600101612b54565b50505092915050565b600060208284031215612b97578081fd5b81356122c1816139c4565b600060208284031215612bb3578081fd5b81516122c1816139c4565b60008060408385031215612bd0578081fd5b8235612bdb816139c4565b946020939093013593505050565b60006020808385031215612bfb578182fd5b82356001600160401b03811115612c10578283fd5b8301601f81018513612c20578283fd5b8035612c33612c2e82613979565b613953565b8181528381019083850185840285018601891015612c4f578687fd5b8694505b83851015612c71578035835260019490940193918501918501612c53565b50979650505050505050565b600060808284031215612c8e578081fd5b6122c18383612b23565b600060808284031215612ca9578081fd5b82601f830112612cb7578081fd5b612cc16080613953565b808385608086011115612cd2578384fd5b835b6004811015612cfd578151612ce8816139dc565b84526020938401939190910190600101612cd4565b509095945050505050565b600060208284031215612d19578081fd5b815180151581146122c1578182fd5b60008060008060008060c08789031215612d40578182fd5b8635612d4b816139c4565b95506020870135612d5b816139c4565b9450604087013593506060870135612d72816139dc565b92506080870135612d82816139c4565b915060a0870135612d92816139c4565b809150509295509295509295565b600060208284031215612db1578081fd5b5035919050565b600060208284031215612dc9578081fd5b5051919050565b60008060408385031215612de2578182fd5b823591506020808401356001600160401b03811115612dff578283fd5b8401601f81018613612e0f578283fd5b8035612e1d612c2e82613979565b818152838101908385016080808502860187018b1015612e3b578788fd5b8795505b84861015612e6757612e518b83612b23565b8452600195909501949286019290810190612e3f565b5096999098509650505050505050565b60008060a08385031215612e89578182fd5b82359150612e9a8460208501612b23565b90509250929050565b60008060408385031215612eb5578182fd5b50508035926020909101359150565b60008060408385031215612ed6578182fd5b8235915060208301356001600160401b0381168114612ef3578182fd5b809150509250929050565b600060208284031215612f0f578081fd5b81356122c1816139dc565b60008060008060808587031215612f2f578182fd5b8435612f3a816139dc565b93506020850135612f4a816139dc565b92506040850135612f5a816139dc565b91506060850135612f6a816139dc565b939692955090935050565b8060005b600481101561232057815160ff16845260209384019390910190600101612f79565b60008251612fad818460208701613998565b9190910192915050565b6001600160a01b0391909116815260200190565b6001600160a01b038516815260e08101612fe86020830186612f75565b60a082019390935260c0015292915050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b8181101561306f57835183529284019291840191600101613053565b50909695505050505050565b6101608101818360005b600b811015612b7d5781516001600160401b0316835260209283019290910190600101613085565b905460ff8082168352600882901c81166020840152601082901c8116604084015260189190911c16606082015260800190565b901515815260200190565b9283526020830191909152604082015260600190565b93845260208401929092526040830152606082015260800190565b600060208252825180602084015261313b816040850160208701613998565b601f01601f19169190910160400192915050565b6020808252602b908201527f4c6f74746572793a3a656e74657244726177696e6750686173653a3a20616c7260408201526a1958591e48191c985dd95960aa1b606082015260800190565b6020808252602c908201527f4c6f74746572793a3a64726177696e673a3a20656e7465722064726177696e6760408201526b081c1a185cd948199a5c9cdd60a21b606082015260800190565b60208082526028908201527f4c6f74746572793a3a6f6e6c7941646d696e3a3a206f6e6c792061646d696e2060408201526718d85b8818d85b1b60c21b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526027908201527f4c6f74746572793a6275793a3a207072696365206d7573742061626f7665206d604082015266696e507269636560c81b606082015260800190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b60208082526032908201527f4c6f74746572793a3a696e44726177696e6750686173653a3a2064726177696e604082015271672c2063616e206e6f7420627579206e6f7760701b606082015260800190565b60208082526022908201527f4c6f74746572793a3a6275793a3a20657863656564206e756d6265722073636f604082015261706560f01b606082015260800190565b6020808252601d908201527f4c6f74746572793a3a6d756c7469436c61696d3a3a20636c61696d6564000000604082015260600190565b60208082526034908201527f4c6f74746572793a3a676574546f74616c526577617264733a3a205f697373756040820152730ca92dcc8caf040787a40d2e6e6eaca92dcc8caf60631b606082015260800190565b60208082526021908201527f4c6f74746572793a3a64726177696e673a3a20616c72656164792064726177656040820152601960fa1b606082015260800190565b60208082526027908201527f4c6f74746572793a3a6d756c74694275793a3a20657863656564206e756d6265604082015266722073636f706560c81b606082015260800190565b60208082526029908201527f4c6f74746572793a3a696e7465726e616c4275793a3a2065786365656420746860408201526865206d6178696d756d60b81b606082015260800190565b6020808252601e908201527f4c6f74746572793a3a636c61696d5265776172643a3a20636c61696d65640000604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526023908201527f4c6f74746572793a3a676574526577617264566965773a3a206e6f74206472616040820152621dd95960ea1b606082015260800190565b6020808252602d908201527f4c6f74746572793a3a6d756c74694275793a3a207072696365206d757374206160408201526c626f7665206d696e507269636560981b606082015260800190565b60208082526021908201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6040820152607760f81b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526025908201527f4c6f74746572793a3a636c61696d5265776172643a3a206e6f742066726f6d2060408201526437bbb732b960d91b606082015260800190565b6020808252602f908201527f4c6f74746572793a3a696e6a6563745265776172643a3a20616363657074206f60408201526e1b9b1e481b9d5b1b081d1a58dad95d608a1b606082015260800190565b60208082526024908201527f4c6f74746572793a3a6d756c7469436c61696d3a3a206e6f742066726f6d206f6040820152633bb732b960e11b606082015260800190565b60208082526018908201527f4c6f74746572793a3a72657365743a3a206472617765643f0000000000000000604082015260600190565b6020808252602f908201527f4c6f74746572793a3a696e6a6563745265776172643a3a206472617765642c2060408201526e63616e206e6f7420627579206e6f7760881b606082015260800190565b6020808252602e908201527f4c6f74746572793a3a696e7465726e616c4275793a3a206472617765642c206360408201526d616e206e6f7420627579206e6f7760901b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b6020808252602a908201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6040820152691bdd081cdd58d8d9595960b21b606082015260800190565b60208082526031908201527f4c6f74746572793a3a696e44726177696e6750686173653a3a206472617765646040820152702c2063616e206e6f7420627579206e6f7760781b606082015260800190565b60208082526023908201527f4c6f74746572793a3a736574416c6c6f636174696f6e3a3a206578636565642060408201526203130360ec1b606082015260800190565b90815260200190565b918252602082015260400190565b60ff91909116815260200190565b6040518181016001600160401b038111828210171561397157600080fd5b604052919050565b60006001600160401b0382111561398e578081fd5b5060209081020190565b60005b838110156139b357818101518382015260200161399b565b838111156123205750506000910152565b6001600160a01b03811681146139d957600080fd5b50565b60ff811681146139d957600080fdfea26469706673582212205ae6040362b5460ee15378641b94ba957a9cf65c9fc80844304a88d21e79150164736f6c634300060c0033

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