Contract 0x5189404f255bb7724f969429bdc7655ea5057dd7

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x0826d7b12315cb097ae4292629b5ddeed1d4d00ff922eccaa20b366278d05bd0Mint To Proxy297917602022-06-20 13:01:4449 days 6 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.038552357374 67.035336807
0xee8ab30cf309f64ee43050e87d24d08c74c305ef3e5967d47ddcee45b335f6e2Mint To Proxy293729962022-06-09 22:53:3559 days 20 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.038440256 64
0x6a69a12915eefbbcfe6dbe136c90e61c8483e019ffcf3d82370836e33f21c904Mint To Proxy293728402022-06-09 22:48:1159 days 20 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.035438527 59
0x58bcc9beb43dbf1b89dc4ed9f3d0b5425830d3af727001dd6a1e071c720afda7Mint To Proxy293717102022-06-09 22:07:1159 days 21 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.037241974 62
0xb328b18db3f84c2c5d10f4d93496fdc559f325885559e10f40f9bb1f753f898eMint To Proxy293084922022-06-08 8:16:4361 days 11 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.124327098 207
0xfe47f6b0f0f78b6dea6859e5b594691b1c9d26c4f7e4bee5c527e6f7f5c4d37dMint To Proxy293078412022-06-08 7:54:2161 days 11 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.025225788 42
0xbbb44fda5afb70225ab93e73515b077efa021c6f9e3938596f7cb468ee1b0edaMint To Proxy292926132022-06-07 22:54:2461 days 20 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.239663073171 398.998227242
0x1d6f4a526735d7fefc08a302cdd9c9de0001f21fac84668ad1e1f54c404ba8b2Mint To Proxy292894292022-06-07 20:58:3261 days 22 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.029435378 49
0xb6c4aa545b40b47056d526baddc8190a708e3e5fe7599a0219bd0f883edbdccaMint To Proxy292884872022-06-07 20:24:0061 days 23 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.039645276 66
0x866506b3d07a0daebdd3263939396263ec9f8a69aebe99ed5f1a48f17ea21069Mint To Proxy292848522022-06-07 18:14:4562 days 1 hr ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.05466461 91
0x488c57b198990746c39bd1ac1a652793f7ab0ff562bb218e9d0b9177498fd30fMint To Proxy291733022022-06-04 23:27:2164 days 19 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.026427148 44
0x44b2b99214722ed0137111912ec257414a9888138b4fe1d433a5606220fc5549Mint To Proxy291585592022-06-04 14:49:0865 days 4 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.03303377 55
0x531f593e4eddb25f62a781a126c6c983d414575ef5b7f0b26f3e5fa4c1910e18Mint To Proxy291161192022-06-03 13:22:5666 days 6 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.034833698 58
0x232416896a6d1302b2088db35c427d50954e27fd64c35ad5f1cbc4b6a6ae438cMint To Proxy291080272022-06-03 8:35:5466 days 10 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.025227804 42
0x15e62acd5b9f263c3b2eac72d2145c5436e44b80d623e103f97ef4a11b646821Mint To Proxy291065142022-06-03 7:41:3766 days 11 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.026427676 44
0x9bb8c9dc011cf572f560c678fcef936f90c06f462698a285e2e506ae335e1764Mint To Proxy291021442022-06-03 5:06:4166 days 14 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.024155418 42
0x9dfcf8834d80c7b58cb55f9c08ccfedc3307fb0660b2542fce0922220c6490d8Mint To Wallet279944652022-05-06 14:20:2994 days 5 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.046868341208 181.332713814
0x9f67656c77d5f729e71380144f6f33ae2a6ae0c1eac6009c02b9ea0572cf0eeeMint To Wallet279944332022-05-06 14:19:2594 days 5 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.040768572405 157.732825228
0x78d8927f82c6d1706d3ff4b4f62ab10777c7783a722ea7b60b466311841dacd9Mint To Wallet279943022022-05-06 14:14:5194 days 5 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.023644755704 91.481106623
0xa285886dfc823ec6221558d538cc2b06b812d7b2b128257d55921d0585079defMint To Wallet279942012022-05-06 14:11:2594 days 5 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.041945385981 162.249485468
0x6966ae8205d24dbba37c1fb1fb943ca20fc41c29d482b0c3ff08ff26236ea9f7Mint To Wallet279941122022-05-06 14:08:2394 days 5 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.027437684464 106.132059167
0xbd94714de55d80462451a95d5fc470fbbea79e19caf5cfee66211d0be8a5f2f8Mint To Wallet279937672022-05-06 13:56:2994 days 5 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.051879510548 200.675800112
0xcaa84e43c08eccebd07ebdf56d4acfc0998dff9e872cdf1876df8710a6c891c3Mint To Proxy277330162022-04-29 22:45:44100 days 20 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.020074721247 33.418991319
0xd18d6ede681613ef9538acd7b2edb49bb5ba75915060bad439c72918db6ca213Mint To Wallet277299862022-04-29 20:53:02100 days 22 hrs ago0xb89ea19ceff7aef21706d739007c34289189166f IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.007830521273 47.462594776
0x7af9d3f68c1c49c0b9d4d7a2a1de65f315bababa8422716e7424fbbb42b7b55cMint To Wallet274926632022-04-23 20:09:15106 days 23 hrs ago0x9a0159d95ad4e17750e33d6e8ec93a7986e2acb1 IN  0x5189404f255bb7724f969429bdc7655ea5057dd70 MATIC0.01009309485560.155646612
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x0826d7b12315cb097ae4292629b5ddeed1d4d00ff922eccaa20b366278d05bd0297917602022-06-20 13:01:4449 days 6 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0xee8ab30cf309f64ee43050e87d24d08c74c305ef3e5967d47ddcee45b335f6e2293729962022-06-09 22:53:3559 days 20 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x6a69a12915eefbbcfe6dbe136c90e61c8483e019ffcf3d82370836e33f21c904293728402022-06-09 22:48:1159 days 20 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x58bcc9beb43dbf1b89dc4ed9f3d0b5425830d3af727001dd6a1e071c720afda7293717102022-06-09 22:07:1159 days 21 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0xb328b18db3f84c2c5d10f4d93496fdc559f325885559e10f40f9bb1f753f898e293084922022-06-08 8:16:4361 days 11 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0xfe47f6b0f0f78b6dea6859e5b594691b1c9d26c4f7e4bee5c527e6f7f5c4d37d293078412022-06-08 7:54:2161 days 11 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0xbbb44fda5afb70225ab93e73515b077efa021c6f9e3938596f7cb468ee1b0eda292926132022-06-07 22:54:2461 days 20 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x1d6f4a526735d7fefc08a302cdd9c9de0001f21fac84668ad1e1f54c404ba8b2292894292022-06-07 20:58:3261 days 22 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0xb6c4aa545b40b47056d526baddc8190a708e3e5fe7599a0219bd0f883edbdcca292884872022-06-07 20:24:0061 days 23 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x866506b3d07a0daebdd3263939396263ec9f8a69aebe99ed5f1a48f17ea21069292848522022-06-07 18:14:4562 days 1 hr ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x488c57b198990746c39bd1ac1a652793f7ab0ff562bb218e9d0b9177498fd30f291733022022-06-04 23:27:2164 days 19 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x44b2b99214722ed0137111912ec257414a9888138b4fe1d433a5606220fc5549291585592022-06-04 14:49:0865 days 4 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x531f593e4eddb25f62a781a126c6c983d414575ef5b7f0b26f3e5fa4c1910e18291161192022-06-03 13:22:5666 days 6 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x232416896a6d1302b2088db35c427d50954e27fd64c35ad5f1cbc4b6a6ae438c291080272022-06-03 8:35:5466 days 10 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x15e62acd5b9f263c3b2eac72d2145c5436e44b80d623e103f97ef4a11b646821291065142022-06-03 7:41:3766 days 11 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x9bb8c9dc011cf572f560c678fcef936f90c06f462698a285e2e506ae335e1764291021442022-06-03 5:06:4166 days 14 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0xcaa84e43c08eccebd07ebdf56d4acfc0998dff9e872cdf1876df8710a6c891c3277330162022-04-29 22:45:44100 days 20 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd7  Contract Creation0 MATIC
0x18c9746a53deeea91f064abcb9daf5ec56973495296b99a18dfd0776d141c5ed274926542022-04-23 20:08:57106 days 23 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70x2a706d782922d4b340fcbdb21607ce49f622ebbe2.412000000000000059 MATIC
0x18c9746a53deeea91f064abcb9daf5ec56973495296b99a18dfd0776d141c5ed274926542022-04-23 20:08:57106 days 23 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70xd9709233a70c4ced9e3974a40ca8564e7e06b8e60.540000000000000013 MATIC
0x18c9746a53deeea91f064abcb9daf5ec56973495296b99a18dfd0776d141c5ed274926542022-04-23 20:08:57106 days 23 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70x4ead4cc6642466162b728a1dde0d134cf60db9df0.540000000000000013 MATIC
0x18c9746a53deeea91f064abcb9daf5ec56973495296b99a18dfd0776d141c5ed274926542022-04-23 20:08:57106 days 23 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70x751e859f490dfdbc78e7f2aa0f9b0996f3f203ab0.108000000000000002 MATIC
0xf2204cb517dda3b4c73750d20813f3495cb80574390903353082f965066846ca274660712022-04-23 3:10:44107 days 16 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70x2a706d782922d4b340fcbdb21607ce49f622ebbe16.884000000000001904 MATIC
0xf2204cb517dda3b4c73750d20813f3495cb80574390903353082f965066846ca274660712022-04-23 3:10:44107 days 16 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70xd9709233a70c4ced9e3974a40ca8564e7e06b8e63.780000000000000426 MATIC
0xf2204cb517dda3b4c73750d20813f3495cb80574390903353082f965066846ca274660712022-04-23 3:10:44107 days 16 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70x4ead4cc6642466162b728a1dde0d134cf60db9df3.780000000000000426 MATIC
0xf2204cb517dda3b4c73750d20813f3495cb80574390903353082f965066846ca274660712022-04-23 3:10:44107 days 16 hrs ago 0x5189404f255bb7724f969429bdc7655ea5057dd70x751e859f490dfdbc78e7f2aa0f9b0996f3f203ab0.756000000000000085 MATIC
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Crowdsale

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 30 : Crowdsale.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "./NFTCollection.sol";
import "./libraries/TransferHelper.sol";
import "./ProxyWallet.sol";
import "./Prize.sol";

contract Crowdsale is AccessControl {
    address public PrizeDrawer;

    address[] public distWallets;
    mapping(address => uint256) public distPercentile;

    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PROXY_ADMIN_ROLE = keccak256("PROXY_ADMIN_ROLE");

    bool public isEnabled = false;

    /// Either public sale or private sale should be enabled.
    error SaleIsNotEnabled();

    /**
     * @dev Emitted when distribution wallet is added.
     */
    event AddedDistributionWallet(
        address indexed wallet,
        uint256 indexed percentile
    );

    /**
     * @dev Emitted when distribution wallet is removed.
     */
    event RemovedDistributionWallet(
        address indexed wallet,
        uint256 indexed percentile
    );

    /**
     * @dev Emitted when `tokenId` token is transferred to `to`.
     */
    event TransferFromProxyWallet(
        address indexed collection,
        address indexed to,
        string indexed email
    );

    event OrderPaidWithERC20Token(
        uint256 indexed orderId,
        address buyer,
        uint256 indexed amount,
        address indexed token
    );

    event OrderPaidWithMatic(
        uint256 indexed orderId,
        address indexed buyer,
        uint256 indexed amount
    );

    event MintedToProxy(
        uint256 indexed orderId,
        address indexed collection,
        uint256 indexed tokenId,
        string email,
        address proxy
    );

    event MintedToWallet(
        uint256 orderId,
        address indexed collection,
        uint256 indexed tokenId,
        address indexed wallet
    );

    event PrizeMinted(
        address indexed collection,
        uint256 indexed tokenId,
        address indexed wallet
    );

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

    function addDistributionWallet(address payable wallet, uint256 percentile)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        require(wallet != address(0), "zero address cannot be used");
        require(distPercentile[wallet] == 0, "wallet had been already used.");

        require(
            totalDistPercentile() + percentile <= 100,
            "Total percentile of distribution should be less than 100"
        );
        distWallets.push(wallet);
        distPercentile[wallet] = percentile;

        emit AddedDistributionWallet(wallet, percentile);
    }

    function removeDistributionWallet(address payable wallet)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        require(distPercentile[wallet] > 0, "wallet was not registered");

        for (uint256 i = 0; i < distWallets.length; i++) {
            if (distWallets[i] == wallet) {
                emit RemovedDistributionWallet(wallet, distPercentile[wallet]);
                delete distPercentile[wallet];
                _removeDistWallet(i);
                break;
            }
        }
    }

    function _removeDistWallet(uint256 index) private {
        // require(index < distWallets.length, "index out of bound");

        for (uint256 i = index; i < distWallets.length - 1; i++) {
            distWallets[i] = distWallets[i + 1];
        }
        distWallets.pop();
    }

    function mintToProxy(
        uint256 orderId,
        address collection,
        uint256 amount,
        string memory email,
        bool prize
    ) external onlyRole(MINTER_ROLE) {
        require(collection != address(0), "Zero address cannot be used");
        require(amount > 0, "amount should be greater than 0");
        require(orderId > 0, "orderId should be greater than 0");

        ProxyWallet proxy = new ProxyWallet(email);
        for (uint256 i = 0; i < amount; i++) {
            uint256 tokenId = NFTCollection(collection).safeMint(
                address(proxy)
            );
            if (prize) {
                Prize(PrizeDrawer).draw(address(proxy), collection, tokenId);
            }

            emit MintedToProxy(
                orderId,
                collection,
                tokenId,
                email,
                address(proxy)
            );
        }
    }

    function mintToWallet(
        uint256 orderId,
        address collection,
        uint256 amount,
        address wallet,
        bool prize
    ) external onlyRole(MINTER_ROLE) {
        require(collection != address(0), "Zero address cannot be used");
        require(amount > 0, "amount should be greater than 0");
        require(orderId > 0, "orderId should be greater than 0");

        for (uint256 i = 0; i < amount; i++) {
            uint256 tokenId = NFTCollection(collection).safeMint(wallet);
            if (prize) {
                Prize(PrizeDrawer).draw(wallet, collection, tokenId);
            }
            emit MintedToWallet(orderId, collection, tokenId, wallet);
        }
    }

    function mintPrizeWinner(
        address collection,
        uint256 amount,
        address wallet
    ) external {
        require(
            msg.sender == PrizeDrawer,
            "only prize drawer smart contract can call this"
        );
        require(collection != address(0), "Zero address cannot be used");
        require(amount > 0, "amount should be greater than 0");
        require(wallet != address(0), "orderId should be greater than 0");

        for (uint256 i = 0; i < amount; i++) {
            uint256 tokenId = NFTCollection(collection).safeMint(wallet);
            emit PrizeMinted(collection, tokenId, wallet);
        }
    }

    /**
     * transfer token from Proxy Wallet Contract to the user.
     */
    function transferFromProxy(
        address collection,
        address from,
        address to
    ) external onlyRole(PROXY_ADMIN_ROLE) {
        ProxyWallet(from).transferAll(collection, to);
        emit TransferFromProxyWallet(collection, to, ProxyWallet(from).email());
    }

    function payOrderWithERC20Token(
        uint256 orderId,
        address token,
        uint256 amount
    ) public {
        require(isEnabled, "Sale is disabled");
        require(amount > 0, "need to buy at least 1 token");

        uint256 allowance = IERC20(token).allowance(msg.sender, address(this));
        require(allowance >= amount, "token allowance is not enough");

        TransferHelper.safeTransferFrom(
            token,
            msg.sender,
            address(this),
            amount
        );

        _forwardToken(token, amount);

        emit OrderPaidWithERC20Token(orderId, msg.sender, amount, token);
    }

    function payOrderWithMatic(uint256 orderId) public payable {
        require(isEnabled, "Sale is disabled");
        require(msg.value > 0, "value should be greater than 0");

        _forwardMatic(msg.value);

        emit OrderPaidWithMatic(orderId, msg.sender, msg.value);
    }

    function setSaleStatus(bool status) external onlyRole(MINTER_ROLE) {
        require(
            totalDistPercentile() == 100 || status==false,
            "Total percentile of distribution should be 100"
        );
        isEnabled = status;
    }

    function setPrizeDrawer(address drawer) external onlyRole(MINTER_ROLE) {
        require(drawer != address(0), "zero address is provided");
        PrizeDrawer = drawer;
    }

    /**
     * Fallback function is called when msg.data is empty
     */
    receive() external payable {
        revert();
    }

    function totalDistPercentile() public view returns (uint256) {
        uint256 totalPercentile = 0;
        for (uint256 i = 0; i < distWallets.length; i++) {
            totalPercentile += distPercentile[distWallets[i]];
        }

        return totalPercentile;
    }

    /**
     * @dev Throws if called when  is disabled.
     */
    modifier onlyWhenSaleIsOff() {
        require(isEnabled == false, "Sale is enabled");
        _;
    }

    function _forwardToken(address token, uint256 amount) private {
        require(amount > 0, "amount should be greater than zero");
        require(
            IERC20(token).balanceOf(address(this)) >= amount,
            "token balance is not enough"
        );

        require(
            totalDistPercentile() == 100,
            "Total percentile of distribution should be 100"
        );

        for (uint256 i = 0; i < distWallets.length; i++) {
            uint256 value = (amount * distPercentile[distWallets[i]]) / 100;
            TransferHelper.safeTransfer(token, distWallets[i], value);
        }
    }

    function _forwardMatic(uint256 amount) private {
        require(amount > 0, "balance should be greater than zero");
        require(address(this).balance >= amount, "ETH balance is not enough");

        require(
            totalDistPercentile() == 100,
            "Total percentile of distribution should be 100"
        );

        for (uint256 i = 0; i < distWallets.length; i++) {
            uint256 value = (amount * distPercentile[distWallets[i]]) / 100;
            TransferHelper.safeTransferETH(distWallets[i], value);
        }
    }

    function withdrawMatic() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _forwardMatic(address(this).balance);
    }

    function withdrawERC20Token(address token)
        external
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        _forwardToken(token, IERC20(token).balanceOf(address(this)));
    }
}

File 2 of 30 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

File 3 of 30 : NFTCollection.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

import "./common/meta-transactions/ContentMixin.sol";
import "./common/meta-transactions/NativeMetaTransaction.sol";

contract NFTCollection is ContextMixin, ERC721, ERC721Enumerable, ERC721URIStorage, NativeMetaTransaction, Ownable, AccessControl {
    using Counters for Counters.Counter;

    uint16 public CREATURE_MAX_SUPPLY = 10000;

    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant METADATA_ROLE = keccak256("METADATA_ROLE");

    Counters.Counter private _tokenIdCounter;

    // Base Token URI
    string private _baseTokenURI;
    address private _proxy;

    constructor(string memory name, string memory symbol, address proxy) ERC721(name, symbol) {
        _initializeEIP712(name);
        _proxy = proxy;

        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(MINTER_ROLE, msg.sender);
        _setupRole(METADATA_ROLE, msg.sender);
    }

    function safeMint(address to) external onlyRole(MINTER_ROLE) returns (uint256) {
        require(totalSupply() < CREATURE_MAX_SUPPLY, "Total Supply is reached to Creature Max Supply");
        _safeMint(to, _tokenIdCounter.current());
        _tokenIdCounter.increment();

        return _tokenIdCounter.current() - 1;
    }

    function setBaseTokenURI(string memory uri) external onlyRole(METADATA_ROLE) {
        _baseTokenURI = uri;
    }

    function baseTokenURI() public view returns (string memory) {
        return _baseURI();
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() override internal view returns (string memory) {
        return _baseTokenURI;
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     */
    function setTokenURI(uint256 tokenId, string memory _tokenURI) external onlyRole(METADATA_ROLE) {
        _setTokenURI(tokenId, _tokenURI);
    }

    /**
     * Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings.
     */
    function isApprovedForAll(address owner, address operator)
        override (ERC721, IERC721)
        public
        view
        returns (bool)
    {
        // Mainnet: if OpenSea's ERC721 Proxy Address is detected, auto-return true
        // if (operator == address(0x58807baD0B376efc12F5AD86aAc70E78ed67deaE)) {
        //     return true;
        // }

        // // Mumbai Testnet: if OpenSea's ERC721 Proxy Address is detected, auto-return true
        // if (operator == address(0xff7Ca10aF37178BdD056628eF42fD7F799fAc77c)) {
        //     return true;
        // }
        
        // if OpenSea's ERC721 Proxy Address is detected, auto-return true
        if (_proxy == operator) {
            return true;
        }

        return super.isApprovedForAll(owner, operator);
    }

    /**
     * This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea.
     */
    function _msgSender()
        internal
        override
        view
        returns (address sender)
    {
        return ContextMixin.msgSender();
    }

     // The following functions are overrides required by Solidity.
    function _beforeTokenTransfer(address from, address to, uint256 tokenId)
        internal
        override(ERC721, ERC721Enumerable)
    {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function _burn(uint256 tokenId) internal override(ERC721, ERC721URIStorage) {
        super._burn(tokenId);
    }

    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721, ERC721URIStorage)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721, ERC721Enumerable, AccessControl)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}

File 4 of 30 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) =
            token.call(abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers ETH to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 5 of 30 : ProxyWallet.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "./Crowdsale.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

contract ProxyWallet is IERC721Receiver {
    address public crowdsale;
    string public email;

    constructor(string memory _email) {
        crowdsale = msg.sender;
        email = _email;
    }

    function transferAll(address collection, address to) external {
        require(msg.sender == crowdsale, "Only Carbon Creature Crowdsale contract can execute");
        require(collection != address(0), "zero address cannot be used for collection");
        require(to != address(0), "zero address cannot be used for recepient");

        IERC721(collection).setApprovalForAll(crowdsale, true);
        
        for (uint i = 0; i < IERC721(collection).balanceOf(address(this)); i++) {
            IERC721(collection).safeTransferFrom(address(this), to, IERC721Enumerable(collection).tokenOfOwnerByIndex(address(this), i));
        }
    }

    /**
     * @dev See {IERC721Receiver-onERC721Received}. Accepts Carbon Creature NFT token transfers.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address _operator,
        address _from,
        uint _tokenId,
        bytes calldata _data
    ) external virtual override returns (bytes4) {
        require(_operator == crowdsale, "Only accept Carbon Creature NFT Crowdsale");
        return this.onERC721Received.selector;
    }
}

File 6 of 30 : Prize.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

/**
 * @notice A Chainlink VRF consumer which uses randomness to determin prize winner.
 */

/**
 * Request testnet LINK and ETH here: https://faucets.chain.link/
 * Find information on LINK Token Contracts and get the latest ETH and LINK faucets here: https://docs.chain.link/docs/link-token-contracts/
 */

interface ICrowdsale {
    function mintPrizeWinner(
        address collection,
        uint256 amount,
        address wallet
    ) external;
}

contract Prize is VRFConsumerBase, AccessControl {
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

    address private _crowdsale;

    uint256 private constant DRAW_IN_PROGRESS = 1000;

    bytes32 private _keyHash;
    uint256 private _fee;

    struct Token {
        address collection;
        address owner;
        uint256 tokenId;
    }

    mapping(bytes32 => Token) private _tokensDrawn;
    mapping(bytes32 => uint256) private _results;

    address[] private _prizeTokens;
    mapping(address => uint256) _prizeAmount;

    uint256 public winningRate;

    event AddedPrizeToken(address indexed token, uint256 indexed amount);
    event RemovedPrizeToken(address indexed token, uint256 indexed amount);

    event Drawn(
        bytes32 indexed requestId,
        address indexed buyer,
        address indexed collection,
        uint256 tokenId
    );
    event Awarded(
        bytes32 indexed requestId,
        address indexed buyer,
        address collection,
        uint256 tokenId,
        bool indexed awarded
    );

    /**
     * @notice Constructor inherits VRFConsumerBase
     *
     * @dev NETWORK: Rinkeby
     * @dev   Chainlink VRF Coordinator address: 0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B
     * @dev   LINK token address:                0x01BE23585060835E02B77ef475b0Cc51aA1e0709
     * @dev   Key Hash:   0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311
     * @dev   Fee:        0.1 LINK (100000000000000000)
     *
     * @param vrfCoordinator address of the VRF Coordinator
     * @param link address of the LINK token
     * @param keyHash bytes32 representing the hash of the VRF job
     * @param fee uint fee to pay the VRF oracle
     */
    constructor(
        address vrfCoordinator,
        address link,
        bytes32 keyHash,
        uint256 fee
    ) VRFConsumerBase(vrfCoordinator, link) {
        _keyHash = keyHash;
        _fee = fee;

        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _setupRole(MINTER_ROLE, msg.sender);
    }

    /**
     * @notice Requests randomness
     * @dev Warning: if the VRF response is delayed, avoid calling requestRandomness repeatedly
     * as that would give miners/VRF operators latitude about which VRF response arrives first.
     * @dev You must review your implementation details with extreme care.
     *
     * @param buyer address of the buyer who prize draw
     */
    function draw(
        address buyer,
        address collection,
        uint256 tokenId
    ) public returns (bytes32 requestId) {
        require(
            msg.sender == _crowdsale,
            "only crowdsale contract can call this"
        );
        require(
            LINK.balanceOf(address(this)) >= _fee,
            "Not enough LINK to pay fee"
        );
        require(
            _crowdsale != address(0),
            "crowdsale contract address is invalid"
        );

        requestId = requestRandomness(_keyHash, _fee);
        _tokensDrawn[requestId].collection = collection;
        _tokensDrawn[requestId].owner = buyer;
        _tokensDrawn[requestId].tokenId = tokenId;
        _results[requestId] = DRAW_IN_PROGRESS;
        emit Drawn(requestId, buyer, collection, tokenId);
    }

    /**
     * @notice Callback function used by VRF Coordinator to return the random number
     * to this contract.
     * @dev Some action on the contract state should be taken here, like storing the result.
     * @dev WARNING: take care to avoid having multiple VRF requests in flight if their order of arrival would result
     * in contract states with different outcomes. Otherwise miners or the VRF operator would could take advantage
     * by controlling the order.
     * @dev The VRF Coordinator will only send this function verified responses, and the parent VRFConsumerBase
     * contract ensures that this method only receives randomness from the designated VRFCoordinator.
     *
     * @param requestId bytes32
     * @param randomness The random result returned by the oracle
     */
    function fulfillRandomness(bytes32 requestId, uint256 randomness)
        internal
        override
    {
        uint256 result = (randomness % winningRate);
        _results[requestId] = result;

        if (result == 0) {
            _award(requestId);
        }

        emit Awarded(
            requestId,
            _tokensDrawn[requestId].owner,
            _tokensDrawn[requestId].collection,
            _tokensDrawn[requestId].tokenId,
            result == 0
        );
    }

    /**
     * @notice Withdraw LINK from this contract.
     * @dev this is an example only, and in a real contract withdrawals should
     * happen according to the established withdrawal pattern:
     * https://docs.soliditylang.org/en/v0.4.24/common-patterns.html#withdrawal-from-contracts
     * @param to the address to withdraw LINK to
     * @param value the amount of LINK to withdraw
     */
    function withdrawLINK(address to, uint256 value)
        public
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        require(LINK.transfer(to, value), "Not enough LINK");
    }

    /**
     * @notice Set the key hash for the oracle
     *
     * @param keyHash bytes32
     */
    function setKeyHash(bytes32 keyHash) public onlyRole(DEFAULT_ADMIN_ROLE) {
        _keyHash = keyHash;
    }

    /**
     * @notice Get the current key hash
     *
     * @return bytes32
     */
    function keyHash() public view returns (bytes32) {
        return _keyHash;
    }

    /**
     * @notice Set the oracle fee for requesting randomness
     *
     * @param fee uint
     */
    function setFee(uint256 fee) public onlyRole(DEFAULT_ADMIN_ROLE) {
        _fee = fee;
    }

    /**
     * @notice Get the current fee
     *
     * @return uint
     */
    function fee() public view returns (uint256) {
        return _fee;
    }

    function setCrowdsale(address crowdsale)
        public
        onlyRole(MINTER_ROLE)
    {
        require(
            crowdsale != address(0),
            "crowdsale contract address is invalid"
        );
        _crowdsale = crowdsale;
    }

    function crowdsale() public view returns (address) {
        return _crowdsale;
    }

    function setWinningRate(uint256 rate)
        public
        onlyRole(MINTER_ROLE)
    {
        require(rate > 0, "winning rate should be greater than 0");
        winningRate = rate;
    }

    /**
     * @notice Returns draw prize details as tuple for requestId.
     */
    function getDrawDetail(bytes32 requestId)
        public
        view
        returns (
            address owner,
            address collection,
            uint256 tokenId,
            uint256 result
        )
    {
        Token storage d = _tokensDrawn[requestId]; // copy to memory
        return (d.owner, d.collection, d.tokenId, _results[requestId]);
    }

    function addPrizeToken(address token, uint256 amount)
        public
        onlyRole(MINTER_ROLE)
    {
        require(token != address(0), "zero address cannot be used");
        require(amount > 0, "prize amount should be greater than 0");

        _prizeTokens.push(token);
        _prizeAmount[token] = amount;

        emit AddedPrizeToken(token, amount);
    }

    function removePrizeToken(address token) public onlyRole(MINTER_ROLE) {
        require(_prizeAmount[token] > 0, "token was not registered");

        for (uint256 i = 0; i < _prizeTokens.length; i++) {
            if (_prizeTokens[i] == token) {
                emit RemovedPrizeToken(token, _prizeAmount[token]);
                delete _prizeAmount[token];
                _removePrizeToken(i);
                break;
            }
        }
    }

    function prizeTokenByIndex(uint256 index) public view returns (address) {
        require(index < _prizeTokens.length, "token index out of bounds");
        return _prizeTokens[index];
    }

    function prizeAmount(address token) public view returns (uint256) {
        return _prizeAmount[token];
    }

    function _removePrizeToken(uint256 index) private {
        for (uint256 i = index; i < _prizeTokens.length - 1; i++) {
            _prizeTokens[i] = _prizeTokens[i + 1];
        }
        _prizeTokens.pop();
    }

    function _award(bytes32 requestId) private {
        for (uint256 i = 0; i < _prizeTokens.length; i++) {
            ICrowdsale(_crowdsale).mintPrizeWinner(
                _prizeTokens[i],
                _prizeAmount[_prizeTokens[i]],
                _tokensDrawn[requestId].owner
            );
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

File 9 of 30 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

File 12 of 30 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

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

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

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

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

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

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

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

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

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.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 virtual 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 {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual 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 mechanisms 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 virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

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

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `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);

        _balances[to] += 1;
        _owners[tokenId] = to;

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

        _afterTokenTransfer(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 = ERC721.ownerOf(tokenId);

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

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

        _balances[owner] -= 1;
        delete _owners[tokenId];

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

        _afterTokenTransfer(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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

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

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @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()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @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` and `to` are never both zero.
     *
     * 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 {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

File 13 of 30 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @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 override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 14 of 30 : ERC721URIStorage.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721URIStorage.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";

/**
 * @dev ERC721 token with storage based token URI management.
 */
abstract contract ERC721URIStorage is ERC721 {
    using Strings for uint256;

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

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

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).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(base, _tokenURI));
        }

        return super.tokenURI(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), "ERC721URIStorage: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @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 override {
        super._burn(tokenId);

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

File 15 of 30 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

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.
 */
abstract 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() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual 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 {
        _transferOwnership(address(0));
    }

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

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

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

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. 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;`
 */
library Counters {
    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 {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 17 of 30 : ContentMixin.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.13;

abstract contract ContextMixin {
    function msgSender()
        internal
        view
        returns (address payable sender)
    {
        if (msg.sender == address(this)) {
            bytes memory array = msg.data;
            uint256 index = msg.data.length;
            assembly {
                // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
                sender := and(
                    mload(add(array, index)),
                    0xffffffffffffffffffffffffffffffffffffffff
                )
            }
        } else {
            sender = payable(msg.sender);
        }
        return sender;
    }
}

File 18 of 30 : NativeMetaTransaction.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.13;

import {SafeMath} from  "@openzeppelin/contracts/utils/math/SafeMath.sol";
import {EIP712Base} from "./EIP712Base.sol";

contract NativeMetaTransaction is EIP712Base {
    using SafeMath for uint256;
    bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256(
        bytes(
            "MetaTransaction(uint256 nonce,address from,bytes functionSignature)"
        )
    );
    event MetaTransactionExecuted(
        address userAddress,
        address payable relayerAddress,
        bytes functionSignature
    );
    mapping(address => uint256) nonces;

    /*
     * Meta transaction structure.
     * No point of including value field here as if user is doing value transfer then he has the funds to pay for gas
     * He should call the desired function directly in that case.
     */
    struct MetaTransaction {
        uint256 nonce;
        address from;
        bytes functionSignature;
    }

    function executeMetaTransaction(
        address userAddress,
        bytes memory functionSignature,
        bytes32 sigR,
        bytes32 sigS,
        uint8 sigV
    ) public payable returns (bytes memory) {
        MetaTransaction memory metaTx = MetaTransaction({
            nonce: nonces[userAddress],
            from: userAddress,
            functionSignature: functionSignature
        });

        require(
            verify(userAddress, metaTx, sigR, sigS, sigV),
            "Signer and signature do not match"
        );

        // increase nonce for user (to avoid re-use)
        nonces[userAddress] = nonces[userAddress].add(1);

        emit MetaTransactionExecuted(
            userAddress,
            payable(msg.sender),
            functionSignature
        );

        // Append userAddress and relayer address at the end to extract it from calling context
        (bool success, bytes memory returnData) = address(this).call(
            abi.encodePacked(functionSignature, userAddress)
        );
        require(success, "Function call not successful");

        return returnData;
    }

    function hashMetaTransaction(MetaTransaction memory metaTx)
        internal
        pure
        returns (bytes32)
    {
        return
            keccak256(
                abi.encode(
                    META_TRANSACTION_TYPEHASH,
                    metaTx.nonce,
                    metaTx.from,
                    keccak256(metaTx.functionSignature)
                )
            );
    }

    function getNonce(address user) public view returns (uint256 nonce) {
        nonce = nonces[user];
    }

    function verify(
        address signer,
        MetaTransaction memory metaTx,
        bytes32 sigR,
        bytes32 sigS,
        uint8 sigV
    ) internal view returns (bool) {
        require(signer != address(0), "NativeMetaTransaction: INVALID_SIGNER");
        return
            signer ==
            ecrecover(
                toTypedMessageHash(hashMetaTransaction(metaTx)),
                sigV,
                sigR,
                sigS
            );
    }
}

File 19 of 30 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, 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 20 of 30 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @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 21 of 30 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

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 22 of 30 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 23 of 30 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

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);

    /**
     * @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 24 of 30 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // 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 (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @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) {
        return a + b;
    }

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

    /**
     * @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) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting 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 a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting 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) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * 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) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 25 of 30 : EIP712Base.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.13;

import {Initializable} from "./Initializable.sol";

contract EIP712Base is Initializable {
    struct EIP712Domain {
        string name;
        string version;
        address verifyingContract;
        bytes32 salt;
    }

    string constant public ERC712_VERSION = "1";

    bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256(
        bytes(
            "EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)"
        )
    );
    bytes32 internal domainSeperator;

    // supposed to be called once while initializing.
    // one of the contracts that inherits this contract follows proxy pattern
    // so it is not possible to do this in a constructor
    function _initializeEIP712(
        string memory name
    )
        internal
        initializer
    {
        _setDomainSeperator(name);
    }

    function _setDomainSeperator(string memory name) internal {
        domainSeperator = keccak256(
            abi.encode(
                EIP712_DOMAIN_TYPEHASH,
                keccak256(bytes(name)),
                keccak256(bytes(ERC712_VERSION)),
                address(this),
                bytes32(getChainId())
            )
        );
    }

    function getDomainSeperator() public view returns (bytes32) {
        return domainSeperator;
    }

    function getChainId() public view returns (uint256) {
        uint256 id;
        assembly {
            id := chainid()
        }
        return id;
    }

    /**
     * Accept message hash and returns hash message in EIP712 compatible form
     * So that it can be used to recover signer from signature signed using EIP712 formatted data
     * https://eips.ethereum.org/EIPS/eip-712
     * "\\x19" makes the encoding deterministic
     * "\\x01" is the version byte to make it compatible to EIP-191
     */
    function toTypedMessageHash(bytes32 messageHash)
        internal
        view
        returns (bytes32)
    {
        return
            keccak256(
                abi.encodePacked("\x19\x01", getDomainSeperator(), messageHash)
            );
    }
}

File 26 of 30 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.13;

contract Initializable {
    bool inited = false;

    modifier initializer() {
        require(!inited, "already inited");
        _;
        inited = true;
    }
}

File 27 of 30 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, 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 `from` to `to` 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 from,
        address to,
        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 28 of 30 : VRFConsumerBase.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./interfaces/LinkTokenInterface.sol";

import "./VRFRequestIDBase.sol";

/** ****************************************************************************
 * @notice Interface for contracts using VRF randomness
 * *****************************************************************************
 * @dev PURPOSE
 *
 * @dev Reggie the Random Oracle (not his real job) wants to provide randomness
 * @dev to Vera the verifier in such a way that Vera can be sure he's not
 * @dev making his output up to suit himself. Reggie provides Vera a public key
 * @dev to which he knows the secret key. Each time Vera provides a seed to
 * @dev Reggie, he gives back a value which is computed completely
 * @dev deterministically from the seed and the secret key.
 *
 * @dev Reggie provides a proof by which Vera can verify that the output was
 * @dev correctly computed once Reggie tells it to her, but without that proof,
 * @dev the output is indistinguishable to her from a uniform random sample
 * @dev from the output space.
 *
 * @dev The purpose of this contract is to make it easy for unrelated contracts
 * @dev to talk to Vera the verifier about the work Reggie is doing, to provide
 * @dev simple access to a verifiable source of randomness.
 * *****************************************************************************
 * @dev USAGE
 *
 * @dev Calling contracts must inherit from VRFConsumerBase, and can
 * @dev initialize VRFConsumerBase's attributes in their constructor as
 * @dev shown:
 *
 * @dev   contract VRFConsumer {
 * @dev     constructor(<other arguments>, address _vrfCoordinator, address _link)
 * @dev       VRFConsumerBase(_vrfCoordinator, _link) public {
 * @dev         <initialization with other arguments goes here>
 * @dev       }
 * @dev   }
 *
 * @dev The oracle will have given you an ID for the VRF keypair they have
 * @dev committed to (let's call it keyHash), and have told you the minimum LINK
 * @dev price for VRF service. Make sure your contract has sufficient LINK, and
 * @dev call requestRandomness(keyHash, fee, seed), where seed is the input you
 * @dev want to generate randomness from.
 *
 * @dev Once the VRFCoordinator has received and validated the oracle's response
 * @dev to your request, it will call your contract's fulfillRandomness method.
 *
 * @dev The randomness argument to fulfillRandomness is the actual random value
 * @dev generated from your seed.
 *
 * @dev The requestId argument is generated from the keyHash and the seed by
 * @dev makeRequestId(keyHash, seed). If your contract could have concurrent
 * @dev requests open, you can use the requestId to track which seed is
 * @dev associated with which randomness. See VRFRequestIDBase.sol for more
 * @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind,
 * @dev if your contract could have multiple requests in flight simultaneously.)
 *
 * @dev Colliding `requestId`s are cryptographically impossible as long as seeds
 * @dev differ. (Which is critical to making unpredictable randomness! See the
 * @dev next section.)
 *
 * *****************************************************************************
 * @dev SECURITY CONSIDERATIONS
 *
 * @dev A method with the ability to call your fulfillRandomness method directly
 * @dev could spoof a VRF response with any random value, so it's critical that
 * @dev it cannot be directly called by anything other than this base contract
 * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method).
 *
 * @dev For your users to trust that your contract's random behavior is free
 * @dev from malicious interference, it's best if you can write it so that all
 * @dev behaviors implied by a VRF response are executed *during* your
 * @dev fulfillRandomness method. If your contract must store the response (or
 * @dev anything derived from it) and use it later, you must ensure that any
 * @dev user-significant behavior which depends on that stored value cannot be
 * @dev manipulated by a subsequent VRF request.
 *
 * @dev Similarly, both miners and the VRF oracle itself have some influence
 * @dev over the order in which VRF responses appear on the blockchain, so if
 * @dev your contract could have multiple VRF requests in flight simultaneously,
 * @dev you must ensure that the order in which the VRF responses arrive cannot
 * @dev be used to manipulate your contract's user-significant behavior.
 *
 * @dev Since the ultimate input to the VRF is mixed with the block hash of the
 * @dev block in which the request is made, user-provided seeds have no impact
 * @dev on its economic security properties. They are only included for API
 * @dev compatability with previous versions of this contract.
 *
 * @dev Since the block hash of the block which contains the requestRandomness
 * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful
 * @dev miner could, in principle, fork the blockchain to evict the block
 * @dev containing the request, forcing the request to be included in a
 * @dev different block with a different hash, and therefore a different input
 * @dev to the VRF. However, such an attack would incur a substantial economic
 * @dev cost. This cost scales with the number of blocks the VRF oracle waits
 * @dev until it calls responds to a request.
 */
abstract contract VRFConsumerBase is VRFRequestIDBase {
  /**
   * @notice fulfillRandomness handles the VRF response. Your contract must
   * @notice implement it. See "SECURITY CONSIDERATIONS" above for important
   * @notice principles to keep in mind when implementing your fulfillRandomness
   * @notice method.
   *
   * @dev VRFConsumerBase expects its subcontracts to have a method with this
   * @dev signature, and will call it once it has verified the proof
   * @dev associated with the randomness. (It is triggered via a call to
   * @dev rawFulfillRandomness, below.)
   *
   * @param requestId The Id initially returned by requestRandomness
   * @param randomness the VRF output
   */
  function fulfillRandomness(bytes32 requestId, uint256 randomness) internal virtual;

  /**
   * @dev In order to keep backwards compatibility we have kept the user
   * seed field around. We remove the use of it because given that the blockhash
   * enters later, it overrides whatever randomness the used seed provides.
   * Given that it adds no security, and can easily lead to misunderstandings,
   * we have removed it from usage and can now provide a simpler API.
   */
  uint256 private constant USER_SEED_PLACEHOLDER = 0;

  /**
   * @notice requestRandomness initiates a request for VRF output given _seed
   *
   * @dev The fulfillRandomness method receives the output, once it's provided
   * @dev by the Oracle, and verified by the vrfCoordinator.
   *
   * @dev The _keyHash must already be registered with the VRFCoordinator, and
   * @dev the _fee must exceed the fee specified during registration of the
   * @dev _keyHash.
   *
   * @dev The _seed parameter is vestigial, and is kept only for API
   * @dev compatibility with older versions. It can't *hurt* to mix in some of
   * @dev your own randomness, here, but it's not necessary because the VRF
   * @dev oracle will mix the hash of the block containing your request into the
   * @dev VRF seed it ultimately uses.
   *
   * @param _keyHash ID of public key against which randomness is generated
   * @param _fee The amount of LINK to send with the request
   *
   * @return requestId unique ID for this request
   *
   * @dev The returned requestId can be used to distinguish responses to
   * @dev concurrent requests. It is passed as the first argument to
   * @dev fulfillRandomness.
   */
  function requestRandomness(bytes32 _keyHash, uint256 _fee) internal returns (bytes32 requestId) {
    LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, USER_SEED_PLACEHOLDER));
    // This is the seed passed to VRFCoordinator. The oracle will mix this with
    // the hash of the block containing this request to obtain the seed/input
    // which is finally passed to the VRF cryptographic machinery.
    uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]);
    // nonces[_keyHash] must stay in sync with
    // VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
    // successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
    // This provides protection against the user repeating their input seed,
    // which would result in a predictable/duplicate output, if multiple such
    // requests appeared in the same block.
    nonces[_keyHash] = nonces[_keyHash] + 1;
    return makeRequestId(_keyHash, vRFSeed);
  }

  LinkTokenInterface internal immutable LINK;
  address private immutable vrfCoordinator;

  // Nonces for each VRF key from which randomness has been requested.
  //
  // Must stay in sync with VRFCoordinator[_keyHash][this]
  mapping(bytes32 => uint256) /* keyHash */ /* nonce */
    private nonces;

  /**
   * @param _vrfCoordinator address of VRFCoordinator contract
   * @param _link address of LINK token contract
   *
   * @dev https://docs.chain.link/docs/link-token-contracts
   */
  constructor(address _vrfCoordinator, address _link) {
    vrfCoordinator = _vrfCoordinator;
    LINK = LinkTokenInterface(_link);
  }

  // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
  // proof. rawFulfillRandomness then calls fulfillRandomness, after validating
  // the origin of the call
  function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external {
    require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill");
    fulfillRandomness(requestId, randomness);
  }
}

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

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

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

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

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

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

  function increaseApproval(address spender, uint256 subtractedValue) external;

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

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

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

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

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

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

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

contract VRFRequestIDBase {
  /**
   * @notice returns the seed which is actually input to the VRF coordinator
   *
   * @dev To prevent repetition of VRF output due to repetition of the
   * @dev user-supplied seed, that seed is combined in a hash with the
   * @dev user-specific nonce, and the address of the consuming contract. The
   * @dev risk of repetition is mostly mitigated by inclusion of a blockhash in
   * @dev the final seed, but the nonce does protect against repetition in
   * @dev requests which are included in a single block.
   *
   * @param _userSeed VRF seed input provided by user
   * @param _requester Address of the requesting contract
   * @param _nonce User-specific nonce at the time of the request
   */
  function makeVRFInputSeed(
    bytes32 _keyHash,
    uint256 _userSeed,
    address _requester,
    uint256 _nonce
  ) internal pure returns (uint256) {
    return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce)));
  }

  /**
   * @notice Returns the id for this request
   * @param _keyHash The serviceAgreement ID to be used for this request
   * @param _vRFInputSeed The seed to be passed directly to the VRF
   * @return The id for this request
   *
   * @dev Note that _vRFInputSeed is not the seed passed by the consuming
   * @dev contract, but the one generated by makeVRFInputSeed
   */
  function makeRequestId(bytes32 _keyHash, uint256 _vRFInputSeed) internal pure returns (bytes32) {
    return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed));
  }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"SaleIsNotEnabled","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"percentile","type":"uint256"}],"name":"AddedDistributionWallet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"email","type":"string"},{"indexed":false,"internalType":"address","name":"proxy","type":"address"}],"name":"MintedToProxy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"wallet","type":"address"}],"name":"MintedToWallet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"address","name":"token","type":"address"}],"name":"OrderPaidWithERC20Token","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"OrderPaidWithMatic","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"wallet","type":"address"}],"name":"PrizeMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"percentile","type":"uint256"}],"name":"RemovedDistributionWallet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"string","name":"email","type":"string"}],"name":"TransferFromProxyWallet","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROXY_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PrizeDrawer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"wallet","type":"address"},{"internalType":"uint256","name":"percentile","type":"uint256"}],"name":"addDistributionWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"distPercentile","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"distWallets","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"wallet","type":"address"}],"name":"mintPrizeWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"email","type":"string"},{"internalType":"bool","name":"prize","type":"bool"}],"name":"mintToProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"},{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"wallet","type":"address"},{"internalType":"bool","name":"prize","type":"bool"}],"name":"mintToWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"payOrderWithERC20Token","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"orderId","type":"uint256"}],"name":"payOrderWithMatic","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address payable","name":"wallet","type":"address"}],"name":"removeDistributionWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"drawer","type":"address"}],"name":"setPrizeDrawer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status","type":"bool"}],"name":"setSaleStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDistPercentile","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"}],"name":"transferFromProxy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"withdrawERC20Token","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawMatic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040526004805460ff191690553480156200001b57600080fd5b506200002960003362000087565b620000557f9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a63362000087565b620000817f795eb25cb2b1be6e10a101fd5278394bdeaa6cda3086183d0982b3254e030c1a3362000087565b62000137565b62000093828262000097565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000093576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620000f33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61316580620001476000396000f3fe608060405260043610620001a55760003560e01c8063a217fddf11620000e2578063c931f82c1162000095578063d547741f116200006c578063d547741f1462000519578063d897833e146200053e578063e20494071462000563578063ea7c335c146200058857600080fd5b8063c931f82c14620004ac578063d0fa05a614620004c3578063d539139314620004f457600080fd5b8063a217fddf14620003c6578063a934c0cd14620003dd578063b4483f4f1462000402578063c5df265d146200043d578063c69aa8791462000462578063c867835e146200048757600080fd5b8063446ba128116200015857806382f3a000116200012f57806382f3a0001462000321578063870a26e9146200035757806391d14854146200037c578063955322b914620003a157600080fd5b8063446ba12814620002c85780636aa633b614620002ed578063810074c6146200030957600080fd5b806301ffc9a714620001b5578063248a9ca314620001ef5780632f2ff15d146200023257806336568abe14620002595780633b2ec5ef146200027e5780633bdebbe114620002a357600080fd5b36620001b057600080fd5b600080fd5b348015620001c257600080fd5b50620001da620001d4366004620020a0565b620005a0565b60405190151581526020015b60405180910390f35b348015620001fc57600080fd5b50620002236200020e366004620020cc565b60009081526020819052604090206001015490565b604051908152602001620001e6565b3480156200023f57600080fd5b506200025762000251366004620020fc565b620005d8565b005b3480156200026657600080fd5b506200025762000278366004620020fc565b62000607565b3480156200028b57600080fd5b50620002576200029d3660046200212f565b6200068d565b348015620002b057600080fd5b5062000257620002c236600462002176565b62000853565b348015620002d557600080fd5b5062000257620002e73660046200222c565b620008d9565b348015620002fa57600080fd5b50600454620001da9060ff1681565b3480156200031657600080fd5b506200025762000b14565b3480156200032e57600080fd5b50620002237f795eb25cb2b1be6e10a101fd5278394bdeaa6cda3086183d0982b3254e030c1a81565b3480156200036457600080fd5b50620002576200037636600462002176565b62000b30565b3480156200038957600080fd5b50620001da6200039b366004620020fc565b62000c69565b348015620003ae57600080fd5b5062000257620003c0366004620022ef565b62000c92565b348015620003d357600080fd5b5062000223600081565b348015620003ea57600080fd5b5062000257620003fc3660046200231e565b62000e76565b3480156200040f57600080fd5b5060015462000424906001600160a01b031681565b6040516001600160a01b039091168152602001620001e6565b3480156200044a57600080fd5b50620004246200045c366004620020cc565b62000fce565b3480156200046f57600080fd5b50620002576200048136600462002365565b62000ff9565b3480156200049457600080fd5b5062000257620004a6366004620023cb565b620011fe565b62000257620004bd366004620020cc565b620013c1565b348015620004d057600080fd5b5062000223620004e236600462002176565b60036020526000908152604090205481565b3480156200050157600080fd5b50620002236000805160206200311083398151915281565b3480156200052657600080fd5b506200025762000538366004620020fc565b62001497565b3480156200054b57600080fd5b50620002576200055d36600462002406565b620014c1565b3480156200057057600080fd5b50620002576200058236600462002176565b62001527565b3480156200059557600080fd5b5062000223620015be565b60006001600160e01b03198216637965db0b60e01b1480620005d257506301ffc9a760e01b6001600160e01b03198316145b92915050565b600082815260208190526040902060010154620005f6813362001636565b620006028383620016a5565b505050565b6001600160a01b03811633146200067d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b6200068982826200172d565b5050565b6001546001600160a01b03163314620007005760405162461bcd60e51b815260206004820152602e60248201527f6f6e6c79207072697a652064726177657220736d61727420636f6e747261637460448201526d2063616e2063616c6c207468697360901b606482015260840162000674565b6001600160a01b038316620007295760405162461bcd60e51b8152600401620006749062002426565b600082116200074c5760405162461bcd60e51b815260040162000674906200245d565b6001600160a01b038116620007755760405162461bcd60e51b8152600401620006749062002494565b60005b828110156200084d576040516340d097c360e01b81526001600160a01b038381166004830152600091908616906340d097c3906024016020604051808303816000875af1158015620007ce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007f49190620024c9565b9050826001600160a01b031681866001600160a01b03167f81bf176970dc42476d2d60927727c18ea1c04449f842f09b98bb0248b76e3d5260405160405180910390a450806200084481620024f9565b91505062000778565b50505050565b600062000861813362001636565b6040516370a0823160e01b8152306004820152620006899083906001600160a01b038216906370a0823190602401602060405180830381865afa158015620008ad573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008d39190620024c9565b62001795565b60008051602062003110833981519152620008f5813362001636565b6001600160a01b0385166200091e5760405162461bcd60e51b8152600401620006749062002426565b60008411620009415760405162461bcd60e51b815260040162000674906200245d565b60008611620009645760405162461bcd60e51b8152600401620006749062002494565b600083604051620009759062002092565b62000981919062002572565b604051809103906000f0801580156200099e573d6000803e3d6000fd5b50905060005b8581101562000b0a576040516340d097c360e01b81526001600160a01b038381166004830152600091908916906340d097c3906024016020604051808303816000875af1158015620009fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000a209190620024c9565b9050841562000aad576001546040516390d8c03160e01b81526001600160a01b0385811660048301528a8116602483015260448201849052909116906390d8c031906064016020604051808303816000875af115801562000a85573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000aab9190620024c9565b505b80886001600160a01b03168a7fd0bcd5c579b2e11788916efa371a8e68748be9f67dc8a34fb568f37289c04a7f898760405162000aec92919062002587565b60405180910390a4508062000b0181620024f9565b915050620009a4565b5050505050505050565b600062000b22813362001636565b62000b2d4762001993565b50565b600062000b3e813362001636565b6001600160a01b03821660009081526003602052604090205462000ba55760405162461bcd60e51b815260206004820152601960248201527f77616c6c657420776173206e6f74207265676973746572656400000000000000604482015260640162000674565b60005b6002548110156200060257826001600160a01b03166002828154811062000bd35762000bd3620025b3565b6000918252602090912001546001600160a01b03160362000c54576001600160a01b0383166000818152600360205260408082205490519092917ff5c05f4ab2127ef443fcb9b3468c423b9fdceae9007647389fe43d960972741191a36001600160a01b038316600090815260036020526040812055620006028162001b26565b8062000c6081620024f9565b91505062000ba8565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600062000ca0813362001636565b6001600160a01b03831662000cf85760405162461bcd60e51b815260206004820152601b60248201527f7a65726f20616464726573732063616e6e6f7420626520757365640000000000604482015260640162000674565b6001600160a01b0383166000908152600360205260409020541562000d605760405162461bcd60e51b815260206004820152601d60248201527f77616c6c657420686164206265656e20616c726561647920757365642e000000604482015260640162000674565b60648262000d6d620015be565b62000d799190620025c9565b111562000def5760405162461bcd60e51b815260206004820152603860248201527f546f74616c2070657263656e74696c65206f6620646973747269627574696f6e60448201527f2073686f756c64206265206c657373207468616e203130300000000000000000606482015260840162000674565b60028054600181019091557f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace0180546001600160a01b0319166001600160a01b038516908117909155600081815260036020526040808220859055518492917f120072ef4148f13047a442182c69f0d7f0b1d006509b6415dfcfb3d5702ed2eb91a3505050565b7f795eb25cb2b1be6e10a101fd5278394bdeaa6cda3086183d0982b3254e030c1a62000ea3813362001636565b604051634b14e00360e01b81526001600160a01b0385811660048301528381166024830152841690634b14e00390604401600060405180830381600087803b15801562000eef57600080fd5b505af115801562000f04573d6000803e3d6000fd5b50505050826001600160a01b031663820e93f56040518163ffffffff1660e01b8152600401600060405180830381865afa15801562000f47573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405262000f719190810190620025e4565b60405162000f80919062002664565b6040518091039020826001600160a01b0316856001600160a01b03167f6db93f32fbe5ae283acaabf930d237fd829c90d497d048416a44c3ca9767b56860405160405180910390a450505050565b6002818154811062000fdf57600080fd5b6000918252602090912001546001600160a01b0316905081565b6000805160206200311083398151915262001015813362001636565b6001600160a01b0385166200103e5760405162461bcd60e51b8152600401620006749062002426565b60008411620010615760405162461bcd60e51b815260040162000674906200245d565b60008611620010845760405162461bcd60e51b8152600401620006749062002494565b60005b84811015620011f5576040516340d097c360e01b81526001600160a01b038581166004830152600091908816906340d097c3906024016020604051808303816000875af1158015620010dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620011039190620024c9565b9050831562001190576001546040516390d8c03160e01b81526001600160a01b038781166004830152898116602483015260448201849052909116906390d8c031906064016020604051808303816000875af115801562001168573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200118e9190620024c9565b505b846001600160a01b031681886001600160a01b03167f42633c8f1f8e2dc0cb106dd62f1444e8d5372cd4f95e10758ada235f5b0e9bc08b604051620011d791815260200190565b60405180910390a45080620011ec81620024f9565b91505062001087565b50505050505050565b60045460ff16620012455760405162461bcd60e51b815260206004820152601060248201526f14d85b19481a5cc8191a5cd8589b195960821b604482015260640162000674565b60008111620012975760405162461bcd60e51b815260206004820152601c60248201527f6e65656420746f20627579206174206c65617374203120746f6b656e00000000604482015260640162000674565b604051636eb1769f60e11b81523360048201523060248201526000906001600160a01b0384169063dd62ed3e90604401602060405180830381865afa158015620012e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200130b9190620024c9565b9050818110156200135f5760405162461bcd60e51b815260206004820152601d60248201527f746f6b656e20616c6c6f77616e6365206973206e6f7420656e6f756768000000604482015260640162000674565b6200136d8333308562001c0a565b62001379838362001795565b6040513381526001600160a01b03841690839086907f9a8c1db8ffe3227ea7216a92c0ff87897487ebeb0196d3af66911101eea198279060200160405180910390a450505050565b60045460ff16620014085760405162461bcd60e51b815260206004820152601060248201526f14d85b19481a5cc8191a5cd8589b195960821b604482015260640162000674565b600034116200145a5760405162461bcd60e51b815260206004820152601e60248201527f76616c75652073686f756c642062652067726561746572207468616e20300000604482015260640162000674565b620014653462001993565b6040513490339083907f89f994a6eea1e12aba326db72a17b827c78750d5cfede7b4c1f816018545eedf90600090a450565b600082815260208190526040902060010154620014b5813362001636565b6200060283836200172d565b60008051602062003110833981519152620014dd813362001636565b620014e7620015be565b60641480620014f4575081155b620015135760405162461bcd60e51b8152600401620006749062002682565b506004805460ff1916911515919091179055565b6000805160206200311083398151915262001543813362001636565b6001600160a01b0382166200159b5760405162461bcd60e51b815260206004820152601860248201527f7a65726f20616464726573732069732070726f76696465640000000000000000604482015260640162000674565b50600180546001600160a01b0319166001600160a01b0392909216919091179055565b600080805b60025481101562001630576003600060028381548110620015e857620015e8620025b3565b60009182526020808320909101546001600160a01b03168352820192909252604001902054620016199083620025c9565b9150806200162781620024f9565b915050620015c3565b50919050565b62001642828262000c69565b62000689576200165d816001600160a01b0316601462001d1e565b6200166a83602062001d1e565b6040516020016200167d929190620026d0565b60408051601f198184030181529082905262461bcd60e51b8252620006749160040162002572565b620016b1828262000c69565b62000689576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620016e93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b62001739828262000c69565b1562000689576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60008111620017f25760405162461bcd60e51b815260206004820152602260248201527f616d6f756e742073686f756c642062652067726561746572207468616e207a65604482015261726f60f01b606482015260840162000674565b6040516370a0823160e01b815230600482015281906001600160a01b038416906370a0823190602401602060405180830381865afa15801562001839573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200185f9190620024c9565b1015620018af5760405162461bcd60e51b815260206004820152601b60248201527f746f6b656e2062616c616e6365206973206e6f7420656e6f7567680000000000604482015260640162000674565b620018b9620015be565b606414620018db5760405162461bcd60e51b8152600401620006749062002682565b60005b6002548110156200060257600060646003600060028581548110620019075762001907620025b3565b60009182526020808320909101546001600160a01b0316835282019290925260400190205462001938908562002749565b6200194491906200276b565b90506200197d8460028481548110620019615762001961620025b3565b6000918252602090912001546001600160a01b03168362001edf565b50806200198a81620024f9565b915050620018de565b60008111620019f15760405162461bcd60e51b815260206004820152602360248201527f62616c616e63652073686f756c642062652067726561746572207468616e207a60448201526265726f60e81b606482015260840162000674565b8047101562001a435760405162461bcd60e51b815260206004820152601960248201527f4554482062616c616e6365206973206e6f7420656e6f75676800000000000000604482015260640162000674565b62001a4d620015be565b60641462001a6f5760405162461bcd60e51b8152600401620006749062002682565b60005b600254811015620006895760006064600360006002858154811062001a9b5762001a9b620025b3565b60009182526020808320909101546001600160a01b0316835282019290925260400190205462001acc908562002749565b62001ad891906200276b565b905062001b106002838154811062001af45762001af4620025b3565b6000918252602090912001546001600160a01b03168262001fe9565b508062001b1d81620024f9565b91505062001a72565b805b60025462001b39906001906200278e565b81101562001bd057600262001b50826001620025c9565b8154811062001b635762001b63620025b3565b600091825260209091200154600280546001600160a01b03909216918390811062001b925762001b92620025b3565b600091825260209091200180546001600160a01b0319166001600160a01b03929092169190911790558062001bc781620024f9565b91505062001b28565b50600280548062001be55762001be5620027a8565b600082815260209020810160001990810180546001600160a01b031916905501905550565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b179052915160009283929088169162001c70919062002664565b6000604051808303816000865af19150503d806000811462001caf576040519150601f19603f3d011682016040523d82523d6000602084013e62001cb4565b606091505b509150915081801562001ce257508051158062001ce257508080602001905181019062001ce29190620027be565b62001d165760405162461bcd60e51b815260206004820152600360248201526229aa2360e91b604482015260640162000674565b505050505050565b6060600062001d2f83600262002749565b62001d3c906002620025c9565b67ffffffffffffffff81111562001d575762001d5762002196565b6040519080825280601f01601f19166020018201604052801562001d82576020820181803683370190505b509050600360fc1b8160008151811062001da05762001da0620025b3565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811062001dd25762001dd2620025b3565b60200101906001600160f81b031916908160001a905350600062001df884600262002749565b62001e05906001620025c9565b90505b600181111562001e87576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811062001e3d5762001e3d620025b3565b1a60f81b82828151811062001e565762001e56620025b3565b60200101906001600160f81b031916908160001a90535060049490941c9362001e7f81620027de565b905062001e08565b50831562001ed85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640162000674565b9392505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b179052915160009283929087169162001f3d919062002664565b6000604051808303816000865af19150503d806000811462001f7c576040519150601f19603f3d011682016040523d82523d6000602084013e62001f81565b606091505b509150915081801562001faf57508051158062001faf57508080602001905181019062001faf9190620027be565b62001fe25760405162461bcd60e51b815260206004820152600260248201526114d560f21b604482015260640162000674565b5050505050565b604080516000808252602082019092526001600160a01b03841690839060405162002015919062002664565b60006040518083038185875af1925050503d806000811462002054576040519150601f19603f3d011682016040523d82523d6000602084013e62002059565b606091505b5050905080620006025760405162461bcd60e51b815260206004820152600360248201526253544560e81b604482015260640162000674565b61091780620027f983390190565b600060208284031215620020b357600080fd5b81356001600160e01b03198116811462001ed857600080fd5b600060208284031215620020df57600080fd5b5035919050565b6001600160a01b038116811462000b2d57600080fd5b600080604083850312156200211057600080fd5b8235915060208301356200212481620020e6565b809150509250929050565b6000806000606084860312156200214557600080fd5b83356200215281620020e6565b92506020840135915060408401356200216b81620020e6565b809150509250925092565b6000602082840312156200218957600080fd5b813562001ed881620020e6565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715620021d857620021d862002196565b604052919050565b600067ffffffffffffffff821115620021fd57620021fd62002196565b50601f01601f191660200190565b801515811462000b2d57600080fd5b803562002227816200220b565b919050565b600080600080600060a086880312156200224557600080fd5b8535945060208601356200225981620020e6565b935060408601359250606086013567ffffffffffffffff8111156200227d57600080fd5b8601601f810188136200228f57600080fd5b8035620022a6620022a082620021e0565b620021ac565b818152896020838501011115620022bc57600080fd5b81602084016020830137600060208383010152809450505050620022e3608087016200221a565b90509295509295909350565b600080604083850312156200230357600080fd5b82356200231081620020e6565b946020939093013593505050565b6000806000606084860312156200233457600080fd5b83356200234181620020e6565b925060208401356200235381620020e6565b915060408401356200216b81620020e6565b600080600080600060a086880312156200237e57600080fd5b8535945060208601356200239281620020e6565b9350604086013592506060860135620023ab81620020e6565b91506080860135620023bd816200220b565b809150509295509295909350565b600080600060608486031215620023e157600080fd5b833592506020840135620023f581620020e6565b929592945050506040919091013590565b6000602082840312156200241957600080fd5b813562001ed8816200220b565b6020808252601b908201527f5a65726f20616464726573732063616e6e6f7420626520757365640000000000604082015260600190565b6020808252601f908201527f616d6f756e742073686f756c642062652067726561746572207468616e203000604082015260600190565b6020808252818101527f6f7264657249642073686f756c642062652067726561746572207468616e2030604082015260600190565b600060208284031215620024dc57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000600182016200250e576200250e620024e3565b5060010190565b60005b838110156200253257818101518382015260200162002518565b838111156200084d5750506000910152565b600081518084526200255e81602086016020860162002515565b601f01601f19169290920160200192915050565b60208152600062001ed8602083018462002544565b6040815260006200259c604083018562002544565b905060018060a01b03831660208301529392505050565b634e487b7160e01b600052603260045260246000fd5b60008219821115620025df57620025df620024e3565b500190565b600060208284031215620025f757600080fd5b815167ffffffffffffffff8111156200260f57600080fd5b8201601f810184136200262157600080fd5b805162002632620022a082620021e0565b8181528560208385010111156200264857600080fd5b6200265b82602083016020860162002515565b95945050505050565b600082516200267881846020870162002515565b9190910192915050565b6020808252602e908201527f546f74616c2070657263656e74696c65206f6620646973747269627574696f6e60408201526d02073686f756c64206265203130360941b606082015260800190565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516200270a81601785016020880162002515565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516200273d81602884016020880162002515565b01602801949350505050565b6000816000190483118215151615620027665762002766620024e3565b500290565b6000826200278957634e487b7160e01b600052601260045260246000fd5b500490565b600082821015620027a357620027a3620024e3565b500390565b634e487b7160e01b600052603160045260246000fd5b600060208284031215620027d157600080fd5b815162001ed8816200220b565b600081620027f057620027f0620024e3565b50600019019056fe608060405234801561001057600080fd5b5060405161091738038061091783398101604081905261002f9161010a565b600080546001600160a01b03191633179055805161005490600190602084019061005b565b5050610213565b828054610067906101d9565b90600052602060002090601f01602090048101928261008957600085556100cf565b82601f106100a257805160ff19168380011785556100cf565b828001600101855582156100cf579182015b828111156100cf5782518255916020019190600101906100b4565b506100db9291506100df565b5090565b5b808211156100db57600081556001016100e0565b634e487b7160e01b600052604160045260246000fd5b6000602080838503121561011d57600080fd5b82516001600160401b038082111561013457600080fd5b818501915085601f83011261014857600080fd5b81518181111561015a5761015a6100f4565b604051601f8201601f19908116603f01168101908382118183101715610182576101826100f4565b81604052828152888684870101111561019a57600080fd5b600093505b828410156101bc578484018601518185018701529285019261019f565b828411156101cd5760008684830101525b98975050505050505050565b600181811c908216806101ed57607f821691505b60208210810361020d57634e487b7160e01b600052602260045260246000fd5b50919050565b6106f5806102226000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c8063150b7a02146100515780634b14e00314610082578063820e93f5146100975780639c1e03a0146100ac575b600080fd5b61006461005f366004610522565b6100d7565b6040516001600160e01b031990911681526020015b60405180910390f35b6100956100903660046105bd565b61015e565b005b61009f610478565b60405161007991906105f0565b6000546100bf906001600160a01b031681565b6040516001600160a01b039091168152602001610079565b600080546001600160a01b0387811691161461014c5760405162461bcd60e51b815260206004820152602960248201527f4f6e6c792061636365707420436172626f6e204372656174757265204e46542060448201526843726f776473616c6560b81b60648201526084015b60405180910390fd5b50630a85bd0160e11b95945050505050565b6000546001600160a01b031633146101d45760405162461bcd60e51b815260206004820152603360248201527f4f6e6c7920436172626f6e2043726561747572652043726f776473616c6520636044820152726f6e74726163742063616e206578656375746560681b6064820152608401610143565b6001600160a01b03821661023d5760405162461bcd60e51b815260206004820152602a60248201527f7a65726f20616464726573732063616e6e6f74206265207573656420666f722060448201526931b7b63632b1ba34b7b760b11b6064820152608401610143565b6001600160a01b0381166102a55760405162461bcd60e51b815260206004820152602960248201527f7a65726f20616464726573732063616e6e6f74206265207573656420666f72206044820152681c9958d95c1a595b9d60ba1b6064820152608401610143565b60005460405163a22cb46560e01b81526001600160a01b039182166004820152600160248201529083169063a22cb46590604401600060405180830381600087803b1580156102f357600080fd5b505af1158015610307573d6000803e3d6000fd5b5050505060005b6040516370a0823160e01b81523060048201526001600160a01b038416906370a0823190602401602060405180830381865afa158015610352573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103769190610645565b81101561047357604051632f745c5960e01b81523060048201819052602482018390526001600160a01b038516916342842e0e919085908490632f745c5990604401602060405180830381865afa1580156103d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103f99190610645565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561044857600080fd5b505af115801561045c573d6000803e3d6000fd5b50505050808061046b9061065e565b91505061030e565b505050565b6001805461048590610685565b80601f01602080910402602001604051908101604052809291908181526020018280546104b190610685565b80156104fe5780601f106104d3576101008083540402835291602001916104fe565b820191906000526020600020905b8154815290600101906020018083116104e157829003601f168201915b505050505081565b80356001600160a01b038116811461051d57600080fd5b919050565b60008060008060006080868803121561053a57600080fd5b61054386610506565b945061055160208701610506565b935060408601359250606086013567ffffffffffffffff8082111561057557600080fd5b818801915088601f83011261058957600080fd5b81358181111561059857600080fd5b8960208285010111156105aa57600080fd5b9699959850939650602001949392505050565b600080604083850312156105d057600080fd5b6105d983610506565b91506105e760208401610506565b90509250929050565b600060208083528351808285015260005b8181101561061d57858101830151858201604001528201610601565b8181111561062f576000604083870101525b50601f01601f1916929092016040019392505050565b60006020828403121561065757600080fd5b5051919050565b60006001820161067e57634e487b7160e01b600052601160045260246000fd5b5060010190565b600181811c9082168061069957607f821691505b6020821081036106b957634e487b7160e01b600052602260045260246000fd5b5091905056fea2646970667358221220eeadccfea7054d8d210356c7b5fe4d519b0894ab7158dc549193ad0d7ab6b70264736f6c634300080d00339f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6a264697066735822122027785c16122cfbf26931fd901e868c898c5fea7ef640ddd681335fe0df26477264736f6c634300080d0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.