Contract 0x785B0CEb43d35ff40e24Ef863a0C7d400a96e3A2 2

 

Contract Overview

MurAll: FRAMES Token
Balance:
0.378 Ether

EtherValue:
$673.07 (@ $1,780.60/ETH)

Token:
 
Txn Hash
Method
Block
From
To
Value
0x4c4a3a55bc26f35a31fc4cee9e423bb0517f548cd2457965dbd2e39fc10bbd32Set Approval For...152626852022-08-02 10:57:466 days 20 hrs ago0x37fb0006b93a43ea51c8e5a0210fc5c7cc99b202 IN  MurAll: FRAMES Token0 Ether0.00057548 12.4677842
0x3c35e49e29acb85de053b75c30322a9bf6f751e47f05d41bd4c377f5c1a109cdTransfer From152556822022-08-01 8:55:437 days 22 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.0019621 17.90211057
0x8964f80dc9f20c8f0719abf3eed2edd7afe06a5537308c89a13c81f78252a38eTransfer From152556792022-08-01 8:55:277 days 22 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00218215 19.07244965
0x2a8965ba7fe9910ca7bf9ac70d2c6b8d5835d048cbffc2f2106592ab38772cefTransfer From152556772022-08-01 8:54:307 days 22 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.0023485 18.90872836
0x76dfbeefe4bc3689e15bed63146452ac036119cb619f3b9548de4e33ef2a2658Transfer From152556772022-08-01 8:54:307 days 22 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.0023485 18.90872836
0x67c20c48d19bc213e6dac7d278dfa88fbcba630c8d28a031accf49fcbdd76ba8Transfer From152556742022-08-01 8:53:527 days 22 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00179002 15.6451569
0x9d51c993c2e70f15aae895a5f09eb51c0be666cd87409401e22e5fc4e1620fb5Transfer From152556732022-08-01 8:53:337 days 22 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00176179 14.18495065
0xb85aeafb32dd596109f299a9316e34e0adf25933fae16b9fe9fc61f97855771dTransfer From152122812022-07-25 14:40:1514 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00223563 18
0x9863ddb7c7b49fb070c5e5aa2398d60a9e9794f099f66c99c8b87d85a9f3b024Transfer From152122792022-07-25 14:39:3114 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00223585 18
0x71ed2865fbed0933fcd88c443bca4fc07af5fc87bba23cb1204ce4f1455f91e8Transfer From152122772022-07-25 14:39:2414 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00223563 18
0x42912610005c92ea58dd535351fb2a6d95b8ef614023fb5b175497a9276b3c0fTransfer From152122672022-07-25 14:38:0514 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00223563 18
0x44b521f897972fa3bb4127331667c58095b03e13667ef3692bc9bb3e0f2e2407Transfer From152122582022-07-25 14:37:0414 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00223585 18
0xc88b0e575182da822d470b03008b2dbe2a0d782c7617088426253442f9c340c1Transfer From152122562022-07-25 14:36:1814 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00223563 18
0xfc064acd39e18ff49c779b0999bd7694f37ec9923f1b2ef31ca65682806541e3Transfer From152122282022-07-25 14:32:0514 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00260824 21
0x47927b1dfaa5c02cbbf75ae918894308df01378ee7033acb46f7821be62079c4Transfer From152122232022-07-25 14:30:4214 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00260849 21
0xd7f4954b61a6089c2fa91bc26734384496ac36a4a1ccb9644a2cc7dbce5ee5f7Transfer From152122202022-07-25 14:30:0014 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00260824 21
0xff43f71a9d51f9d1252eef4a9e2ff18b4603a0fef841c6f2902ab8b613df52ffTransfer From152122162022-07-25 14:29:4114 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00260849 21
0xc4c6cbee85fc556cf4e9ed14e1c432be947ec7a759eb9388eb8304cf026c086aTransfer From152122052022-07-25 14:27:0814 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00260824 21
0x85945537c88549fd28d58b868320a355531e21741d0eb989d6d4e66fcb640e69Transfer From152122042022-07-25 14:27:0614 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00260824 21
0x42933ed215023ada51fbc389d020fef1f16e18a6b9b3e7afaaf7e167417e526eTransfer From152122022022-07-25 14:26:2714 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00260824 21
0x921d4ef8de86e27844e7f308b4a7261e309cb2a0c2533900a65c2a2adefd0f26Transfer From152121812022-07-25 14:21:5214 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00335377 27
0xb724bce354f0e506115096e4596be199ef2da2dbe31b5536ef2f4e5259eca9bfTransfer From152121792022-07-25 14:21:3114 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00335377 27
0xb78beed3c8f30b3ac1414f53b267e9329acdf49349a1b683ce68eaa6e7314541Transfer From152121692022-07-25 14:19:3414 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00335345 27
0x0ac83693579694f20949380f1f107314ea20879e05d6b6e2d48dd8af6b69ae54Transfer From152121672022-07-25 14:19:0714 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00335345 27
0xdeef29dcf4ca6f75c6b41d9522e8275a4d82ae8ef84fe55b6d2c42455c8d6cccTransfer From152121662022-07-25 14:18:5614 days 17 hrs ago0x79f70d99cd54240fe9032ef8b4e3ada95ebba018 IN  MurAll: FRAMES Token0 Ether0.00335345 27
[ Download CSV Export 

OVERVIEW

A collection of 4,444 revolutionary NFTs allowing collectors to mount their existing NFT artwork in a decorative, rare and highly collectible frame.

Latest 3 internal transactions
Parent Txn Hash Block From To Value
0xae610ae72e435fdafecec7b83e44051090e28abb00c6af4e750136513523c926140433752022-01-20 15:57:10200 days 15 hrs ago MurAll: FRAMES TokenMurAll: Deployer0.648 Ether
0x38fa3a8b23317a8e2028204981ecbede35b6abd0ebf91c4a43225605c02e234c138420632021-12-20 12:40:02231 days 19 hrs ago MurAll: FRAMES TokenMurAll: Deployer1.152 Ether
0x3e80f72198212e2edac92c6bae2e203e9ab374b59148a66ee1cc474a6c1d91c4137170832021-11-30 21:05:45251 days 10 hrs ago MurAll: FRAMES TokenMurAll: Deployer4.32 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MurAllFrame

Compiler Version
v0.6.11+commit.5ef660b1

Optimization Enabled:
Yes with 21000 runs

Other Settings:
constantinople EvmVersion
File 1 of 32 : MurAllFrame.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/introspection/ERC165Checker.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/ERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IFrameTraitManager} from "./IFrameTraitManager.sol";
import {IERC2981} from "../royalties/IERC2981.sol";
import {IRoyaltyGovernor} from "../royalties/IRoyaltyGovernor.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";
import {MintManager} from "../distribution/MintManager.sol";
import {TraitSeedManager} from "./TraitSeedManager.sol";

/**
 * MurAll Frame contract
 */
contract MurAllFrame is AccessControl, ReentrancyGuard, IERC2981, IERC721Receiver, ERC1155Receiver, ERC721 {
    bytes32 private constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    bytes32 private constant TRAIT_MOD_ROLE = keccak256("TRAIT_MOD_ROLE");

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

    /*
     *     bytes4(keccak256('balanceOf(address,uint256)')) == 0x00fdd58e
     *     bytes4(keccak256('balanceOfBatch(address[],uint256[])')) == 0x4e1273f4
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,uint256,bytes)')) == 0xf242432a
     *     bytes4(keccak256('safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)')) == 0x2eb2c2d6
     *
     *     => 0x00fdd58e ^ 0x4e1273f4 ^ 0xa22cb465 ^
     *        0xe985e9c5 ^ 0xf242432a ^ 0x2eb2c2d6 == 0xd9b67a26
     */
    bytes4 private constant _INTERFACE_ID_ERC1155 = 0xd9b67a26;

    uint64 public immutable MAX_SUPPLY = 4444;

    IFrameTraitManager public frameTraitManager;
    MintManager public mintManager;
    IRoyaltyGovernor public royaltyGovernorContract;
    TraitSeedManager public traitSeedManager;
    string public contractURI;

    mapping(uint256 => uint256) private customFrameTraits;

    struct FrameContents {
        address contractAddress;
        uint256 tokenId;
        uint256 amount;
        bool bound;
    }

    mapping(uint256 => FrameContents) public frameContents;

    event RandomnessRequested(bytes32 requestId);
    event TraitSeedSet(uint256 seed);

    /** @dev Checks if token exists
     * @param _tokenId The token id to check if exists
     */
    modifier onlyExistingTokens(uint256 _tokenId) {
        require(_exists(_tokenId), "Invalid Token ID");
        _;
    }

    /** @dev Checks if sender address has admin role
     */
    modifier onlyAdmin() {
        require(hasRole(ADMIN_ROLE, msg.sender), "Does not have admin role");
        _;
    }
    
    /** @dev Checks if sender address has admin role
     */
    modifier onlyTraitMod() {
        require(hasRole(TRAIT_MOD_ROLE, msg.sender), "Does not have trait mod role");
        _;
    }

    event FrameContentsUpdated(
        uint256 indexed id,
        address indexed contentsContract,
        uint256 contentsId,
        uint256 amount,
        bool bound
    );
    event FrameContentsRemoved(uint256 indexed id);
    event RoyaltyGovernorContractChanged(address indexed royaltyGovernor);
    event FrameTraitManagerChanged(address indexed frameTraitManager);
    event FrameMinted(uint256 indexed id, address indexed owner);

    constructor(
        address[] memory admins,
        MintManager _mintManager,
        TraitSeedManager _traitSeedManager
    ) public ERC721("Frames by MurAll", "FRAMES") {
        for (uint256 i = 0; i < admins.length; ++i) {
            _setupRole(ADMIN_ROLE, admins[i]);
        }

        for (uint256 i = 0; i < admins.length; ++i) {
            _setupRole(TRAIT_MOD_ROLE, admins[i]);
        }
        // traitSeedManager = new TraitSeedManager(admins, _vrfCoordinator, _linkTokenAddr, _keyHash, _fee, 435, 252);
        traitSeedManager = _traitSeedManager;

        // mintManager = new MintManager(this, admins, 436, 1004, 0.144 ether, 0.244 ether);
        mintManager = _mintManager;
        _registerInterface(IERC721Receiver(0).onERC721Received.selector);
    }

    function setCustomTraits(uint256[] memory traitHash, uint256[] memory indexes) public onlyTraitMod {
        require(traitHash.length == indexes.length, "Trait hash and indexes length mismatch");

        for (uint256 i = 0; i < traitHash.length; ++i) {
            require(indexes[i] < mintManager.NUM_INITIAL_MINTABLE(), "Cannot change trait hash for index");
            require(customFrameTraits[indexes[i]] == 0, "Cannot change trait hash for index");
            customFrameTraits[indexes[i]] = traitHash[i];
        }
    }

    /**
     * @notice Set the base URI for creating `tokenURI` for each NFT.
     * Only invokable by admin role.
     * @param _tokenUriBase base for the ERC721 tokenURI
     */
    function setTokenUriBase(string calldata _tokenUriBase) external onlyAdmin {
        // Set the base for metadata tokenURI
        _setBaseURI(_tokenUriBase);
    }

    /**
     * @notice Set the contract URI for marketplace data.
     * Only invokable by admin role.
     * @param _contractURI contract uri for this contract
     */
    function setContractUri(string calldata _contractURI) external onlyAdmin {
        // Set the base for metadata tokenURI
        contractURI = _contractURI;
    }

    /**
     * @notice Set the frame trait manager contract.
     * Only invokable by admin role.
     * @param managerAddress the address of the frame trait image storage contract
     */
    function setFrameTraitManager(IFrameTraitManager managerAddress) public onlyAdmin {
        frameTraitManager = IFrameTraitManager(managerAddress);
        emit FrameTraitManagerChanged(address(managerAddress));
    }

    /**
     * @notice Set the Royalty Governer for creating `tokenURI` for each Montage NFT.
     * Only invokable by admin role.
     * @param _royaltyGovAddr the address of the Royalty Governer contract
     */
    function setRoyaltyGovernor(IRoyaltyGovernor _royaltyGovAddr) external onlyAdmin {
        royaltyGovernorContract = _royaltyGovAddr;
        emit RoyaltyGovernorContractChanged(address(_royaltyGovAddr));
    }

    function getTraits(uint256 _tokenId) public view onlyExistingTokens(_tokenId) returns (uint256 traits) {
        if (customFrameTraits[_tokenId] != 0) {
            return customFrameTraits[_tokenId];
        } else {
            uint256 traitSeed = traitSeedManager.getTraitSeed(_tokenId);
            return uint256(keccak256(abi.encode(traitSeed, _tokenId)));
        }
    }

    function setFrameContents(
        uint256 _tokenId,
        address contentContractAddress,
        uint256 contentTokenId,
        uint256 contentAmount,
        bool bindContentToFrame
    ) public nonReentrant {
        require(ownerOf(_tokenId) == msg.sender, "Not token owner"); // this will also fail if the token does not exist
        if (bindContentToFrame) {
            require(!frameContents[_tokenId].bound, "Frame already contains bound content");
            if (contentContractAddress.supportsInterface(_INTERFACE_ID_ERC721)) {
                // transfer ownership of the token to this contract (will fail if contract is not approved prior to this)
                IERC721(contentContractAddress).safeTransferFrom(msg.sender, address(this), contentTokenId, "");
            } else if (contentContractAddress.supportsInterface(_INTERFACE_ID_ERC1155)) {
                // transfer ownership of the token to this contract (will fail if contract is not approved prior to this)
                IERC1155(contentContractAddress).safeTransferFrom(
                    msg.sender,
                    address(this),
                    contentTokenId,
                    contentAmount,
                    ""
                );
            } else revert();
        } else {
            if (contentContractAddress.supportsInterface(_INTERFACE_ID_ERC721)) {
                require(IERC721(contentContractAddress).ownerOf(contentTokenId) == msg.sender, "Not token owner");
            } else if (contentContractAddress.supportsInterface(_INTERFACE_ID_ERC1155)) {
                require(
                    IERC1155(contentContractAddress).balanceOf(msg.sender, contentTokenId) >= contentAmount,
                    "Not enough tokens"
                );
            } else {
                revert();
            }
        }
        createFrameContents(_tokenId, contentContractAddress, contentTokenId, contentAmount, bindContentToFrame);
    }

    function removeFrameContents(uint256 _tokenId) public nonReentrant {
        require(ownerOf(_tokenId) == msg.sender, "Not token owner"); // this will also fail if the token does not exist
        require(hasContentsInFrame(_tokenId), "Frame does not contain any content"); // Also checks token exists
        FrameContents memory _frameContents = frameContents[_tokenId];
        if (_frameContents.bound) {
            if (_frameContents.contractAddress.supportsInterface(_INTERFACE_ID_ERC721)) {
                // transfer ownership of the token to this contract (will fail if contract is not approved prior to this)
                IERC721(_frameContents.contractAddress).safeTransferFrom(
                    address(this),
                    msg.sender,
                    _frameContents.tokenId
                );
            } else {
                // transfer ownership of the token to this contract (will fail if contract is not approved prior to this)
                IERC1155(_frameContents.contractAddress).safeTransferFrom(
                    address(this),
                    msg.sender,
                    _frameContents.tokenId,
                    _frameContents.amount,
                    ""
                );
            }
        }

        delete frameContents[_tokenId];
        emit FrameContentsRemoved(_tokenId);
    }

    function hasContentsInFrame(uint256 _tokenId) public view onlyExistingTokens(_tokenId) returns (bool) {
        return frameContents[_tokenId].contractAddress != address(0);
    }

    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes memory data
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }

    function onERC1155Received(
        address operator,
        address from,
        uint256 tokenId,
        uint256 amount,
        bytes memory data
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        revert();
    }

    function royaltyInfo(
        uint256 _tokenId,
        uint256 _value,
        bytes calldata _data
    )
        external
        override
        returns (
            address _receiver,
            uint256 _royaltyAmount,
            bytes memory _royaltyPaymentData
        )
    {
        return royaltyGovernorContract.royaltyInfo(_tokenId, _value, _data);
    }

    function createFrameContents(
        uint256 _tokenId,
        address contentContractAddress,
        uint256 contentTokenId,
        uint256 contentAmount,
        bool bindContentToFrame
    ) private onlyExistingTokens(_tokenId) {
        FrameContents memory newFrameContents = FrameContents(
            contentContractAddress,
            contentTokenId,
            contentAmount,
            bindContentToFrame
        );
        frameContents[_tokenId] = newFrameContents;

        emit FrameContentsUpdated(_tokenId, contentContractAddress, contentTokenId, contentAmount, bindContentToFrame);
    }

    function mint(uint256 amount) public payable nonReentrant {
        mintManager.checkCanMintPublic(msg.sender, msg.value, amount);
        uint256 maxId = traitSeedManager.getMaxIdForCurrentPhase();
        for (uint256 i = 0; i < amount; ++i) {
            mintInternal(msg.sender, maxId);
        }
    }

    function mintPresale(
        uint256 index,
        uint256 maxAmount,
        bytes32[] calldata merkleProof,
        uint256 amountDesired
    ) public payable nonReentrant {
        mintManager.checkCanMintPresale(msg.sender, msg.value, index, maxAmount, merkleProof, amountDesired);
        uint256 maxId = traitSeedManager.getMaxIdForCurrentPhase();
        uint256 amountToMint = maxAmount < amountDesired ? maxAmount : amountDesired;
        for (uint256 i = 0; i < amountToMint; ++i) {
            mintInternal(msg.sender, maxId);
        }
    }

    function mintInitial(uint256 amountToMint) public nonReentrant onlyAdmin returns (uint256) {
        mintManager.checkCanMintInitial(amountToMint);
        uint256 maxId = traitSeedManager.getMaxIdForCurrentPhase();
        for (uint256 i = 0; i < amountToMint; ++i) {
            mintInternal(msg.sender, maxId);
        }
    }

    function mintInternal(address account, uint256 maxId) private {
        require(totalSupply() <= MAX_SUPPLY, "Maximum number of NFTs minted");

        // mint a new frame
        uint256 _id = totalSupply();
        require(_id <= maxId, "Maximum number of NFTs for phase minted");
        _mint(account, _id);
        emit FrameMinted(_id, account);
    }

    function withdrawFunds(address payable _to) public onlyAdmin {
        (bool success, ) = _to.call{value: address(this).balance}("");
        require(success, "Failed to transfer the funds, aborting.");
    }

    function rescueTokens(address tokenAddress) public onlyAdmin {
        uint256 balance = IERC20(tokenAddress).balanceOf(address(this));
        require(IERC20(tokenAddress).transfer(msg.sender, balance), "rescueTokens: Transfer failed.");
    }

    fallback() external payable {}

    receive() external payable {}
}

File 2 of 32 : IRoyaltyGovernor.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.0;
import {IERC2981} from "./IERC2981.sol";

interface IRoyaltyGovernor is IERC2981 {
    function setRoyaltyPercentage(uint256 _royaltyPercentage) external;
}

File 3 of 32 : IERC2981.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/introspection/IERC165.sol";

///
/// @dev Interface for the NFT Royalty Standard
///
interface IERC2981 is IERC165 {
    /// ERC165 bytes to add to interface array - set in parent contract
    /// implementing this standard
    ///
    /// bytes4(keccak256("royaltyInfo(uint256,uint256,bytes)")) == 0xc155531d
    /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0xc155531d;
    /// _registerInterface(_INTERFACE_ID_ERC2981);

    /// @notice Called with the sale price to determine how much royalty
    //          is owed and to whom.
    /// @param _tokenId - the NFT asset queried for royalty information
    /// @param _value - the sale price of the NFT asset specified by _tokenId
    /// @param _data - information used by extensions of this ERC.
    ///                Must not to be used by implementers of EIP-2981
    ///                alone.
    /// @return _receiver - address of who should be sent the royalty payment
    /// @return _royaltyAmount - the royalty payment amount for _value sale price
    /// @return _royaltyPaymentData - information used by extensions of this ERC.
    ///                               Must not to be used by implementers of
    ///                               EIP-2981 alone.
    function royaltyInfo(
        uint256 _tokenId,
        uint256 _value,
        bytes calldata _data
    )
        external
        returns (
            address _receiver,
            uint256 _royaltyAmount,
            bytes memory _royaltyPaymentData
        );
}

File 4 of 32 : TraitSeedManager.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

/**
 * MurAll Frame contract
 */
contract TraitSeedManager is AccessControl, ReentrancyGuard, VRFConsumerBase {
    bytes32 private constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    uint256 public rangeSize;
    uint256 public rangeStart;
    uint256 public phase;
    using Strings for uint256;

    uint256[] public traitSeeds;

    // for chainlink vrf
    bytes32 internal keyHash;
    uint256 internal fee;

    event RandomnessRequested(bytes32 requestId);
    event TraitSeedSet(uint256 seed);

    /** @dev Checks if sender address has admin role
     */
    modifier onlyAdmin() {
        require(hasRole(ADMIN_ROLE, msg.sender), "Does not have admin role");
        _;
    }

    constructor(
        address[] memory admins,
        address _vrfCoordinator,
        address _linkTokenAddr,
        bytes32 _keyHash,
        uint256 _fee,
        uint256 _rangeSize,
        uint256 _rangeStart
    ) public VRFConsumerBase(_vrfCoordinator, _linkTokenAddr) {
        for (uint256 i = 0; i < admins.length; ++i) {
            _setupRole(ADMIN_ROLE, admins[i]);
        }
        keyHash = _keyHash;
        fee = _fee;
        rangeSize = _rangeSize;
        rangeStart = _rangeStart;
    }

    function setPhase(uint256 _phase) public onlyAdmin {
        require(_phase <= traitSeeds.length + 1, "Phase is out of range");

        phase = _phase;
    }

    function getMaxIdForCurrentPhase() public view returns (uint256) {
        return rangeStart + phase * rangeSize;
    }

    function addTraitSeedForRange(uint256 amountOfSeeds) public onlyAdmin {
        require(traitSeeds.length > 0 && traitSeeds[0] != 0, "Must have at least 1 trait seed");

        for (uint256 i = 0; i < amountOfSeeds; ++i) {
            uint256 newSeed = uint256(keccak256(abi.encode(traitSeeds[traitSeeds.length - 1], block.timestamp)));

            traitSeeds.push(newSeed);
            emit TraitSeedSet(newSeed);
        }
    }

    function getTraitSeedsLength() public view returns (uint256) {
        return traitSeeds.length;
    }

    function getTraitSeed(uint256 _tokenId) public view returns (uint256 traitSeed) {
        require(traitSeeds.length > 0 && traitSeeds[0] != 0, "Must have at least 1 trait seed");
        if (_tokenId <= rangeStart) {
            traitSeed = traitSeeds[0];
        } else {
            require(_tokenId <= rangeStart + traitSeeds.length * rangeSize, "Trait seed not set for token id");
            traitSeed = traitSeeds[(_tokenId - rangeStart - 1) / rangeSize];
        }
    }

    /** Chainlink VRF ****************************/
    function requestTraitSeed() public onlyAdmin nonReentrant {
        // require(traitSeeds[0] == 0, "Trait seed already requested");
        require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK - fill contract with faucet");
        bytes32 requestId = requestRandomness(keyHash, fee);

        emit RandomnessRequested(requestId);
    }

    /**
     * Callback function used by VRF Coordinator
     */
    function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override {
        traitSeeds.push(randomness);
        emit TraitSeedSet(randomness);
    }

    /** END Chainlink VRF ****************************/

    function withdrawFunds(address payable _to) public onlyAdmin {
        (bool success, ) = _to.call{value: address(this).balance}("");
        require(success, "Failed to transfer the funds, aborting.");
    }

    function rescueTokens(address tokenAddress) public onlyAdmin {
        uint256 balance = IERC20(tokenAddress).balanceOf(address(this));
        require(IERC20(tokenAddress).transfer(msg.sender, balance), "rescueTokens: Transfer failed.");
    }

    fallback() external payable {}

    receive() external payable {}
}

File 5 of 32 : IFrameTraitManager.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.0;

interface IFrameTraitManager {
    /**
    frame style 
    frame colour 
    accent 
    frame corner variation
    frame condition (cracked, weathered, scratched, pristine, shimmering, pixelate)
    frame effect (electrified, fiery, watery/wet, abandoned/plant life growing-vines,) 
    barcode/wave/generated thing from hash (1/1)
    top decorations (e.g. cat, gun, spray can etc)
    top variation (e.g. cat glowing eyes, laser eyes legendary, weighted so legendary harder to get)
    top colour (if not legendary, if legendary, pick from range instead)
    top offset (percent within range from 30% to 70%)
    x 4 (bottom, left, right)
     */
    /**
     Get the frame style
     Choice of: Denim, kintsugi, cyberpunk, 
     */

    enum TraitParameter {
        STYLE,
        MAIN_COLOUR,
        ACCENT_COLOUR,
        ACCENT_SECONDARY_COLOR,
        CORNER,
        CONDITION,
        RIMS,
        TOP_DAMAGE,
        TOP_VARIATION,
        TOP_OFFSET,
        BOTTOM_DAMAGE,
        BOTTOM_VARIATION,
        BOTTOM_OFFSET,
        LEFT_DAMAGE,
        LEFT_VARIATION,
        LEFT_OFFSET,
        RIGHT_DAMAGE,
        RIGHT_VARIATION,
        RIGHT_OFFSET,
        SIGNATURE
    }

    function getTrait(TraitParameter traitParameter, uint256 traitHash) external view returns (uint256);
}

File 6 of 32 : MintManager.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.0;

import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import {MerkleTokenClaimDataManager} from "../distribution/MerkleTokenClaimDataManager.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract MintManager is AccessControl, ReentrancyGuard {
    bytes32 private constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    uint64 public constant MAX_MINTABLE_PER_TX = 4;
    uint64 public constant MAX_MINTABLE_PUBLIC = 40;
    uint64 public immutable NUM_INITIAL_MINTABLE;
    uint64 public immutable NUM_PRESALE_MINTABLE;

    uint256 public mintPricePresale;
    uint256 public mintPricePublic;

    enum MINTMODE {DEVELOPMENT, PRESALE, PUBLIC}
    MINTMODE public mintMode = MINTMODE.DEVELOPMENT;

    MerkleTokenClaimDataManager public presaleManager;

    event PresaleMerkleRootSet(bytes32 merkleRoot);

    ERC721 public token;

    /** @dev Checks if sender address has admin role
     */
    modifier onlyAdmin() {
        require(hasRole(ADMIN_ROLE, msg.sender), "Does not have admin role");
        _;
    }

    constructor(
        address[] memory admins,
        uint64 _numInitialMintable,
        uint64 _numPresaleMintable,
        uint256 _presaleMintPrice,
        uint256 _publicMintPrice
    ) public {
        for (uint256 i = 0; i < admins.length; ++i) {
            _setupRole(ADMIN_ROLE, admins[i]);
        }

        NUM_INITIAL_MINTABLE = _numInitialMintable;
        NUM_PRESALE_MINTABLE = _numPresaleMintable;
        mintPricePresale = _presaleMintPrice;
        mintPricePublic = _publicMintPrice;
    }

    function setToken(ERC721 _token) public onlyAdmin {
        token = _token;
    }

    function checkCanMintPublic(
        address minterAddress,
        uint256 value,
        uint256 amount
    ) external nonReentrant {
        require(amount > 0, "Amount must be greater than 0");
        require(mintMode == MINTMODE.PUBLIC, "Public minting not enabled");
        require(value >= mintPricePublic * amount, "Insufficient funds");
        require(amount <= MAX_MINTABLE_PER_TX, "Amount exceeds allowance per tx");
        require(
            token.balanceOf(minterAddress) + amount <= MAX_MINTABLE_PUBLIC,
            "Amount requested will exceed address allowance"
        );
    }

    function checkCanMintPresale(
        address minterAddress,
        uint256 value,
        uint256 index,
        uint256 maxAmount,
        bytes32[] calldata merkleProof,
        uint256 amountDesired
    ) external nonReentrant {
        require(amountDesired > 0, "Amount must be greater than 0");
        require(
            token.totalSupply() + amountDesired <= NUM_INITIAL_MINTABLE + NUM_PRESALE_MINTABLE,
            "Amount will exceed maximum number of presale NFTs"
        );
        require(mintMode == MINTMODE.PRESALE, "Presale minting not enabled");
        require(address(presaleManager) != address(0), "Merkle root not set");
        require(value >= mintPricePresale * amountDesired, "Insufficient funds");
        require(!presaleManager.hasClaimed(index), "Address already minted");

        // Verify the merkle proof.
        presaleManager.verifyAndSetClaimed(index, minterAddress, maxAmount, merkleProof);
    }

    function checkCanMintInitial(uint256 amountToMint) public nonReentrant returns (uint256) {
        require(
            token.totalSupply() + amountToMint <= NUM_INITIAL_MINTABLE,
            "Amount will exceed maximum number of initial NFTs"
        );
    }

    function setPresaleMintingMerkleRoot(bytes32 merkleRoot) public onlyAdmin {
        if (address(presaleManager) != address(0)) {
            delete presaleManager;
        }

        presaleManager = new MerkleTokenClaimDataManager(merkleRoot);
        emit PresaleMerkleRootSet(merkleRoot);
    }

    function rescueTokens(address tokenAddress) public onlyAdmin {
        uint256 balance = IERC20(tokenAddress).balanceOf(address(this));
        require(IERC20(tokenAddress).transfer(msg.sender, balance), "rescueTokens: Transfer failed.");
    }

    function setPublicSalePrice(uint256 price) public onlyAdmin {
        mintPricePublic = price;
    }

    function setPresalePrice(uint256 price) public onlyAdmin {
        mintPricePresale = price;
    }

    function setMintingMode(MINTMODE mode) public onlyAdmin {
        mintMode = mode;
    }

    function withdrawFunds(address payable _to) public onlyAdmin {
        (bool success, ) = _to.call{value: address(this).balance}("");
        require(success, "Failed to transfer the funds, aborting.");
    }
}

File 7 of 32 : MerkleTokenClaimDataManager.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/cryptography/MerkleProof.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

contract MerkleTokenClaimDataManager is ReentrancyGuard {
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
    using Strings for uint256;

    bytes32 public immutable merkleRoot;
    // This is a packed array of booleans.
    mapping(uint256 => uint256) private claimsBitMap;

    constructor(bytes32 _merkleRoot) public {
        merkleRoot = _merkleRoot;
    }

    function verifyAndSetClaimed(
        uint256 index,
        address account,
        uint256 amount,
        bytes32[] calldata merkleProof
    ) external payable nonReentrant returns (uint256) {
        require(!hasClaimed(index), "Address already claimed.");

        // Verify the merkle proof.
        bytes32 node = keccak256(abi.encodePacked(index, account, amount));
        require(MerkleProof.verify(merkleProof, merkleRoot, node), "Invalid proof.");

        // Mark it claimed and send the token.
        _setClaimed(index);
    }

    function hasClaimed(uint256 index) public view returns (bool) {
        uint256 claimedWordIndex = index / 256;
        uint256 claimedBitIndex = index % 256;
        uint256 claimedWord = claimsBitMap[claimedWordIndex];
        uint256 mask = (1 << claimedBitIndex);
        return claimedWord & mask == mask;
    }

    function _setClaimed(uint256 index) private {
        uint256 claimedWordIndex = index / 256;
        uint256 claimedBitIndex = index % 256;
        claimsBitMap[claimedWordIndex] = claimsBitMap[claimedWordIndex] | (1 << claimedBitIndex);
    }
}

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

pragma solidity ^0.6.0;

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

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

File 9 of 32 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 10 of 32 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

    struct Set {
        // Storage of set values
        bytes32[] _values;

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

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

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

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

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

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

            bytes32 lastvalue = set._values[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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


    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

File 11 of 32 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;

        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping (bytes32 => uint256) _indexes;
    }

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

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

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

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

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

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

            MapEntry storage lastEntry = map._entries[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

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

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

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

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

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

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

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

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

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

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

File 12 of 32 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

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

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

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

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

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

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

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

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

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

File 13 of 32 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 14 of 32 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

import "./IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {

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

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

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

File 15 of 32 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

import "./IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

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

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

File 16 of 32 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 17 of 32 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

    // Base URI
    string private _baseURI;

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

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

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

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

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

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

        return _holderTokens[owner].length();
    }

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

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

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

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

        string memory _tokenURI = _tokenURIs[tokenId];

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mecanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

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

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

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

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

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

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

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

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

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

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

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

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

        _holderTokens[owner].remove(tokenId);

        _tokenOwners.remove(tokenId);

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

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

        _beforeTokenTransfer(from, to, tokenId);

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

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

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

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

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

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

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

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

File 18 of 32 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

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

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

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

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

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

File 19 of 32 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

/**
 * _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {

    /**
        @dev Handles the receipt of a single ERC1155 token type. This function is
        called at the end of a `safeTransferFrom` after the balance has been updated.
        To accept the transfer, this must return
        `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
        (i.e. 0xf23a6e61, or its own function selector).
        @param operator The address which initiated the transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param id The ID of the token being transferred
        @param value The amount of tokens being transferred
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
    */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    )
        external
        returns(bytes4);

    /**
        @dev Handles the receipt of a multiple ERC1155 token types. This function
        is called at the end of a `safeBatchTransferFrom` after the balances have
        been updated. To accept the transfer(s), this must return
        `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
        (i.e. 0xbc197c81, or its own function selector).
        @param operator The address which initiated the batch transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param ids An array containing ids of each token being transferred (order and length must match values array)
        @param values An array containing amounts of each token being transferred (order and length must match ids array)
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
    */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    )
        external
        returns(bytes4);
}

File 20 of 32 : IERC1155.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transfered from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;
}

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

pragma solidity ^0.6.0;

import "./IERC1155Receiver.sol";
import "../../introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    constructor() public {
        _registerInterface(
            ERC1155Receiver(0).onERC1155Received.selector ^
            ERC1155Receiver(0).onERC1155BatchReceived.selector
        );
    }
}

File 22 of 32 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

File 23 of 32 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 24 of 32 : ERC165Checker.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

/**
 * @dev Library used to query support of an interface declared via {IERC165}.
 *
 * Note that these functions return the actual result of the query: they do not
 * `revert` if an interface is not supported. It is up to the caller to decide
 * what to do in these cases.
 */
library ERC165Checker {
    // As per the EIP-165 spec, no interface should ever match 0xffffffff
    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;

    /*
     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
     */
    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;

    /**
     * @dev Returns true if `account` supports the {IERC165} interface,
     */
    function supportsERC165(address account) internal view returns (bool) {
        // Any contract that implements ERC165 must explicitly indicate support of
        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
        return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
            !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
    }

    /**
     * @dev Returns true if `account` supports the interface defined by
     * `interfaceId`. Support for {IERC165} itself is queried automatically.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
        // query support of both ERC165 as per the spec and support of _interfaceId
        return supportsERC165(account) &&
            _supportsERC165Interface(account, interfaceId);
    }

    /**
     * @dev Returns true if `account` supports all the interfaces defined in
     * `interfaceIds`. Support for {IERC165} itself is queried automatically.
     *
     * Batch-querying can lead to gas savings by skipping repeated checks for
     * {IERC165} support.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
        // query support of ERC165 itself
        if (!supportsERC165(account)) {
            return false;
        }

        // query support of each interface in _interfaceIds
        for (uint256 i = 0; i < interfaceIds.length; i++) {
            if (!_supportsERC165Interface(account, interfaceIds[i])) {
                return false;
            }
        }

        // all interfaces supported
        return true;
    }

    /**
     * @notice Query if a contract implements an interface, does not check ERC165 support
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return true if the contract at account indicates support of the interface with
     * identifier interfaceId, false otherwise
     * @dev Assumes that account contains a contract that supports ERC165, otherwise
     * the behavior of this method is undefined. This precondition can be checked
     * with {supportsERC165}.
     * Interface identification is specified in ERC-165.
     */
    function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
        // success determines whether the staticcall succeeded and result determines
        // whether the contract at account indicates support of _interfaceId
        (bool success, bool result) = _callERC165SupportsInterface(account, interfaceId);

        return (success && result);
    }

    /**
     * @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return success true if the STATICCALL succeeded, false otherwise
     * @return result true if the STATICCALL succeeded and the contract at account
     * indicates support of the interface with identifier interfaceId, false otherwise
     */
    function _callERC165SupportsInterface(address account, bytes4 interfaceId)
        private
        view
        returns (bool, bool)
    {
        bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId);
        (bool success, bytes memory result) = account.staticcall{ gas: 30000 }(encodedParams);
        if (result.length < 32) return (false, false);
        return (success, abi.decode(result, (bool)));
    }
}

File 25 of 32 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./IERC165.sol";

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

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

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

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

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

File 26 of 32 : MerkleProof.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev These functions deal with verification of Merkle trees (hash trees),
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        bytes32 computedHash = leaf;

        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];

            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
            }
        }

        // Check if the computed hash (root) is equal to the provided root
        return computedHash == root;
    }
}

File 27 of 32 : AccessControl.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../utils/EnumerableSet.sol";
import "../utils/Address.sol";
import "../GSN/Context.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms.
 *
 * 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 {
    using EnumerableSet for EnumerableSet.AddressSet;
    using Address for address;

    struct RoleData {
        EnumerableSet.AddressSet members;
        bytes32 adminRole;
    }

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @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 {_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) public view returns (bool) {
        return _roles[role].members.contains(account);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view returns (uint256) {
        return _roles[role].members.length();
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
        return _roles[role].members.at(index);
    }

    /**
     * @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 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 {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");

        _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 {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");

        _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 granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual {
        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}.
     * ====
     */
    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 {
        emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (_roles[role].members.add(account)) {
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (_roles[role].members.remove(account)) {
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 28 of 32 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

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

File 29 of 32 : SafeMathChainlink.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

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

    return c;
  }

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

    return c;
  }

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

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

    return c;
  }

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

    return c;
  }

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

File 30 of 32 : LinkTokenInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.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 31 of 32 : VRFRequestIDBase.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.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));
  }
}

File 32 of 32 : VRFConsumerBase.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "./vendor/SafeMathChainlink.sol";

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     constuctor(<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 {

  using SafeMathChainlink for uint256;

  /**
   * @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 constant private 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].add(1);
    return makeRequestId(_keyHash, vRFSeed);
  }

  LinkTokenInterface immutable internal LINK;
  address immutable private vrfCoordinator;

  // Nonces for each VRF key from which randomness has been requested.
  //
  // Must stay in sync with VRFCoordinator[_keyHash][this]
  mapping(bytes32 /* keyHash */ => uint256 /* 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) public {
    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);
  }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address[]","name":"admins","type":"address[]"},{"internalType":"contract MintManager","name":"_mintManager","type":"address"},{"internalType":"contract TraitSeedManager","name":"_traitSeedManager","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"FrameContentsRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"contentsContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"contentsId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"bound","type":"bool"}],"name":"FrameContentsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"FrameMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"frameTraitManager","type":"address"}],"name":"FrameTraitManagerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"}],"name":"RandomnessRequested","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":"royaltyGovernor","type":"address"}],"name":"RoyaltyGovernorContractChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"seed","type":"uint256"}],"name":"TraitSeedSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"frameContents","outputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"bound","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"frameTraitManager","outputs":[{"internalType":"contract IFrameTraitManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","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":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getTraits","outputs":[{"internalType":"uint256","name":"traits","type":"uint256"}],"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":"uint256","name":"_tokenId","type":"uint256"}],"name":"hasContentsInFrame","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountToMint","type":"uint256"}],"name":"mintInitial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintManager","outputs":[{"internalType":"contract MintManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint256","name":"maxAmount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"},{"internalType":"uint256","name":"amountDesired","type":"uint256"}],"name":"mintPresale","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"removeFrameContents","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":"address","name":"tokenAddress","type":"address"}],"name":"rescueTokens","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":[],"name":"royaltyGovernorContract","outputs":[{"internalType":"contract IRoyaltyGovernor","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"_receiver","type":"address"},{"internalType":"uint256","name":"_royaltyAmount","type":"uint256"},{"internalType":"bytes","name":"_royaltyPaymentData","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_contractURI","type":"string"}],"name":"setContractUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"traitHash","type":"uint256[]"},{"internalType":"uint256[]","name":"indexes","type":"uint256[]"}],"name":"setCustomTraits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"contentContractAddress","type":"address"},{"internalType":"uint256","name":"contentTokenId","type":"uint256"},{"internalType":"uint256","name":"contentAmount","type":"uint256"},{"internalType":"bool","name":"bindContentToFrame","type":"bool"}],"name":"setFrameContents","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IFrameTraitManager","name":"managerAddress","type":"address"}],"name":"setFrameTraitManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IRoyaltyGovernor","name":"_royaltyGovAddr","type":"address"}],"name":"setRoyaltyGovernor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_tokenUriBase","type":"string"}],"name":"setTokenUriBase","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":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"traitSeedManager","outputs":[{"internalType":"contract TraitSeedManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_to","type":"address"}],"name":"withdrawFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a060405279115c0000000000000000000000000000000000000000000000006080523480156200002f57600080fd5b506040516200595838038062005958833981810160405260608110156200005557600080fd5b81019080805160405193929190846401000000008211156200007657600080fd5b9083019060208201858111156200008c57600080fd5b8251866020820283011164010000000082111715620000aa57600080fd5b82525081516020918201928201910280838360005b83811015620000d9578181015183820152602001620000bf565b50505050919091016040818152602084810151948201518284018352601084527f4672616d6573206279204d7572416c6c00000000000000000000000000000000828501528251808401909352600683527f4652414d455300000000000000000000000000000000000000000000000000009183019190915260018055939550929350919050620001937f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03620003cf16565b620001c77f4e2312e0000000000000000000000000000000000000000000000000000000006001600160e01b03620003cf16565b8151620001dc906008906020850190620005d7565b508051620001f2906009906020840190620005d7565b50620002277f80ac58cd000000000000000000000000000000000000000000000000000000006001600160e01b03620003cf16565b6200025b7f5b5e139f000000000000000000000000000000000000000000000000000000006001600160e01b03620003cf16565b6200028f7f780e9d63000000000000000000000000000000000000000000000000000000006001600160e01b03620003cf16565b50600090505b83518110156200030357620002fa60405180807f41444d494e5f524f4c4500000000000000000000000000000000000000000000815250600a0190506040518091039020858381518110620002e657fe5b60200260200101516200049e60201b60201c565b60010162000295565b5060005b835181101562000361576200035860405180807f54524149545f4d4f445f524f4c45000000000000000000000000000000000000815250600e0190506040518091039020858381518110620002e657fe5b60010162000307565b50600f80546001600160a01b038084166001600160a01b031992831617909255600d805492851692909116919091179055620003c67f150b7a02000000000000000000000000000000000000000000000000000000006001600160e01b03620003cf16565b50505062000679565b7fffffffff0000000000000000000000000000000000000000000000000000000080821614156200046157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b7fffffffff00000000000000000000000000000000000000000000000000000000166000908152600260205260409020805460ff19166001179055565b620004b382826001600160e01b03620004b716565b5050565b600082815260208181526040909120620004dc91839062003a9262000539821b17901c565b15620004b357620004f56001600160e01b036200056216565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600062000559836001600160a01b0384166001600160e01b036200056716565b90505b92915050565b335b90565b60006200057e83836001600160e01b03620005bf16565b620005b6575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556200055c565b5060006200055c565b60009081526001919091016020526040902054151590565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200061a57805160ff19168380011785556200064a565b828001600101855582156200064a579182015b828111156200064a5782518255916020019190600101906200062d565b50620006589291506200065c565b5090565b6200056491905b8082111562000658576000815560010162000663565b60805160c01c6152bc6200069c6000398061218c5280613b6252506152bc6000f3fe60806040526004361061032c5760003560e01c8063739d6ca9116101a5578063c7c01ec5116100ec578063d547741f11610095578063e985e9c51161006f578063e985e9c5146111e6578063f147ce3f14611221578063f23a6e611461126e578063f9f466f41461134657610333565b8063d547741f1461116e578063e1dc0761146111a7578063e8a3d485146111d157610333565b8063ccb4807b116100c6578063ccb4807b14610f93578063d15beb4514611010578063d509d5921461103a57610333565b8063c7c01ec514610f2a578063c87b56dd14610f3f578063ca15c87314610f6957610333565b8063a0712d681161014e578063b88d4fde11610128578063b88d4fde14610b62578063bc197c8114610c35578063c155531d14610e0957610333565b8063a0712d6814610af5578063a217fddf14610b12578063a22cb46514610b2757610333565b80639010d07c1161017f5780639010d07c14610a7757806391d1485414610aa757806395d89b4114610ae057610333565b8063739d6ca9146109f15780637e4edf7014610a06578063855a85b614610a1b57610333565b8063248a9ca31161027457806342842e0e1161021d5780636533a6fc116101f75780636533a6fc146108f957806368742da6146109765780636c0360eb146109a957806370a08231146109be57610333565b806342842e0e146108625780634f6ccce7146108a55780636352211e146108cf57610333565b80632f745c591161024e5780632f745c59146107be57806332cb6b0c146107f757806336568abe1461082957610333565b8063248a9ca3146107285780632774fb77146107525780632f2ff15d1461078557610333565b8063095ea7b3116102d657806318160ddd116102b057806318160ddd146106945780631ecb8113146106bb57806323b872dd146106e557610333565b8063095ea7b3146104d7578063150b7a02146105105780631685684d1461061857610333565b806306fdde031161030757806306fdde03146103f957806307f3e9cf14610483578063081812fc146104ad57610333565b8062ae3bf81461033557806301ffc9a7146103685780630626abee146103c857610333565b3661033357005b005b34801561034157600080fd5b506103336004803603602081101561035857600080fd5b50356001600160a01b0316611379565b34801561037457600080fd5b506103b46004803603602081101561038b57600080fd5b50357fffffffff0000000000000000000000000000000000000000000000000000000016611582565b604080519115158252519081900360200190f35b3480156103d457600080fd5b506103dd6115bd565b604080516001600160a01b039092168252519081900360200190f35b34801561040557600080fd5b5061040e6115cc565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610448578181015183820152602001610430565b50505050905090810190601f1680156104755780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561048f57600080fd5b50610333600480360360208110156104a657600080fd5b5035611681565b3480156104b957600080fd5b506103dd600480360360208110156104d057600080fd5b50356119f6565b3480156104e357600080fd5b50610333600480360360408110156104fa57600080fd5b506001600160a01b038135169060200135611a58565b34801561051c57600080fd5b506105e36004803603608081101561053357600080fd5b6001600160a01b0382358116926020810135909116916040820135919081019060808101606082013564010000000081111561056e57600080fd5b82018360208201111561058057600080fd5b803590602001918460018302840111640100000000831117156105a257600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611b33945050505050565b604080517fffffffff000000000000000000000000000000000000000000000000000000009092168252519081900360200190f35b6103336004803603608081101561062e57600080fd5b81359160208101359181019060608101604082013564010000000081111561065557600080fd5b82018360208201111561066757600080fd5b8035906020019184602083028401116401000000008311171561068957600080fd5b919350915035611b5d565b3480156106a057600080fd5b506106a9611d52565b60408051918252519081900360200190f35b3480156106c757600080fd5b506106a9600480360360208110156106de57600080fd5b5035611d63565b3480156106f157600080fd5b506103336004803603606081101561070857600080fd5b506001600160a01b03813581169160208101359091169060400135611f96565b34801561073457600080fd5b506106a96004803603602081101561074b57600080fd5b5035611fed565b34801561075e57600080fd5b506103336004803603602081101561077557600080fd5b50356001600160a01b0316612002565b34801561079157600080fd5b50610333600480360360408110156107a857600080fd5b50803590602001356001600160a01b03166120f1565b3480156107ca57600080fd5b506106a9600480360360408110156107e157600080fd5b506001600160a01b038135169060200135612159565b34801561080357600080fd5b5061080c61218a565b6040805167ffffffffffffffff9092168252519081900360200190f35b34801561083557600080fd5b506103336004803603604081101561084c57600080fd5b50803590602001356001600160a01b03166121ae565b34801561086e57600080fd5b506103336004803603606081101561088557600080fd5b506001600160a01b0381358116916020810135909116906040013561220f565b3480156108b157600080fd5b506106a9600480360360208110156108c857600080fd5b503561222a565b3480156108db57600080fd5b506103dd600480360360208110156108f257600080fd5b5035612246565b34801561090557600080fd5b506103336004803603602081101561091c57600080fd5b81019060208101813564010000000081111561093757600080fd5b82018360208201111561094957600080fd5b8035906020019184600183028401116401000000008311171561096b57600080fd5b509092509050612274565b34801561098257600080fd5b506103336004803603602081101561099957600080fd5b50356001600160a01b0316612340565b3480156109b557600080fd5b5061040e61245e565b3480156109ca57600080fd5b506106a9600480360360208110156109e157600080fd5b50356001600160a01b03166124dd565b3480156109fd57600080fd5b506103dd612545565b348015610a1257600080fd5b506103dd612554565b348015610a2757600080fd5b50610a4560048036036020811015610a3e57600080fd5b5035612563565b604080516001600160a01b03909516855260208501939093528383019190915215156060830152519081900360800190f35b348015610a8357600080fd5b506103dd60048036036040811015610a9a57600080fd5b5080359060200135612597565b348015610ab357600080fd5b506103b460048036036040811015610aca57600080fd5b50803590602001356001600160a01b03166125b5565b348015610aec57600080fd5b5061040e6125d3565b61033360048036036020811015610b0b57600080fd5b5035612652565b348015610b1e57600080fd5b506106a96127dd565b348015610b3357600080fd5b5061033360048036036040811015610b4a57600080fd5b506001600160a01b03813516906020013515156127e2565b348015610b6e57600080fd5b5061033360048036036080811015610b8557600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135640100000000811115610bc057600080fd5b820183602082011115610bd257600080fd5b80359060200191846001830284011164010000000083111715610bf457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612905945050505050565b348015610c4157600080fd5b506105e3600480360360a0811015610c5857600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135640100000000811115610c8c57600080fd5b820183602082011115610c9e57600080fd5b80359060200191846020830284011164010000000083111715610cc057600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610d1057600080fd5b820183602082011115610d2257600080fd5b80359060200191846020830284011164010000000083111715610d4457600080fd5b9190808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152509295949360208101935035915050640100000000811115610d9457600080fd5b820183602082011115610da657600080fd5b80359060200191846001830284011164010000000083111715610dc857600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612963945050505050565b348015610e1557600080fd5b50610e9260048036036060811015610e2c57600080fd5b813591602081013591810190606081016040820135640100000000811115610e5357600080fd5b820183602082011115610e6557600080fd5b80359060200191846001830284011164010000000083111715610e8757600080fd5b50909250905061296a565b60405180846001600160a01b03166001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b83811015610eed578181015183820152602001610ed5565b50505050905090810190601f168015610f1a5780820380516001836020036101000a031916815260200191505b5094505050505060405180910390f35b348015610f3657600080fd5b506103dd612b3a565b348015610f4b57600080fd5b5061040e60048036036020811015610f6257600080fd5b5035612b49565b348015610f7557600080fd5b506106a960048036036020811015610f8c57600080fd5b5035612e68565b348015610f9f57600080fd5b5061033360048036036020811015610fb657600080fd5b810190602081018135640100000000811115610fd157600080fd5b820183602082011115610fe357600080fd5b8035906020019184600183028401116401000000008311171561100557600080fd5b509092509050612e7f565b34801561101c57600080fd5b506103b46004803603602081101561103357600080fd5b5035612f18565b34801561104657600080fd5b506103336004803603604081101561105d57600080fd5b81019060208101813564010000000081111561107857600080fd5b82018360208201111561108a57600080fd5b803590602001918460208302840111640100000000831117156110ac57600080fd5b91908080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525092959493602081019350359150506401000000008111156110fc57600080fd5b82018360208201111561110e57600080fd5b8035906020019184602083028401116401000000008311171561113057600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929550612f98945050505050565b34801561117a57600080fd5b506103336004803603604081101561119157600080fd5b50803590602001356001600160a01b03166131f8565b3480156111b357600080fd5b506106a9600480360360208110156111ca57600080fd5b5035613251565b3480156111dd57600080fd5b5061040e61339b565b3480156111f257600080fd5b506103b46004803603604081101561120957600080fd5b506001600160a01b0381358116916020013516613447565b34801561122d57600080fd5b50610333600480360360a081101561124457600080fd5b508035906001600160a01b0360208201351690604081013590606081013590608001351515613475565b34801561127a57600080fd5b506105e3600480360360a081101561129157600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a0810160808201356401000000008111156112d157600080fd5b8201836020820111156112e357600080fd5b8035906020019184600183028401116401000000008311171561130557600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550613979945050505050565b34801561135257600080fd5b506103336004803603602081101561136957600080fd5b50356001600160a01b03166139a3565b604080517f41444d494e5f524f4c45000000000000000000000000000000000000000000008152905190819003600a0190206113b590336125b5565b611406576040805162461bcd60e51b815260206004820152601860248201527f446f6573206e6f7420686176652061646d696e20726f6c650000000000000000604482015290519081900360640190fd5b604080517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015290516000916001600160a01b038416916370a0823191602480820192602092909190829003018186803b15801561146957600080fd5b505afa15801561147d573d6000803e3d6000fd5b505050506040513d602081101561149357600080fd5b5051604080517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201526024810183905290519192506001600160a01b0384169163a9059cbb916044808201926020929091908290030181600087803b15801561150157600080fd5b505af1158015611515573d6000803e3d6000fd5b505050506040513d602081101561152b57600080fd5b505161157e576040805162461bcd60e51b815260206004820152601e60248201527f726573637565546f6b656e733a205472616e73666572206661696c65642e0000604482015290519081900360640190fd5b5050565b7fffffffff00000000000000000000000000000000000000000000000000000000811660009081526002602052604090205460ff165b919050565b600c546001600160a01b031681565b60088054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156116765780601f1061164b57610100808354040283529160200191611676565b820191906000526020600020905b81548152906001019060200180831161165957829003601f168201915b505050505090505b90565b600260015414156116d9576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155336116e882612246565b6001600160a01b031614611743576040805162461bcd60e51b815260206004820152600f60248201527f4e6f7420746f6b656e206f776e65720000000000000000000000000000000000604482015290519081900360640190fd5b61174c81612f18565b6117875760405162461bcd60e51b8152600401808060200182810382526022815260200180614f796022913960400191505060405180910390fd5b61178f614d9e565b50600081815260126020908152604091829020825160808101845281546001600160a01b0316815260018201549281019290925260028101549282019290925260039091015460ff16158015606083015261195c57805161181f906001600160a01b03167f80ac58cd0000000000000000000000000000000000000000000000000000000063ffffffff613aa716565b156118b75780516020820151604080517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201523360248201526044810192909252516001600160a01b03909216916342842e0e9160648082019260009290919082900301818387803b15801561189a57600080fd5b505af11580156118ae573d6000803e3d6000fd5b5050505061195c565b8051602082015160408084015181517ff242432a0000000000000000000000000000000000000000000000000000000081523060048201523360248201526044810193909352606483015260a06084830152600060a4830181905290516001600160a01b039093169263f242432a9260e480820193929182900301818387803b15801561194357600080fd5b505af1158015611957573d6000803e3d6000fd5b505050505b60008281526012602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155600181018390556002810183905560030180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690555183917fa75ff4e9b6a8edf53f89a69e3bee65ef7bdd8c9867c5b38febf1d8744fbccb3a91a2505060018055565b6000611a0182613ac3565b611a3c5760405162461bcd60e51b815260040180806020018281038252602c815260200180615111602c913960400191505060405180910390fd5b506000908152600660205260409020546001600160a01b031690565b6000611a6382612246565b9050806001600160a01b0316836001600160a01b03161415611ab65760405162461bcd60e51b81526004018080602001828103825260218152602001806151bc6021913960400191505060405180910390fd5b806001600160a01b0316611ac8613ad6565b6001600160a01b03161480611ae95750611ae981611ae4613ad6565b613447565b611b245760405162461bcd60e51b81526004018080602001828103825260388152602001806150646038913960400191505060405180910390fd5b611b2e8383613ada565b505050565b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b60026001541415611bb5576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155600d546040517f12d03f8100000000000000000000000000000000000000000000000000000000815233600482018181523460248401819052604484018a90526064840189905260a4840186905260c06084850190815260c485018890526001600160a01b03909516946312d03f819491928b928b928b928b928b929060e401856020860280828437600081840152601f19601f82011690508083019250505098505050505050505050600060405180830381600087803b158015611c7e57600080fd5b505af1158015611c92573d6000803e3d6000fd5b505050506000600f60009054906101000a90046001600160a01b03166001600160a01b031663463b23dc6040518163ffffffff1660e01b815260040160206040518083038186803b158015611ce657600080fd5b505afa158015611cfa573d6000803e3d6000fd5b505050506040513d6020811015611d1057600080fd5b505190506000828610611d235782611d25565b855b905060005b81811015611d4457611d3c3384613b60565b600101611d2a565b505060018055505050505050565b6000611d5e6004613c76565b905090565b600060026001541415611dbd576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155604080517f41444d494e5f524f4c45000000000000000000000000000000000000000000008152905190819003600a019020611dfe90336125b5565b611e4f576040805162461bcd60e51b815260206004820152601860248201527f446f6573206e6f7420686176652061646d696e20726f6c650000000000000000604482015290519081900360640190fd5b600d54604080517f832648f60000000000000000000000000000000000000000000000000000000081526004810185905290516001600160a01b039092169163832648f6916024808201926020929091908290030181600087803b158015611eb657600080fd5b505af1158015611eca573d6000803e3d6000fd5b505050506040513d6020811015611ee057600080fd5b5050600f54604080517f463b23dc00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163463b23dc916004808301926020929190829003018186803b158015611f4057600080fd5b505afa158015611f54573d6000803e3d6000fd5b505050506040513d6020811015611f6a57600080fd5b5051905060005b83811015611f8b57611f833383613b60565b600101611f71565b505060018055919050565b611fa7611fa1613ad6565b82613c81565b611fe25760405162461bcd60e51b81526004018080602001828103825260318152602001806152276031913960400191505060405180910390fd5b611b2e838383613d1d565b60009081526020819052604090206002015490565b604080517f41444d494e5f524f4c45000000000000000000000000000000000000000000008152905190819003600a01902061203e90336125b5565b61208f576040805162461bcd60e51b815260206004820152601860248201527f446f6573206e6f7420686176652061646d696e20726f6c650000000000000000604482015290519081900360640190fd5b600e80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517fbc45a353b16f28623e13856f76c64e29ed27355630d43a6112b437c62e00873390600090a250565b6000828152602081905260409020600201546121149061210f613ad6565b6125b5565b61214f5760405162461bcd60e51b815260040180806020018281038252602f815260200180614f18602f913960400191505060405180910390fd5b61157e8282613e7b565b6001600160a01b0382166000908152600360205260408120612181908363ffffffff613eea16565b90505b92915050565b7f000000000000000000000000000000000000000000000000000000000000000081565b6121b6613ad6565b6001600160a01b0316816001600160a01b0316146122055760405162461bcd60e51b815260040180806020018281038252602f815260200180615258602f913960400191505060405180910390fd5b61157e8282613ef6565b611b2e83838360405180602001604052806000815250612905565b60008061223e60048463ffffffff613f6516565b509392505050565b6000612184826040518060600160405280602981526020016150c6602991396004919063ffffffff613f8316565b604080517f41444d494e5f524f4c45000000000000000000000000000000000000000000008152905190819003600a0190206122b090336125b5565b612301576040805162461bcd60e51b815260206004820152601860248201527f446f6573206e6f7420686176652061646d696e20726f6c650000000000000000604482015290519081900360640190fd5b61157e82828080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613f9a92505050565b604080517f41444d494e5f524f4c45000000000000000000000000000000000000000000008152905190819003600a01902061237c90336125b5565b6123cd576040805162461bcd60e51b815260206004820152601860248201527f446f6573206e6f7420686176652061646d696e20726f6c650000000000000000604482015290519081900360640190fd5b6040516000906001600160a01b038316903031908381818185875af1925050503d8060008114612419576040519150601f19603f3d011682016040523d82523d6000602084013e61241e565b606091505b505090508061157e5760405162461bcd60e51b8152600401808060200182810382526027815260200180614feb6027913960400191505060405180910390fd5b600b8054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156116765780601f1061164b57610100808354040283529160200191611676565b60006001600160a01b0382166125245760405162461bcd60e51b815260040180806020018281038252602a81526020018061509c602a913960400191505060405180910390fd5b6001600160a01b038216600090815260036020526040902061218490613c76565b600e546001600160a01b031681565b600d546001600160a01b031681565b60126020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909160ff1684565b6000828152602081905260408120612181908363ffffffff613eea16565b6000828152602081905260408120612181908363ffffffff613fad16565b60098054604080516020601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156116765780601f1061164b57610100808354040283529160200191611676565b600260015414156126aa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155600d54604080517f53cac4c60000000000000000000000000000000000000000000000000000000081523360048201523460248201526044810184905290516001600160a01b03909216916353cac4c69160648082019260009290919082900301818387803b15801561272157600080fd5b505af1158015612735573d6000803e3d6000fd5b505050506000600f60009054906101000a90046001600160a01b03166001600160a01b031663463b23dc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561278957600080fd5b505afa15801561279d573d6000803e3d6000fd5b505050506040513d60208110156127b357600080fd5b5051905060005b828110156127d4576127cc3383613b60565b6001016127ba565b50506001805550565b600081565b6127ea613ad6565b6001600160a01b0316826001600160a01b03161415612850576040805162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015290519081900360640190fd5b806007600061285d613ad6565b6001600160a01b0390811682526020808301939093526040918201600090812091871680825291909352912080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016921515929092179091556128bf613ad6565b60408051841515815290516001600160a01b0392909216917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319181900360200190a35050565b612916612910613ad6565b83613c81565b6129515760405162461bcd60e51b81526004018080602001828103825260318152602001806152276031913960400191505060405180910390fd5b61295d84848484613fc2565b50505050565b6000806000fd5b600e546040517fc155531d000000000000000000000000000000000000000000000000000000008152600481018681526024820186905260606044830181815260648401869052600094859492936001600160a01b039091169263c155531d928b928b928b928b9291608401848480828437600081840152601f19601f82011690508083019250505095505050505050600060405180830381600087803b158015612a1457600080fd5b505af1158015612a28573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526060811015612a6f57600080fd5b81516020830151604080850180519151939592948301929184640100000000821115612a9a57600080fd5b908301906020820185811115612aaf57600080fd5b8251640100000000811182820188101715612ac957600080fd5b82525081516020918201929091019080838360005b83811015612af6578181015183820152602001612ade565b50505050905090810190601f168015612b235780820380516001836020036101000a031916815260200191505b506040525050509250925092509450945094915050565b600f546001600160a01b031681565b6060612b5482613ac3565b612b8f5760405162461bcd60e51b815260040180806020018281038252602f81526020018061518d602f913960400191505060405180910390fd5b6000828152600a602090815260409182902080548351601f60027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610100600186161502019093169290920491820184900484028101840190945280845260609392830182828015612c425780601f10612c1757610100808354040283529160200191612c42565b820191906000526020600020905b815481529060010190602001808311612c2557829003601f168201915b5050600b5493945050505060027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6101006001841615020190911604612c895790506115b8565b805115612d7857600b816040516020018083805460018160011615610100020316600290048015612cf15780601f10612ccf576101008083540402835291820191612cf1565b820191906000526020600020905b815481529060010190602001808311612cdd575b5050825160208401908083835b60208310612d3b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612cfe565b6001836020036101000a038019825116818451168082178552505050505050905001925050506040516020818303038152906040529150506115b8565b600b612d8384614014565b6040516020018083805460018160011615610100020316600290048015612de15780601f10612dbf576101008083540402835291820191612de1565b820191906000526020600020905b815481529060010190602001808311612dcd575b5050825160208401908083835b60208310612e2b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101612dee565b6001836020036101000a03801982511681845116808217855250505050505090500192505050604051602081830303815290604052915050919050565b600081815260208190526040812061218490613c76565b604080517f41444d494e5f524f4c45000000000000000000000000000000000000000000008152905190819003600a019020612ebb90336125b5565b612f0c576040805162461bcd60e51b815260206004820152601860248201527f446f6573206e6f7420686176652061646d696e20726f6c650000000000000000604482015290519081900360640190fd5b611b2e60108383614dd1565b600081612f2481613ac3565b612f75576040805162461bcd60e51b815260206004820152601060248201527f496e76616c696420546f6b656e20494400000000000000000000000000000000604482015290519081900360640190fd5b6000838152601260205260409020546001600160a01b0316151591505b50919050565b604080517f54524149545f4d4f445f524f4c450000000000000000000000000000000000008152905190819003600e019020612fd490336125b5565b613025576040805162461bcd60e51b815260206004820152601c60248201527f446f6573206e6f742068617665207472616974206d6f6420726f6c6500000000604482015290519081900360640190fd5b80518251146130655760405162461bcd60e51b81526004018080602001828103825260268152602001806151dd6026913960400191505060405180910390fd5b60005b8251811015611b2e57600d60009054906101000a90046001600160a01b03166001600160a01b031663bef311d46040518163ffffffff1660e01b815260040160206040518083038186803b1580156130bf57600080fd5b505afa1580156130d3573d6000803e3d6000fd5b505050506040513d60208110156130e957600080fd5b5051825167ffffffffffffffff9091169083908390811061310657fe5b60200260200101511061314a5760405162461bcd60e51b81526004018080602001828103825260228152602001806150426022913960400191505060405180910390fd5b6011600083838151811061315a57fe5b60200260200101518152602001908152602001600020546000146131af5760405162461bcd60e51b81526004018080602001828103825260228152602001806150426022913960400191505060405180910390fd5b8281815181106131bb57fe5b6020026020010151601160008484815181106131d357fe5b6020026020010151815260200190815260200160002081905550806001019050613068565b6000828152602081905260409020600201546132169061210f613ad6565b6122055760405162461bcd60e51b81526004018080602001828103825260308152602001806150126030913960400191505060405180910390fd5b60008161325d81613ac3565b6132ae576040805162461bcd60e51b815260206004820152601060248201527f496e76616c696420546f6b656e20494400000000000000000000000000000000604482015290519081900360640190fd5b600083815260116020526040902054156132d8576000838152601160205260409020549150612f92565b600f54604080517fd2286f040000000000000000000000000000000000000000000000000000000081526004810186905290516000926001600160a01b03169163d2286f04916024808301926020929190829003018186803b15801561333d57600080fd5b505afa158015613351573d6000803e3d6000fd5b505050506040513d602081101561336757600080fd5b505160408051602081810193909352808201879052815180820383018152606090910190915280519101209250612f929050565b6010805460408051602060026001851615610100027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190941693909304601f8101849004840282018401909252818152929183018282801561343f5780601f106134145761010080835404028352916020019161343f565b820191906000526020600020905b81548152906001019060200180831161342257829003601f168201915b505050505081565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b600260015414156134cd576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600155336134dc86612246565b6001600160a01b031614613537576040805162461bcd60e51b815260206004820152600f60248201527f4e6f7420746f6b656e206f776e65720000000000000000000000000000000000604482015290519081900360640190fd5b801561372a5760008581526012602052604090206003015460ff161561358e5760405162461bcd60e51b81526004018080602001828103825260248152602001806152036024913960400191505060405180910390fd5b6135c76001600160a01b0385167f80ac58cd0000000000000000000000000000000000000000000000000000000063ffffffff613aa716565b1561366257604080517fb88d4fde000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018590526080606482015260006084820181905291516001600160a01b0387169263b88d4fde9260c4808201939182900301818387803b15801561364557600080fd5b505af1158015613659573d6000803e3d6000fd5b50505050613725565b61369b6001600160a01b0385167fd9b67a260000000000000000000000000000000000000000000000000000000063ffffffff613aa716565b1561372057604080517ff242432a000000000000000000000000000000000000000000000000000000008152336004820152306024820152604481018590526064810184905260a06084820152600060a4820181905291516001600160a01b0387169263f242432a9260e4808201939182900301818387803b15801561364557600080fd5b600080fd5b613961565b6137636001600160a01b0385167f80ac58cd0000000000000000000000000000000000000000000000000000000063ffffffff613aa716565b1561383d57336001600160a01b0316846001600160a01b0316636352211e856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b1580156137b657600080fd5b505afa1580156137ca573d6000803e3d6000fd5b505050506040513d60208110156137e057600080fd5b50516001600160a01b031614613725576040805162461bcd60e51b815260206004820152600f60248201527f4e6f7420746f6b656e206f776e65720000000000000000000000000000000000604482015290519081900360640190fd5b6138766001600160a01b0385167fd9b67a260000000000000000000000000000000000000000000000000000000063ffffffff613aa716565b1561372057604080517efdd58e00000000000000000000000000000000000000000000000000000000815233600482015260248101859052905183916001600160a01b0387169162fdd58e91604480820192602092909190829003018186803b1580156138e257600080fd5b505afa1580156138f6573d6000803e3d6000fd5b505050506040513d602081101561390c57600080fd5b50511015613725576040805162461bcd60e51b815260206004820152601160248201527f4e6f7420656e6f75676820746f6b656e73000000000000000000000000000000604482015290519081900360640190fd5b61396e8585858585614141565b505060018055505050565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b604080517f41444d494e5f524f4c45000000000000000000000000000000000000000000008152905190819003600a0190206139df90336125b5565b613a30576040805162461bcd60e51b815260206004820152601860248201527f446f6573206e6f7420686176652061646d696e20726f6c650000000000000000604482015290519081900360640190fd5b600c80547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517fe1fab4ea190242a84dbe795484ac1e5aad5d2413474381987089fd0fe51819b090600090a250565b6000612181836001600160a01b0384166142a9565b6000613ab2836142f3565b801561218157506121818383614357565b600061218460048363ffffffff61437d16565b3390565b600081815260066020526040902080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091558190613b2782612246565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b7f000000000000000000000000000000000000000000000000000000000000000067ffffffffffffffff16613b93611d52565b1115613be6576040805162461bcd60e51b815260206004820152601d60248201527f4d6178696d756d206e756d626572206f66204e465473206d696e746564000000604482015290519081900360640190fd5b6000613bf0611d52565b905081811115613c315760405162461bcd60e51b81526004018080602001828103825260278152602001806151666027913960400191505060405180910390fd5b613c3b8382614389565b6040516001600160a01b0384169082907fbde7c42185e319d9756a9ee98e28431ed931c416998ad8a1b49330d8cdc01f4a90600090a3505050565b6000612184826144c3565b6000613c8c82613ac3565b613cc75760405162461bcd60e51b815260040180806020018281038252602c815260200180614fbf602c913960400191505060405180910390fd5b6000613cd283612246565b9050806001600160a01b0316846001600160a01b03161480613d0d5750836001600160a01b0316613d02846119f6565b6001600160a01b0316145b80611b555750611b558185613447565b826001600160a01b0316613d3082612246565b6001600160a01b031614613d755760405162461bcd60e51b815260040180806020018281038252602981526020018061513d6029913960400191505060405180910390fd5b6001600160a01b038216613dba5760405162461bcd60e51b8152600401808060200182810382526024815260200180614f9b6024913960400191505060405180910390fd5b613dc5838383611b2e565b613dd0600082613ada565b6001600160a01b0383166000908152600360205260409020613df8908263ffffffff6144c716565b506001600160a01b0382166000908152600360205260409020613e21908263ffffffff6144d316565b50613e346004828463ffffffff6144df16565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000828152602081905260409020613e99908263ffffffff613a9216565b1561157e57613ea6613ad6565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600061218183836144f5565b6000828152602081905260409020613f14908263ffffffff61455916565b1561157e57613f21613ad6565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b6000808080613f74868661456e565b909450925050505b9250929050565b6000613f908484846145e9565b90505b9392505050565b805161157e90600b906020840190614e6d565b6000612181836001600160a01b0384166146b3565b613fcd848484613d1d565b613fd9848484846146cb565b61295d5760405162461bcd60e51b8152600401808060200182810382526032815260200180614f476032913960400191505060405180910390fd5b606081614055575060408051808201909152600181527f300000000000000000000000000000000000000000000000000000000000000060208201526115b8565b8160005b811561406d57600101600a82049150614059565b60608167ffffffffffffffff8111801561408657600080fd5b506040519080825280601f01601f1916602001820160405280156140b1576020820181803683370190505b5085935090507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82015b831561413857600a840660300160f81b828280600190039350815181106140fe57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a840493506140db565b50949350505050565b8461414b81613ac3565b61419c576040805162461bcd60e51b815260206004820152601060248201527f496e76616c696420546f6b656e20494400000000000000000000000000000000604482015290519081900360640190fd5b6141a4614d9e565b6040518060800160405280876001600160a01b031681526020018681526020018581526020018415158152509050806012600089815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b03160217905550602082015181600101556040820151816002015560608201518160030160006101000a81548160ff021916908315150217905550905050856001600160a01b0316877fdbc6e5094304c27f5ee98123ac8f376fdb4f407a97a4d39a4c00b3634c03a90c8787876040518084815260200183815260200182151515158152602001935050505060405180910390a350505050505050565b60006142b583836146b3565b6142eb57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155612184565b506000612184565b600061431f827f01ffc9a700000000000000000000000000000000000000000000000000000000614357565b80156121845750614350827fffffffff00000000000000000000000000000000000000000000000000000000614357565b1592915050565b600080600061436685856148bf565b915091508180156143745750805b95945050505050565b600061218183836146b3565b6001600160a01b0382166143e4576040805162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015290519081900360640190fd5b6143ed81613ac3565b1561443f576040805162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015290519081900360640190fd5b61444b60008383611b2e565b6001600160a01b0382166000908152600360205260409020614473908263ffffffff6144d316565b506144866004828463ffffffff6144df16565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b5490565b60006121818383614a55565b600061218183836142a9565b6000613f9084846001600160a01b038516614b39565b815460009082106145375760405162461bcd60e51b8152600401808060200182810382526022815260200180614ef66022913960400191505060405180910390fd5b82600001828154811061454657fe5b9060005260206000200154905092915050565b6000612181836001600160a01b038416614a55565b8154600090819083106145b25760405162461bcd60e51b81526004018080602001828103825260228152602001806150ef6022913960400191505060405180910390fd5b60008460000184815481106145c357fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b600082815260018401602052604081205482816146845760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614649578181015183820152602001614631565b50505050905090810190601f1680156146765780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061469757fe5b9060005260206000209060020201600101549150509392505050565b60009081526001919091016020526040902054151590565b60006146df846001600160a01b0316614bd0565b6146eb57506001611b55565b60606148547f150b7a0200000000000000000000000000000000000000000000000000000000614719613ad6565b88878760405160240180856001600160a01b03166001600160a01b03168152602001846001600160a01b03166001600160a01b0316815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561479257818101518382015260200161477a565b50505050905090810190601f1680156147bf5780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051806060016040528060328152602001614f47603291396001600160a01b038816919063ffffffff614c0916565b9050600081806020019051602081101561486d57600080fd5b50517fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a02000000000000000000000000000000000000000000000000000000001492505050949350505050565b604080517fffffffff00000000000000000000000000000000000000000000000000000000831660248083019190915282518083039091018152604490910182526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f01ffc9a7000000000000000000000000000000000000000000000000000000001781529151815160009384939284926060926001600160a01b038a169261753092879282918083835b602083106149ab57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161496e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303818686fa925050503d8060008114614a0c576040519150601f19603f3d011682016040523d82523d6000602084013e614a11565b606091505b5091509150602081511015614a2f5760008094509450505050613f7c565b81818060200190516020811015614a4557600080fd5b5051909890975095505050505050565b60008181526001830160205260408120548015614b2f5783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8083019190810190600090879083908110614aa657fe5b9060005260206000200154905080876000018481548110614ac357fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080614af357fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612184565b6000915050612184565b600082815260018401602052604081205480614b9e575050604080518082018252838152602080820184815286546001818101895560008981528481209551600290930290950191825591519082015586548684528188019092529290912055613f93565b82856000016001830381548110614bb157fe5b9060005260206000209060020201600101819055506000915050613f93565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590611b55575050151592915050565b6060613f9084846000856060614c1e85614bd0565b614c6f576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614ccc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101614c8f565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614d2e576040519150601f19603f3d011682016040523d82523d6000602084013e614d33565b606091505b50915091508115614d47579150611b559050565b805115614d575780518082602001fd5b60405162461bcd60e51b8152602060048201818152865160248401528651879391928392604401919085019080838360008315614649578181015183820152602001614631565b604051806080016040528060006001600160a01b0316815260200160008152602001600081526020016000151581525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614e30578280017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00823516178555614e5d565b82800160010185558215614e5d579182015b82811115614e5d578235825591602001919060010190614e42565b50614e69929150614edb565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10614eae57805160ff1916838001178555614e5d565b82800160010185558215614e5d579182015b82811115614e5d578251825591602001919060010190614ec0565b61167e91905b80821115614e695760008155600101614ee156fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e744552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724672616d6520646f6573206e6f7420636f6e7461696e20616e7920636f6e74656e744552433732313a207472616e7366657220746f20746865207a65726f20616464726573734552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4661696c656420746f207472616e73666572207468652066756e64732c2061626f7274696e672e416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b6543616e6e6f74206368616e6765207472616974206861736820666f7220696e6465784552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4d6178696d756d206e756d626572206f66204e46547320666f72207068617365206d696e7465644552433732314d657461646174613a2055524920717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65725472616974206861736820616e6420696e6465786573206c656e677468206d69736d617463684672616d6520616c726561647920636f6e7461696e7320626f756e6420636f6e74656e744552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a264697066735822122086751b01f72f7132e768500354dce46c07164ea716cd82762673182edc49802e64736f6c634300060b003300000000000000000000000000000000000000000000000000000000000000600000000000000000000000002cee1ce61ec4068744719056453895d9fd0454f20000000000000000000000003c04121b05a156629b9f8b1b04c0f8f4e19312c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000cf90ad693ace601b5b5582c4f95ec7266cdb3eec0000000000000000000000009388517b36b817dccbb663a3097f4c5ffdbecc14000000000000000000000000f7a3bbe1711eb43967cdbf58fa61342a25e3c845

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

00000000000000000000000000000000000000000000000000000000000000600000000000000000000000002cee1ce61ec4068744719056453895d9fd0454f20000000000000000000000003c04121b05a156629b9f8b1b04c0f8f4e19312c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000cf90ad693ace601b5b5582c4f95ec7266cdb3eec0000000000000000000000009388517b36b817dccbb663a3097f4c5ffdbecc14000000000000000000000000f7a3bbe1711eb43967cdbf58fa61342a25e3c845

-----Decoded View---------------
Arg [0] : admins (address[]): 0xcf90ad693ace601b5b5582c4f95ec7266cdb3eec,0x9388517b36b817dccbb663a3097f4c5ffdbecc14,0xf7a3bbe1711eb43967cdbf58fa61342a25e3c845
Arg [1] : _mintManager (address): 0x2cee1ce61ec4068744719056453895d9fd0454f2
Arg [2] : _traitSeedManager (address): 0x3c04121b05a156629b9f8b1b04c0f8f4e19312c0

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [1] : 0000000000000000000000002cee1ce61ec4068744719056453895d9fd0454f2
Arg [2] : 0000000000000000000000003c04121b05a156629b9f8b1b04c0f8f4e19312c0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [4] : 000000000000000000000000cf90ad693ace601b5b5582c4f95ec7266cdb3eec
Arg [5] : 0000000000000000000000009388517b36b817dccbb663a3097f4c5ffdbecc14
Arg [6] : 000000000000000000000000f7a3bbe1711eb43967cdbf58fa61342a25e3c845


Block Transaction Difficulty Gas Used Reward
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.

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