ETH Price: $1,889.80 (-2.79%)
 

Overview

TokenID

27

Total Transfers

-

Market

Onchain Market Cap

$0.00

Circulating Supply Market Cap

-
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
MahinNFT

Compiler Version
v0.7.3+commit.9bfce1f6

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 23 : MahinNFT.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./ERC721.sol";
import "openzeppelin-solidity/contracts/access/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol";
import "./Roles.sol";
import "./Randomness.sol";
import "./Fees.sol";


contract MahinNFT is Roles, ERC721("Mahin", "MAHIN"), Randomness, HasFees  {
  event TokenDataStorage(
    uint256 indexed tokenId,
    bytes[] states
  );

  event Diagnosed(
    uint256 indexed tokenId
  );

  struct Piece {
    string name;
    bytes[] imageData;
    string[] ipfsHashes;
    string[] arweaveHashes;
    uint8 currentState;
  }

  // The beneficiary (the charity or someone acting in their name) - receives royalties.
  address public beneficiary;

  mapping(uint256 => Piece) public pieces;

  constructor(VRFConfig memory vrfConfig) Randomness(vrfConfig) {
  }

  function withdraw() public onlyOwner {
    address payable owner = payable(owner());
    owner.transfer(address(this).balance);
  }

  function withdrawToken(address tokenAddress) public onlyOwner {
    IERC20 token = IERC20(tokenAddress);
    token.transfer(owner(), token.balanceOf(address(this)));
  }

  // Returns the current SVG/PNG of the piece.
  function getImageData(uint256 tokenId) public view returns (bytes memory) {
    require(_exists(tokenId), "not a valid token");
    return pieces[tokenId].imageData[0];
  }

  function setImageData(uint256 tokenId, bytes calldata state1, bytes calldata state2) public onlyOwner {
    pieces[tokenId].imageData[0] = state1;
    pieces[tokenId].imageData[1] = state2;
  }

  // Will be used by the owner during setup to create all pieces of the work.
  // ipfsHashes - the ipfs location of each state - needed so provided an off-chain metadata url.
  function initToken(uint256 tokenId, string memory name, string[] memory arweaveHashes, string[] memory ipfsHashes) public onlyOwner {
    require(pieces[tokenId].ipfsHashes.length == 0, "invalid id");

    pieces[tokenId].name = name;
    pieces[tokenId].ipfsHashes = ipfsHashes;
    pieces[tokenId].arweaveHashes = arweaveHashes;
    pieces[tokenId].currentState = 0;
  }

  // Init multiple tokens at once
  function initTokens(uint256[] memory tokenIds, string[] memory names, string[][] memory arweaveHashSets, string[][] memory ipfsHashSets) public onlyOwner {
    for (uint256 i=0; i<tokenIds.length; i++) {
      uint256 tokenId = tokenIds[i];
      require(pieces[tokenId].ipfsHashes.length == 0, "invalid id");

      pieces[tokenId].name = names[i];
      pieces[tokenId].ipfsHashes = ipfsHashSets[i];
      pieces[tokenId].arweaveHashes = arweaveHashSets[i];
      pieces[tokenId].currentState = 0;
    }
  }

  // Allow contract owner&minter to mint a token and assigned to to anyone they please.
  function mintToken(uint256 tokenId, address firstOwner) public onlyMinterOrOwner {
    require(pieces[tokenId].ipfsHashes.length > 0, "invalid id");
    require(!_exists(tokenId), "exists");

    _mint(firstOwner, tokenId);
  }

  // Allow contract owner to set the IPFS host
  function setIPFSHost(string memory baseURI_) public onlyOwner {
    _setBaseURI(baseURI_);
  }

  function setBeneficiary(address _beneficiary) public onlyOwner {
    beneficiary = _beneficiary;
  }

  // Return the current IPFS link based on state
  function tokenURI(uint256 tokenId) public view override returns (string memory) {
    require(pieces[tokenId].ipfsHashes.length > 0, "invalid id");

    Piece memory piece = pieces[tokenId];
    string memory tokenPath = piece.ipfsHashes[piece.currentState];
    return string(abi.encodePacked(baseURI(), tokenPath));
  }

  function onDiagnosed(uint256 tokenId) internal override {
    pieces[tokenId].currentState = 1;
    emit Diagnosed(tokenId);
  }

  function diagnose(uint256 tokenId) public onlyDoctor {
    onDiagnosed(tokenId);
  }

  function getBeneficiary() internal override view returns (address) {
    return beneficiary;
  }

  function getFee(uint256 tokenId) override internal view returns (uint256) {
    if (pieces[tokenId].currentState >= 1) {
      return 15;
    } else {
      return 5;
    }
  }
}

File 2 of 23 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

// Copied from openzeppelin because we want to override the tokenURI() function

import "openzeppelin-solidity/contracts/GSN/Context.sol";
import "openzeppelin-solidity/contracts/token/ERC721/IERC721.sol";
import "openzeppelin-solidity/contracts/token/ERC721/IERC721Metadata.sol";
import "openzeppelin-solidity/contracts/token/ERC721/IERC721Enumerable.sol";
import "openzeppelin-solidity/contracts/token/ERC721/IERC721Receiver.sol";
import "openzeppelin-solidity/contracts/introspection/ERC165.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/utils/Address.sol";
import "openzeppelin-solidity/contracts/utils/EnumerableSet.sol";
import "openzeppelin-solidity/contracts/utils/EnumerableMap.sol";
import "openzeppelin-solidity/contracts/utils/Strings.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
abstract 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) internal _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 ^ 0xe985e9c5 ^ 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_) {
    _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 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 mechanisms to perform token transfer, such as signature-based.
   *
   * Requirements:
   *
   * - `from` cannot be the zero address.
   * - `to` cannot be the zero address.
   * - `tokenId` token must exist and be owned by `from`.
   * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
   *
   * Emits a {Transfer} event.
   */
  function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
    _transfer(from, to, tokenId);
    require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
  }

  /**
   * @dev Returns whether `tokenId` exists.
   *
   * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
   *
   * Tokens start existing when they are minted (`_mint`),
   * and stop existing when they are burned (`_burn`).
   */
  function _exists(uint256 tokenId) internal view 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 3 of 23 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

File 4 of 23 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `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 5 of 23 : Roles.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "openzeppelin-solidity/contracts/access/Ownable.sol";
import "openzeppelin-solidity/contracts/GSN/Context.sol";

/**
 * @dev Uses the Ownable class and adds a second role called the minter.
 *
 * Owner: Can upload tokens, withdraw lost tokens, config ipfs hashes etc. Can also mint tokens.
     Can set the other roles.
 * Minter: Can only mint tokens.
 * Doctor: If set, can diagnose pieces. Replaces the builtin rand gen.
 */
abstract contract Roles is Context, Ownable {
    address private _minter;
    address private _doctor;

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

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

    /**
     * @dev Returns the address of the doctor.
     */
    function doctor() public view returns (address) {
        return _doctor;
    }

    /**
     * @dev Throws if called by any account other than the minter.
     */
    modifier onlyMinter() {
        require(_minter == _msgSender(), "not minter");
        _;
    }

    /**
     * @dev Throws if called by any account other than the doctor.
     */
    modifier onlyDoctor() {
        require(_doctor == _msgSender(), "not doctor");
        _;
    }

    /**
     * @dev Throws if called by any account other than the minter or the owner.
     */
    modifier onlyMinterOrOwner() {
        require(_minter == _msgSender() || owner() == _msgSender(), "not minter or owner");
        _;
    }

    /**
     * @dev Transfers the minter role of the contract to a new account (`newMinter`).
     * Can only be called by the owner.
     */
    function setMinter(address newMinter) public virtual onlyOwner {
        require(newMinter != address(0), "zero address");
        _minter = newMinter;
    }

    /**
     * @dev Assigns the doctor role, replacing the builtin rng.
     */
    function setDoctor(address newDoctor) public virtual onlyOwner {
        require(newDoctor != address(0), "zero address");
        _doctor = newDoctor;
    }
}

File 6 of 23 : Randomness.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

//import "hardhat/console.sol";
import "./ABDKMath64x64.sol";
import "./ChainlinkVRF.sol";
import "openzeppelin-solidity/contracts/token/ERC721/IERC721Enumerable.sol";
import "./Roles.sol";


abstract contract Randomness is Roles, ChainlinkVRF, IERC721Enumerable {
    using SafeMath for uint256;

    // Configuration Chainlink VRF
    struct VRFConfig {
        address coordinator;
        address token;
        bytes32 keyHash;
        uint256 price;
    }

    event RollInProgress(
        int128 probability
    );

    event RollComplete();

    uint public constant projectRuntimeSeconds = 365 days * 5;   // Runs for 5 years
    uint public constant targetProbability     = 2000000000000000;  // 0.2% - over the course of the project
    uint public constant denominator           = 10000000000000000; // 100%
    // This has been pre-calculated based on the values above
    uint public constant probabilityPerSecond  = 14151671;        // 0.0000000014151671%

    uint256 randomSeedBlock = 0;
    int128 public rollProbability = 0;
    uint256 public lastRollTime = 0;

    bytes32 chainlinkRequestId = 0;
    uint256 chainlinkRandomNumber = 0;
    bytes32 internal chainlinkKeyHash;
    uint256 internal chainlinkFee;

    constructor(VRFConfig memory config) ChainlinkVRF(config.coordinator, config.token) {
        chainlinkFee = config.price;
        chainlinkKeyHash = config.keyHash;

        lastRollTime = block.timestamp;
    }

    // Will return the probability of a (non-)diagnosis for an individual NFT, assuming the roll will happen at
    // `timestamp`. This will be based on the last time a roll happened, targeting a certain total probability
    // over the period the project is running.
    // Will return 0.80 to indicate that the probability of a diagnosis is 20%.
    function getProbability(uint256 timestamp) public view returns (int128 probability) {
        uint256 secondsSinceLastRoll = timestamp.sub(lastRollTime);

        // Say we want totalProbability = 20% over the course of the project's runtime.
        // If we roll 12 times, what should be the probability of each roll so they compound to 20%?
        //    (1 - x) ** 12 = (1 - 20%)
        // Or generalized:
        //    (1 - x) ** numTries = (1 - totalProbability)
        // Solve by x:
        //     x = 1 - (1 - totalProbability) ** (1/numTries)
        //

        // We use the 64.64 fixed point math library here. More info about this kind of math in Solidity:
        // https://medium.com/hackernoon/10x-better-fixed-point-math-in-solidity-32441fd25d43
        // https://ethereum.stackexchange.com/questions/83785/what-fixed-or-float-point-math-libraries-are-available-in-solidity

        // We already pre-calculated the probability for a 1-second interval
        int128 _denominator = ABDKMath64x64.fromUInt(denominator);
        int128 _probabilityPerSecond = ABDKMath64x64.fromUInt(probabilityPerSecond);

        // From the *probability per second* number, calculate the probability for this dice roll based on
        // the number of seconds since the last roll. randomNumber must be larger than this.
        probability = ABDKMath64x64.pow(
        // Convert from our fraction using our denominator, to a 64.64 fixed point number
            ABDKMath64x64.div(
            // reverse-probability of x: (1-x)
                ABDKMath64x64.sub(
                    _denominator,
                    _probabilityPerSecond
                ),
                _denominator
            ),
            secondsSinceLastRoll
        );

        // `randomNumber / (2**64)` would now give us the random number as a 10-base decimal number.
        // To show it in Solidity, which does not support non-integers, we could multiply to shift the
        // decimal point, for example:
        //    console.log("randomNumber",
        //      uint256(ABDKMath64x64.toUInt(
        //        ABDKMath64x64.mul(randomNumber, ABDKMath64x64.fromUInt(1000000))
        //      ))
        //    );
    }

    // Anyone can roll, but the beneficiary is incentivized to do so.
    //
    // # When using Chainlink VRF:
    // Make sure you have previously funded the contract with LINK. Since anyone can start a request at
    // any time, do not prefund the contract; send the tokens when you want to enable a roll.
    //
    // # When using the blockhash-based fallback method:
    // A future block is picked, whose hash will provide the randomness.
    // We accept as low-impact that a miner mining this block could withhold it. A user seed/reveal system
    // to counteract miner withholding introduces too much complexity (need to penalize users etc).
    function requestRoll(bool useFallback) external {
        require(doctor() == address(0), "rng-disabled");

        // If a roll is already scheduled, do nothing.
        if (isRolling()) { return; }

        if (useFallback) {
            // Two blocks from now, the block hash will provide the randomness to decide the outcome
            randomSeedBlock = block.number + 2;
        }
        else {
            chainlinkRequestId = requestRandomness(chainlinkKeyHash, chainlinkFee, block.timestamp);
        }

        // Calculate the probability for this roll, based on the current lastRollTime, before we update the latter.
        rollProbability = getProbability(block.timestamp);

        // Set the last roll time, which "consumes" parts of the total probability for a diagnosis
        lastRollTime = block.timestamp;

        emit RollInProgress(rollProbability);
    }

    // Callback: randomness is returned from Chainlink VRF
    function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override {
        require(requestId == chainlinkRequestId, "invalid-request");
        chainlinkRandomNumber = randomness;
    }

    // Apply the results of the roll (run the randomness function, update NFTs).
    //
    // When using the block-hash based fallback randomness function:
    // If this is not called within 250 odd blocks, the hash of that block will no longer be accessible to us.
    // The roller thus has a possible reason *not* to call apply(), if the outcome is not as they desire.
    // We counteract this as follows:
    // - We consider an incomplete roll as a completed (which did not cause a state chance) for purposes of the
    //   compound probability. That is, you cannot increase the chance of any of the NFTs being diagnosed, you
    //   can only prevent it from happening. A caller looking to manipulate a roll would presumably desire a
    //   diagnosis, as they otherwise would simply do nothing.
    // - We counteract grieving (the repeated calling of pre-roll without calling apply, thus resetting the
    //   probability of a diagnosis) by letting anyone call `apply`, and emitting an event on `preroll`, to make
    //   it easy to watch for that.
    //
    // When using Chainlink VRF:
    //
    // In case we do not get a response from Chainlink within 2 hours, this can be called.
    //
    function applyRoll() external {
        require(isRolling(), "no-roll");

        bytes32 randomness;

        // Roll was started using the fallback random method based on the block hash
        if (randomSeedBlock > 0) {
            require(block.number > randomSeedBlock, "too-early");
            randomness = blockhash(randomSeedBlock);

            // The seed block is no longer available. We act as if the roll led to zero diagnoses.
            if (randomness <= 0) {
                resetRoll();
                return;
            }
        }

        // Roll was started using Chainlink VRF
        else {
            // No response from Chainlink
            if (chainlinkRandomNumber == 0 && block.timestamp - lastRollTime > 2 hours) {
                resetRoll();
                return;
            }

            require(chainlinkRandomNumber > 0, "too-early");
            randomness = bytes32(chainlinkRandomNumber);
        }

        _applyRandomness(randomness);
        resetRoll();
    }

    function _applyRandomness(bytes32 randomness) internal {
        for (uint i=0; i<this.totalSupply(); i++) {
            uint256 tokenId = this.tokenByIndex(i);

            // For each token, mix in the token id to get a new random number
            bytes32 hash = keccak256(abi.encodePacked(randomness, tokenId));

            // Now we want to convert the token hash to a number between 0 and 1.
            // - 64.64-bit fixed point is a int128  which represents the fraction `{int128}/(64**2)`.
            // - Thus, the lowest 64 bits of the int128 are essentially what is after the decimal point -
            //   the fractional part of the number.
            // - So taking only the lowest 64 bits from a token hash essentially gives us a random number
            //   between 0 and 1.

            // block hash is 256 bits - shift the left-most 64 bits into the right-most position, essentially
            // giving us a 64-bit number. Stored as an int128, this represents a fractional value between 0 and 1
            // in the format used by the 64.64 - fixed point library.
            int128 randomNumber = int128(uint256(hash) >> 192);
            //console.log("RANDOMNUMBER", uint256(randomNumber));

            if (randomNumber > rollProbability) {
                onDiagnosed(tokenId);
            }
        }
    }

    function resetRoll() internal {
        randomSeedBlock = 0;
        rollProbability = 0;
        chainlinkRequestId = 0;
        chainlinkRandomNumber = 0;
        emit RollComplete();
    }

    function isRolling() public view returns (bool) {
        return (randomSeedBlock > 0) || (chainlinkRequestId > 0);
    }

    function onDiagnosed(uint256 tokenId) internal virtual;
}

File 7 of 23 : Fees.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "openzeppelin-solidity/contracts/introspection/ERC165.sol";

abstract contract IRoyalities {
    function getBeneficiary() internal virtual view returns (address);
    // Value between 0 and 100 (0% to 100%).
    function getFee(uint256 tokenId) virtual internal view returns (uint256);
}

interface IRaribleFees is IERC165 {
    // Rarible emits this when minting, we don't bother.
    //event SecondarySaleFees(uint256 tokenId, address[] recipients, uint[] bps);

    function getFeeRecipients(uint256 id) external view returns (address payable[] memory);
    // 1000 = 10%
    function getFeeBps(uint256 id) external view returns (uint[] memory);
}

/**
 * @dev Implementation of royalties for 721s
 *
 */
interface IERC2981 is IERC165 {
    /*
     * ERC165 bytes to add to interface array - set in parent contract implementing this standard
     *
     * bytes4(keccak256('royaltyInfo()')) == 0x46e80720
     * bytes4 private constant _INTERFACE_ID_ERC721ROYALTIES = 0x46e80720;
     * _registerInterface(_INTERFACE_ID_ERC721ROYALTIES);
     */
    /**

    /**
     * @notice Called to return both the creator's address and the royalty percentage - this would be the main
     *   function called by marketplaces unless they specifically need just the royaltyAmount
     * @notice Percentage is calculated as a fixed point with a scaling factor of 10,000, such that 100% would be
     *   the value (1.000.000) where, 1.000.000/10.000 = 100. 1% would be the value 10.000/10.000 = 1
     */
    function royaltyInfo(uint256 _tokenId) external returns (address receiver, uint256 amount);
}

abstract contract HasFees is ERC165, IRaribleFees, IRoyalities, IERC2981 {
    /*
     * bytes4(keccak256('getFeeBps(uint256)')) == 0x0ebd4c7f
     * bytes4(keccak256('getFeeRecipients(uint256)')) == 0xb9c4d9fb
     *
     * => 0x0ebd4c7f ^ 0xb9c4d9fb == 0xb7799584
     */
    bytes4 private constant _INTERFACE_ID_RARIBLE_FEES = 0xb7799584;

    /*
     * ERC165 bytes to add to interface array - set in parent contract implementing this standard
     *
     * bytes4(keccak256('royaltyInfo()')) == 0x46e80720
     */
    bytes4 private constant _INTERFACE_ID_ERC721ROYALTIES = 0x46e80720;

    constructor() {
        _registerInterface(_INTERFACE_ID_RARIBLE_FEES);
        _registerInterface(_INTERFACE_ID_ERC721ROYALTIES);
    }

    function getFeeRecipients(uint256) public override view returns (address payable[] memory) {
        address payable[] memory recipients = new address payable[](1);
        recipients[0] = payable(address(this));
        return recipients;
    }
    function getFeeBps(uint256 id) public override view returns (uint[] memory) {
        uint[] memory fees = new uint[](1);
        fees[0] = getFee(id) * 100;
        return fees;
    }

    // Implements the current version of https://eips.ethereum.org/EIPS/eip-2981
    function royaltyInfo(uint256 _tokenId) external view override returns (address receiver, uint256 amount) {
        return (address(this), getFee(_tokenId) * 10000);
    }
}

File 8 of 23 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../utils/Context.sol";

File 9 of 23 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 10 of 23 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

import "./IERC721.sol";

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

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

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

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

File 11 of 23 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

import "./IERC721.sol";

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

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

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 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 12 of 23 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

File 13 of 23 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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.
 */
abstract 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 virtual 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 14 of 23 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

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

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

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

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

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        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");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        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, reverting 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) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

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

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

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * 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);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 15 of 23 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @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) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // 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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 16 of 23 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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.3.0, sets of type `bytes32` (`Bytes32Set`), `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];
    }

    // Bytes32Set

    struct Bytes32Set {
        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(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, 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(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

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

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set 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(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, 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(uint160(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(uint160(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(uint160(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(uint160(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 17 of 23 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.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 Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
        uint256 keyIndex = map._indexes[key];
        if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
        return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
    }

    /**
     * @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) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    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(uint160(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(uint160(uint256(value))));
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
        return (success, address(uint160(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(uint160(uint256(_get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
    }
}

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

pragma solidity >=0.6.0 <0.8.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--] = bytes1(uint8(48 + temp % 10));
            temp /= 10;
        }
        return string(buffer);
    }
}

File 19 of 23 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/*
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with 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 20 of 23 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

File 21 of 23 : ABDKMath64x64.sol
// SPDX-License-Identifier: BSD-4-Clause
/*
 * ABDK Math 64.64 Smart Contract Library.  Copyright © 2019 by ABDK Consulting.
 * Author: Mikhail Vladimirov <[email protected]>
 */
pragma solidity ^0.7.0;

/**
 * Smart contract library of mathematical functions operating with signed
 * 64.64-bit fixed point numbers.  Signed 64.64-bit fixed point number is
 * basically a simple fraction whose numerator is signed 128-bit integer and
 * denominator is 2^64.  As long as denominator is always the same, there is no
 * need to store it, thus in Solidity signed 64.64-bit fixed point numbers are
 * represented by int128 type holding only the numerator.
 */
library ABDKMath64x64 {
    /*
     * Minimum value signed 64.64-bit fixed point number may have.
     */
    int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;

    /*
     * Maximum value signed 64.64-bit fixed point number may have.
     */
    int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

    /**
     * Convert signed 256-bit integer number into signed 64.64-bit fixed point
     * number.  Revert on overflow.
     *
     * @param x signed 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function fromInt (int256 x) internal pure returns (int128) {
        require (x >= -0x8000000000000000 && x <= 0x7FFFFFFFFFFFFFFF);
        return int128 (x << 64);
    }

    /**
     * Convert signed 64.64 fixed point number into signed 64-bit integer number
     * rounding down.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64-bit integer number
     */
    function toInt (int128 x) internal pure returns (int64) {
        return int64 (x >> 64);
    }

    /**
     * Convert unsigned 256-bit integer number into signed 64.64-bit fixed point
     * number.  Revert on overflow.
     *
     * @param x unsigned 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function fromUInt (uint256 x) internal pure returns (int128) {
        require (x <= 0x7FFFFFFFFFFFFFFF);
        return int128 (x << 64);
    }

    /**
     * Convert signed 64.64 fixed point number into unsigned 64-bit integer
     * number rounding down.  Revert on underflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return unsigned 64-bit integer number
     */
    function toUInt (int128 x) internal pure returns (uint64) {
        require (x >= 0);
        return uint64 (x >> 64);
    }

    /**
     * Convert signed 128.128 fixed point number into signed 64.64-bit fixed point
     * number rounding down.  Revert on overflow.
     *
     * @param x signed 128.128-bin fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function from128x128 (int256 x) internal pure returns (int128) {
        int256 result = x >> 64;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }

    /**
     * Convert signed 64.64 fixed point number into signed 128.128 fixed point
     * number.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 128.128 fixed point number
     */
    function to128x128 (int128 x) internal pure returns (int256) {
        return int256 (x) << 64;
    }

    /**
     * Calculate x + y.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function add (int128 x, int128 y) internal pure returns (int128) {
        int256 result = int256(x) + y;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }

    /**
     * Calculate x - y.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function sub (int128 x, int128 y) internal pure returns (int128) {
        int256 result = int256(x) - y;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }

    /**
     * Calculate x * y rounding down.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function mul (int128 x, int128 y) internal pure returns (int128) {
        int256 result = int256(x) * y >> 64;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }

    /**
     * Calculate x * y rounding towards zero, where x is signed 64.64 fixed point
     * number and y is signed 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64 fixed point number
     * @param y signed 256-bit integer number
     * @return signed 256-bit integer number
     */
    function muli (int128 x, int256 y) internal pure returns (int256) {
        if (x == MIN_64x64) {
            require (y >= -0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF &&
            y <= 0x1000000000000000000000000000000000000000000000000);
            return -y << 63;
        } else {
            bool negativeResult = false;
            if (x < 0) {
                x = -x;
                negativeResult = true;
            }
            if (y < 0) {
                y = -y; // We rely on overflow behavior here
                negativeResult = !negativeResult;
            }
            uint256 absoluteResult = mulu (x, uint256 (y));
            if (negativeResult) {
                require (absoluteResult <=
                    0x8000000000000000000000000000000000000000000000000000000000000000);
                return -int256 (absoluteResult); // We rely on overflow behavior here
            } else {
                require (absoluteResult <=
                    0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
                return int256 (absoluteResult);
            }
        }
    }

    /**
     * Calculate x * y rounding down, where x is signed 64.64 fixed point number
     * and y is unsigned 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64 fixed point number
     * @param y unsigned 256-bit integer number
     * @return unsigned 256-bit integer number
     */
    function mulu (int128 x, uint256 y) internal pure returns (uint256) {
        if (y == 0) return 0;

        require (x >= 0);

        uint256 lo = (uint256 (x) * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
        uint256 hi = uint256 (x) * (y >> 128);

        require (hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
        hi <<= 64;

        require (hi <=
            0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - lo);
        return hi + lo;
    }

    /**
     * Calculate x / y rounding towards zero.  Revert on overflow or when y is
     * zero.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function div (int128 x, int128 y) internal pure returns (int128) {
        require (y != 0);
        int256 result = (int256 (x) << 64) / y;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are signed 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x signed 256-bit integer number
     * @param y signed 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function divi (int256 x, int256 y) internal pure returns (int128) {
        require (y != 0);

        bool negativeResult = false;
        if (x < 0) {
            x = -x; // We rely on overflow behavior here
            negativeResult = true;
        }
        if (y < 0) {
            y = -y; // We rely on overflow behavior here
            negativeResult = !negativeResult;
        }
        uint128 absoluteResult = divuu (uint256 (x), uint256 (y));
        if (negativeResult) {
            require (absoluteResult <= 0x80000000000000000000000000000000);
            return -int128 (absoluteResult); // We rely on overflow behavior here
        } else {
            require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
            return int128 (absoluteResult); // We rely on overflow behavior here
        }
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x unsigned 256-bit integer number
     * @param y unsigned 256-bit integer number
     * @return signed 64.64-bit fixed point number
     */
    function divu (uint256 x, uint256 y) internal pure returns (int128) {
        require (y != 0);
        uint128 result = divuu (x, y);
        require (result <= uint128 (MAX_64x64));
        return int128 (result);
    }

    /**
     * Calculate -x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function neg (int128 x) internal pure returns (int128) {
        require (x != MIN_64x64);
        return -x;
    }

    /**
     * Calculate |x|.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function abs (int128 x) internal pure returns (int128) {
        require (x != MIN_64x64);
        return x < 0 ? -x : x;
    }

    /**
     * Calculate 1 / x rounding towards zero.  Revert on overflow or when x is
     * zero.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function inv (int128 x) internal pure returns (int128) {
        require (x != 0);
        int256 result = int256 (0x100000000000000000000000000000000) / x;
        require (result >= MIN_64x64 && result <= MAX_64x64);
        return int128 (result);
    }

    /**
     * Calculate arithmetics average of x and y, i.e. (x + y) / 2 rounding down.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function avg (int128 x, int128 y) internal pure returns (int128) {
        return int128 ((int256 (x) + int256 (y)) >> 1);
    }

    /**
     * Calculate geometric average of x and y, i.e. sqrt (x * y) rounding down.
     * Revert on overflow or in case x * y is negative.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function gavg (int128 x, int128 y) internal pure returns (int128) {
        int256 m = int256 (x) * int256 (y);
        require (m >= 0);
        require (m <
            0x4000000000000000000000000000000000000000000000000000000000000000);
        return int128 (sqrtu (uint256 (m)));
    }

    /**
     * Calculate x^y assuming 0^0 is 1, where x is signed 64.64 fixed point number
     * and y is unsigned 256-bit integer number.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @param y uint256 value
     * @return signed 64.64-bit fixed point number
     */
    function pow (int128 x, uint256 y) internal pure returns (int128) {
        uint256 absoluteResult;
        bool negativeResult = false;
        if (x >= 0) {
            absoluteResult = powu (uint256 (x) << 63, y);
        } else {
            // We rely on overflow behavior here
            absoluteResult = powu (uint256 (uint128 (-x)) << 63, y);
            negativeResult = y & 1 > 0;
        }

        absoluteResult >>= 63;

        if (negativeResult) {
            require (absoluteResult <= 0x80000000000000000000000000000000);
            return -int128 (absoluteResult); // We rely on overflow behavior here
        } else {
            require (absoluteResult <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
            return int128 (absoluteResult); // We rely on overflow behavior here
        }
    }

    /**
     * Calculate sqrt (x) rounding down.  Revert if x < 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function sqrt (int128 x) internal pure returns (int128) {
        require (x >= 0);
        return int128 (sqrtu (uint256 (x) << 64));
    }

    /**
     * Calculate binary logarithm of x.  Revert if x <= 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function log_2 (int128 x) internal pure returns (int128) {
        require (x > 0);

        int256 msb = 0;
        int256 xc = x;
        if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
        if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
        if (xc >= 0x10000) { xc >>= 16; msb += 16; }
        if (xc >= 0x100) { xc >>= 8; msb += 8; }
        if (xc >= 0x10) { xc >>= 4; msb += 4; }
        if (xc >= 0x4) { xc >>= 2; msb += 2; }
        if (xc >= 0x2) msb += 1;  // No need to shift xc anymore

        int256 result = msb - 64 << 64;
        uint256 ux = uint256 (x) << uint256 (127 - msb);
        for (int256 bit = 0x8000000000000000; bit > 0; bit >>= 1) {
            ux *= ux;
            uint256 b = ux >> 255;
            ux >>= 127 + b;
            result += bit * int256 (b);
        }

        return int128 (result);
    }

    /**
     * Calculate natural logarithm of x.  Revert if x <= 0.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function ln (int128 x) internal pure returns (int128) {
        require (x > 0);

        return int128 (
            uint256 (log_2 (x)) * 0xB17217F7D1CF79ABC9E3B39803F2F6AF >> 128);
    }

    /**
     * Calculate binary exponent of x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function exp_2 (int128 x) internal pure returns (int128) {
        require (x < 0x400000000000000000); // Overflow

        if (x < -0x400000000000000000) return 0; // Underflow

        uint256 result = 0x80000000000000000000000000000000;

        if (x & 0x8000000000000000 > 0)
            result = result * 0x16A09E667F3BCC908B2FB1366EA957D3E >> 128;
        if (x & 0x4000000000000000 > 0)
            result = result * 0x1306FE0A31B7152DE8D5A46305C85EDEC >> 128;
        if (x & 0x2000000000000000 > 0)
            result = result * 0x1172B83C7D517ADCDF7C8C50EB14A791F >> 128;
        if (x & 0x1000000000000000 > 0)
            result = result * 0x10B5586CF9890F6298B92B71842A98363 >> 128;
        if (x & 0x800000000000000 > 0)
            result = result * 0x1059B0D31585743AE7C548EB68CA417FD >> 128;
        if (x & 0x400000000000000 > 0)
            result = result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8 >> 128;
        if (x & 0x200000000000000 > 0)
            result = result * 0x10163DA9FB33356D84A66AE336DCDFA3F >> 128;
        if (x & 0x100000000000000 > 0)
            result = result * 0x100B1AFA5ABCBED6129AB13EC11DC9543 >> 128;
        if (x & 0x80000000000000 > 0)
            result = result * 0x10058C86DA1C09EA1FF19D294CF2F679B >> 128;
        if (x & 0x40000000000000 > 0)
            result = result * 0x1002C605E2E8CEC506D21BFC89A23A00F >> 128;
        if (x & 0x20000000000000 > 0)
            result = result * 0x100162F3904051FA128BCA9C55C31E5DF >> 128;
        if (x & 0x10000000000000 > 0)
            result = result * 0x1000B175EFFDC76BA38E31671CA939725 >> 128;
        if (x & 0x8000000000000 > 0)
            result = result * 0x100058BA01FB9F96D6CACD4B180917C3D >> 128;
        if (x & 0x4000000000000 > 0)
            result = result * 0x10002C5CC37DA9491D0985C348C68E7B3 >> 128;
        if (x & 0x2000000000000 > 0)
            result = result * 0x1000162E525EE054754457D5995292026 >> 128;
        if (x & 0x1000000000000 > 0)
            result = result * 0x10000B17255775C040618BF4A4ADE83FC >> 128;
        if (x & 0x800000000000 > 0)
            result = result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB >> 128;
        if (x & 0x400000000000 > 0)
            result = result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9 >> 128;
        if (x & 0x200000000000 > 0)
            result = result * 0x10000162E43F4F831060E02D839A9D16D >> 128;
        if (x & 0x100000000000 > 0)
            result = result * 0x100000B1721BCFC99D9F890EA06911763 >> 128;
        if (x & 0x80000000000 > 0)
            result = result * 0x10000058B90CF1E6D97F9CA14DBCC1628 >> 128;
        if (x & 0x40000000000 > 0)
            result = result * 0x1000002C5C863B73F016468F6BAC5CA2B >> 128;
        if (x & 0x20000000000 > 0)
            result = result * 0x100000162E430E5A18F6119E3C02282A5 >> 128;
        if (x & 0x10000000000 > 0)
            result = result * 0x1000000B1721835514B86E6D96EFD1BFE >> 128;
        if (x & 0x8000000000 > 0)
            result = result * 0x100000058B90C0B48C6BE5DF846C5B2EF >> 128;
        if (x & 0x4000000000 > 0)
            result = result * 0x10000002C5C8601CC6B9E94213C72737A >> 128;
        if (x & 0x2000000000 > 0)
            result = result * 0x1000000162E42FFF037DF38AA2B219F06 >> 128;
        if (x & 0x1000000000 > 0)
            result = result * 0x10000000B17217FBA9C739AA5819F44F9 >> 128;
        if (x & 0x800000000 > 0)
            result = result * 0x1000000058B90BFCDEE5ACD3C1CEDC823 >> 128;
        if (x & 0x400000000 > 0)
            result = result * 0x100000002C5C85FE31F35A6A30DA1BE50 >> 128;
        if (x & 0x200000000 > 0)
            result = result * 0x10000000162E42FF0999CE3541B9FFFCF >> 128;
        if (x & 0x100000000 > 0)
            result = result * 0x100000000B17217F80F4EF5AADDA45554 >> 128;
        if (x & 0x80000000 > 0)
            result = result * 0x10000000058B90BFBF8479BD5A81B51AD >> 128;
        if (x & 0x40000000 > 0)
            result = result * 0x1000000002C5C85FDF84BD62AE30A74CC >> 128;
        if (x & 0x20000000 > 0)
            result = result * 0x100000000162E42FEFB2FED257559BDAA >> 128;
        if (x & 0x10000000 > 0)
            result = result * 0x1000000000B17217F7D5A7716BBA4A9AE >> 128;
        if (x & 0x8000000 > 0)
            result = result * 0x100000000058B90BFBE9DDBAC5E109CCE >> 128;
        if (x & 0x4000000 > 0)
            result = result * 0x10000000002C5C85FDF4B15DE6F17EB0D >> 128;
        if (x & 0x2000000 > 0)
            result = result * 0x1000000000162E42FEFA494F1478FDE05 >> 128;
        if (x & 0x1000000 > 0)
            result = result * 0x10000000000B17217F7D20CF927C8E94C >> 128;
        if (x & 0x800000 > 0)
            result = result * 0x1000000000058B90BFBE8F71CB4E4B33D >> 128;
        if (x & 0x400000 > 0)
            result = result * 0x100000000002C5C85FDF477B662B26945 >> 128;
        if (x & 0x200000 > 0)
            result = result * 0x10000000000162E42FEFA3AE53369388C >> 128;
        if (x & 0x100000 > 0)
            result = result * 0x100000000000B17217F7D1D351A389D40 >> 128;
        if (x & 0x80000 > 0)
            result = result * 0x10000000000058B90BFBE8E8B2D3D4EDE >> 128;
        if (x & 0x40000 > 0)
            result = result * 0x1000000000002C5C85FDF4741BEA6E77E >> 128;
        if (x & 0x20000 > 0)
            result = result * 0x100000000000162E42FEFA39FE95583C2 >> 128;
        if (x & 0x10000 > 0)
            result = result * 0x1000000000000B17217F7D1CFB72B45E1 >> 128;
        if (x & 0x8000 > 0)
            result = result * 0x100000000000058B90BFBE8E7CC35C3F0 >> 128;
        if (x & 0x4000 > 0)
            result = result * 0x10000000000002C5C85FDF473E242EA38 >> 128;
        if (x & 0x2000 > 0)
            result = result * 0x1000000000000162E42FEFA39F02B772C >> 128;
        if (x & 0x1000 > 0)
            result = result * 0x10000000000000B17217F7D1CF7D83C1A >> 128;
        if (x & 0x800 > 0)
            result = result * 0x1000000000000058B90BFBE8E7BDCBE2E >> 128;
        if (x & 0x400 > 0)
            result = result * 0x100000000000002C5C85FDF473DEA871F >> 128;
        if (x & 0x200 > 0)
            result = result * 0x10000000000000162E42FEFA39EF44D91 >> 128;
        if (x & 0x100 > 0)
            result = result * 0x100000000000000B17217F7D1CF79E949 >> 128;
        if (x & 0x80 > 0)
            result = result * 0x10000000000000058B90BFBE8E7BCE544 >> 128;
        if (x & 0x40 > 0)
            result = result * 0x1000000000000002C5C85FDF473DE6ECA >> 128;
        if (x & 0x20 > 0)
            result = result * 0x100000000000000162E42FEFA39EF366F >> 128;
        if (x & 0x10 > 0)
            result = result * 0x1000000000000000B17217F7D1CF79AFA >> 128;
        if (x & 0x8 > 0)
            result = result * 0x100000000000000058B90BFBE8E7BCD6D >> 128;
        if (x & 0x4 > 0)
            result = result * 0x10000000000000002C5C85FDF473DE6B2 >> 128;
        if (x & 0x2 > 0)
            result = result * 0x1000000000000000162E42FEFA39EF358 >> 128;
        if (x & 0x1 > 0)
            result = result * 0x10000000000000000B17217F7D1CF79AB >> 128;

        result >>= uint256 (63 - (x >> 64));
        require (result <= uint256 (MAX_64x64));

        return int128 (result);
    }

    /**
     * Calculate natural exponent of x.  Revert on overflow.
     *
     * @param x signed 64.64-bit fixed point number
     * @return signed 64.64-bit fixed point number
     */
    function exp (int128 x) internal pure returns (int128) {
        require (x < 0x400000000000000000); // Overflow

        if (x < -0x400000000000000000) return 0; // Underflow

        return exp_2 (
            int128 (int256 (x) * 0x171547652B82FE1777D0FFDA0D23A7D12 >> 128));
    }

    /**
     * Calculate x / y rounding towards zero, where x and y are unsigned 256-bit
     * integer numbers.  Revert on overflow or when y is zero.
     *
     * @param x unsigned 256-bit integer number
     * @param y unsigned 256-bit integer number
     * @return unsigned 64.64-bit fixed point number
     */
    function divuu (uint256 x, uint256 y) private pure returns (uint128) {
        require (y != 0);

        uint256 result;

        if (x <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
            result = (x << 64) / y;
        else {
            uint256 msb = 192;
            uint256 xc = x >> 192;
            if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
            if (xc >= 0x10000) { xc >>= 16; msb += 16; }
            if (xc >= 0x100) { xc >>= 8; msb += 8; }
            if (xc >= 0x10) { xc >>= 4; msb += 4; }
            if (xc >= 0x4) { xc >>= 2; msb += 2; }
            if (xc >= 0x2) msb += 1;  // No need to shift xc anymore

            result = (x << 255 - msb) / ((y - 1 >> msb - 191) + 1);
            require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

            uint256 hi = result * (y >> 128);
            uint256 lo = result * (y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);

            uint256 xh = x >> 192;
            uint256 xl = x << 64;

            if (xl < lo) xh -= 1;
            xl -= lo; // We rely on overflow behavior here
            lo = hi << 128;
            if (xl < lo) xh -= 1;
            xl -= lo; // We rely on overflow behavior here

            assert (xh == hi >> 128);

            result += xl / y;
        }

        require (result <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
        return uint128 (result);
    }

    /**
     * Calculate x^y assuming 0^0 is 1, where x is unsigned 129.127 fixed point
     * number and y is unsigned 256-bit integer number.  Revert on overflow.
     *
     * @param x unsigned 129.127-bit fixed point number
     * @param y uint256 value
     * @return unsigned 129.127-bit fixed point number
     */
    function powu (uint256 x, uint256 y) private pure returns (uint256) {
        if (y == 0) return 0x80000000000000000000000000000000;
        else if (x == 0) return 0;
        else {
            int256 msb = 0;
            uint256 xc = x;
            if (xc >= 0x100000000000000000000000000000000) { xc >>= 128; msb += 128; }
            if (xc >= 0x10000000000000000) { xc >>= 64; msb += 64; }
            if (xc >= 0x100000000) { xc >>= 32; msb += 32; }
            if (xc >= 0x10000) { xc >>= 16; msb += 16; }
            if (xc >= 0x100) { xc >>= 8; msb += 8; }
            if (xc >= 0x10) { xc >>= 4; msb += 4; }
            if (xc >= 0x4) { xc >>= 2; msb += 2; }
            if (xc >= 0x2) msb += 1;  // No need to shift xc anymore

            int256 xe = msb - 127;
            if (xe > 0) x >>= uint256 (xe);
            else x <<= uint256 (-xe);

            uint256 result = 0x80000000000000000000000000000000;
            int256 re = 0;

            while (y > 0) {
                if (y & 1 > 0) {
                    result = result * x;
                    y -= 1;
                    re += xe;
                    if (result >=
                        0x8000000000000000000000000000000000000000000000000000000000000000) {
                        result >>= 128;
                        re += 1;
                    } else result >>= 127;
                    if (re < -127) return 0; // Underflow
                    require (re < 128); // Overflow
                } else {
                    x = x * x;
                    y >>= 1;
                    xe <<= 1;
                    if (x >=
                        0x8000000000000000000000000000000000000000000000000000000000000000) {
                        x >>= 128;
                        xe += 1;
                    } else x >>= 127;
                    if (xe < -127) return 0; // Underflow
                    require (xe < 128); // Overflow
                }
            }

            if (re > 0) result <<= uint256 (re);
            else if (re < 0) result >>= uint256 (-re);

            return result;
        }
    }

    /**
     * Calculate sqrt (x) rounding down, where x is unsigned 256-bit integer
     * number.
     *
     * @param x unsigned 256-bit integer number
     * @return unsigned 128-bit integer number
     */
    function sqrtu (uint256 x) private pure returns (uint128) {
        if (x == 0) return 0;
        else {
            uint256 xx = x;
            uint256 r = 1;
            if (xx >= 0x100000000000000000000000000000000) { xx >>= 128; r <<= 64; }
            if (xx >= 0x10000000000000000) { xx >>= 64; r <<= 32; }
            if (xx >= 0x100000000) { xx >>= 32; r <<= 16; }
            if (xx >= 0x10000) { xx >>= 16; r <<= 8; }
            if (xx >= 0x100) { xx >>= 8; r <<= 4; }
            if (xx >= 0x10) { xx >>= 4; r <<= 2; }
            if (xx >= 0x8) { r <<= 1; }
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1;
            r = (r + x / r) >> 1; // Seven iterations should be enough
            uint256 r1 = x / r;
            return uint128 (r < r1 ? r : r1);
        }
    }
}

File 22 of 23 : ChainlinkVRF.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "./LinkTokenInterface.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";


// See VRFConsumerBase.sol and VRFRequestIDBase.sol from Chainlink.
abstract contract ChainlinkVRF {
    using SafeMath for uint256;

    /**
     * @notice fulfillRandomness handles the VRF response.
     */
    function fulfillRandomness(bytes32 requestId, uint256 randomness) internal virtual;

    /**
     * @notice requestRandomness initiates a request for VRF output given _seed
     */
    function requestRandomness(bytes32 _keyHash, uint256 _fee, uint256 _seed)  internal returns (bytes32 requestId)
    {
        LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, _seed));
        // 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, _seed, 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) {
        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);
    }

    /**
   * @notice returns the seed which is actually input to the VRF coordinator
   */
    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
     */
    function makeRequestId(bytes32 _keyHash, uint256 _vRFInputSeed) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed));
    }
}

File 23 of 23 : LinkTokenInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.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);
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"components":[{"internalType":"address","name":"coordinator","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"internalType":"uint256","name":"price","type":"uint256"}],"internalType":"struct Randomness.VRFConfig","name":"vrfConfig","type":"tuple"}],"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":"tokenId","type":"uint256"}],"name":"Diagnosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"RollComplete","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"int128","name":"probability","type":"int128"}],"name":"RollInProgress","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bytes[]","name":"states","type":"bytes[]"}],"name":"TokenDataStorage","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"},{"inputs":[],"name":"applyRoll","outputs":[],"stateMutability":"nonpayable","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":"beneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"denominator","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"diagnose","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"doctor","outputs":[{"internalType":"address","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":"uint256","name":"id","type":"uint256"}],"name":"getFeeBps","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"getFeeRecipients","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getImageData","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"getProbability","outputs":[{"internalType":"int128","name":"probability","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string[]","name":"arweaveHashes","type":"string[]"},{"internalType":"string[]","name":"ipfsHashes","type":"string[]"}],"name":"initToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"string[][]","name":"arweaveHashSets","type":"string[][]"},{"internalType":"string[][]","name":"ipfsHashSets","type":"string[][]"}],"name":"initTokens","outputs":[],"stateMutability":"nonpayable","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":[],"name":"isRolling","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastRollTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"firstOwner","type":"address"}],"name":"mintToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","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":"","type":"uint256"}],"name":"pieces","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint8","name":"currentState","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"probabilityPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"projectRuntimeSeconds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"},{"internalType":"uint256","name":"randomness","type":"uint256"}],"name":"rawFulfillRandomness","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"useFallback","type":"bool"}],"name":"requestRoll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollProbability","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","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":"address","name":"_beneficiary","type":"address"}],"name":"setBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newDoctor","type":"address"}],"name":"setDoctor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI_","type":"string"}],"name":"setIPFSHost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"state1","type":"bytes"},{"internalType":"bytes","name":"state2","type":"bytes"}],"name":"setImageData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newMinter","type":"address"}],"name":"setMinter","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":[],"name":"targetProbability","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"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","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040526000600e819055600f80546001600160801b0319169055601081905560118190556012553480156200003557600080fd5b50604051620041e5380380620041e5833981016040819052620000589162000318565b806040518060400160405280600581526020016426b0b434b760d91b8152506040518060400160405280600581526020016426a0a424a760d91b815250826000015183602001516000620000b16200020060201b60201c565b600080546001600160a01b0319166001600160a01b038316908117825560405192935091600080516020620041c5833981519152908290a3506000620000f662000200565b600180546001600160a01b0319166001600160a01b03831690811790915560405191925090600090600080516020620041c5833981519152908290a3506001600160601b0319606092831b811660a052911b166080526200015e6301ffc9a760e01b62000204565b81516200017390600a9060208501906200025f565b5080516200018990600b9060208401906200025f565b506200019c6380ac58cd60e01b62000204565b620001ae635b5e139f60e01b62000204565b620001c063780e9d6360e01b62000204565b505060608101516014556040015160135542601055620001e7632dde656160e21b62000204565b620001f9630237403960e51b62000204565b50620003bf565b3390565b6001600160e01b031980821614156200023a5760405162461bcd60e51b8152600401620002319062000388565b60405180910390fd5b6001600160e01b0319166000908152600460205260409020805460ff19166001179055565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620002a257805160ff1916838001178555620002d2565b82800160010185558215620002d2579182015b82811115620002d2578251825591602001919060010190620002b5565b50620002e0929150620002e4565b5090565b5b80821115620002e05760008155600101620002e5565b80516001600160a01b03811681146200031357600080fd5b919050565b6000608082840312156200032a578081fd5b604051608081016001600160401b03811182821017156200034757fe5b6040526200035583620002fb565b81526200036560208401620002fb565b602082015260408301516040820152606083015160608201528091505092915050565b6020808252601c908201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604082015260600190565b60805160601c60a05160601c613dd7620003ee60003980611334528061237c52508061234d5250613dd76000f3fe608060405234801561001057600080fd5b50600436106102d65760003560e01c806370a0823111610182578063a140ae23116100e9578063c87b56dd116100a2578063e2d0f04a1161007c578063e2d0f04a14610601578063e985e9c514610614578063f2fde38b14610627578063fca3b5aa1461063a576102d6565b8063c87b56dd146105c5578063cb565320146105d8578063cef6d368146105e0576102d6565b8063a140ae2314610546578063a22cb46514610559578063aa25f47b1461056c578063b48c7fb21461057f578063b88d4fde14610592578063b9c4d9fb146105a5576102d6565b8063894760691161013b57806389476069146104e75780638da5cb5b146104fa5780638f64be301461050257806394985ddd1461052357806395d89b411461053657806396ce07951461053e576102d6565b806370a082311461048b578063715018a61461049e57806374120c5c146104a6578063791b2123146104b95780637ea7118c146104cc5780638362a342146104d4576102d6565b80633bd8094111610241578063503475a3116101fa5780636352211e116101d45780636352211e14610448578063663a93951461045b5780636b2e90e21461046e5780636c0360eb14610483576102d6565b8063503475a314610425578063529ca2071461042d57806358411a1a14610440576102d6565b80633bd80941146103d45780633ccfd60b146103dc57806342842e0e146103e457806348103e65146103f7578063497027911461040a5780634f6ccce714610412576102d6565b806318160ddd1161029357806318160ddd146103765780631c31f7101461038b57806323b872dd1461039e5780632f745c59146103b1578063361464d8146103c457806338af3eed146103cc576102d6565b806301ffc9a7146102db57806306fdde03146103045780630754617214610319578063081812fc1461032e578063095ea7b3146103415780630ebd4c7f14610356575b600080fd5b6102ee6102e936600461323e565b61064d565b6040516102fb919061358f565b60405180910390f35b61030c610670565b6040516102fb91906135be565b610321610706565b6040516102fb9190613479565b61032161033c3660046132a9565b610715565b61035461034f3660046130c7565b610761565b005b6103696103643660046132a9565b6107f9565b6040516102fb9190613557565b61037e610848565b6040516102fb9190613cab565b610354610399366004612fa4565b610859565b6103546103ac366004612ff0565b6108ba565b61037e6103bf3660046130c7565b6108f2565b61037e61091d565b610321610925565b61037e610934565b61035461093a565b6103546103f2366004612ff0565b6109bf565b610354610405366004612fa4565b6109da565b610354610a61565b61037e6104203660046132a9565b610b2c565b61037e610b42565b61030c61043b3660046132a9565b610b4d565b61037e610c2a565b6103216104563660046132a9565b610c31565b6103546104693660046132fb565b610c59565b610476610d11565b6040516102fb91906135d1565b61030c610d1a565b61037e610499366004612fa4565b610d7b565b610354610dc4565b6103546104b43660046130f0565b610e4d565b6104766104c73660046132a9565b610fc4565b610321611027565b6103546104e2366004613372565b611036565b6103546104f5366004612fa4565b61112e565b610321611270565b6105156105103660046132a9565b61127f565b6040516102fb9291906135df565b61035461053136600461321d565b611329565b61030c61137b565b61037e6113dc565b6103546105543660046132d9565b6113e7565b610354610567366004613091565b6114a4565b61035461057a3660046131e5565b611572565b61035461058d3660046132a9565b611645565b6103546105a036600461302b565b611683565b6105b86105b33660046132a9565b6116c2565b6040516102fb919061350a565b61030c6105d33660046132a9565b611714565b6102ee611af0565b6105f36105ee3660046132a9565b611b06565b6040516102fb9291906134ca565b61035461060f366004613276565b611b20565b6102ee610622366004612fbe565b611b68565b610354610635366004612fa4565b611b96565b610354610648366004612fa4565b611c56565b6001600160e01b0319811660009081526004602052604090205460ff165b919050565b600a8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106fc5780601f106106d1576101008083540402835291602001916106fc565b820191906000526020600020905b8154815290600101906020018083116106df57829003601f168201915b5050505050905090565b6001546001600160a01b031690565b600061072082611cdd565b6107455760405162461bcd60e51b815260040161073c90613a2d565b60405180910390fd5b506000908152600860205260409020546001600160a01b031690565b600061076c82610c31565b9050806001600160a01b0316836001600160a01b031614156107a05760405162461bcd60e51b815260040161073c90613b9e565b806001600160a01b03166107b2611cea565b6001600160a01b031614806107ce57506107ce81610622611cea565b6107ea5760405162461bcd60e51b815260040161073c9061390f565b6107f48383611cee565b505050565b6040805160018082528183019092526060918291906020808301908036833701905050905061082783611d5c565b6064028160008151811061083757fe5b602090810291909101015292915050565b60006108546006611d8a565b905090565b610861611cea565b6001600160a01b0316610872611270565b6001600160a01b0316146108985760405162461bcd60e51b815260040161073c90613a79565b601580546001600160a01b0319166001600160a01b0392909216919091179055565b6108cb6108c5611cea565b82611d95565b6108e75760405162461bcd60e51b815260040161073c90613c00565b6107f4838383611e1a565b6001600160a01b03821660009081526005602052604081206109149083611f28565b90505b92915050565b630966018081565b6015546001600160a01b031681565b60105481565b610942611cea565b6001600160a01b0316610953611270565b6001600160a01b0316146109795760405162461bcd60e51b815260040161073c90613a79565b6000610983611270565b6040519091506001600160a01b038216904780156108fc02916000818181858888f193505050501580156109bb573d6000803e3d6000fd5b5050565b6107f483838360405180602001604052806000815250611683565b6109e2611cea565b6001600160a01b03166109f3611270565b6001600160a01b031614610a195760405162461bcd60e51b815260040161073c90613a79565b6001600160a01b038116610a3f5760405162461bcd60e51b815260040161073c90613b41565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610a69611af0565b610a855760405162461bcd60e51b815260040161073c90613bdf565b600e5460009015610ace57600e544311610ab15760405162461bcd60e51b815260040161073c90613c88565b50600e544080610ac957610ac3611f34565b50610b2a565b610b17565b601254158015610ae35750611c206010544203115b15610af057610ac3611f34565b600060125411610b125760405162461bcd60e51b815260040161073c90613c88565b506012545b610b2081611f7e565b610b28611f34565b505b565b600080610b3a6006846120cd565b509392505050565b66071afd498d000081565b6060610b5882611cdd565b610b745760405162461bcd60e51b815260040161073c90613861565b60008281526016602052604081206001018054909190610b9057fe5b600091825260209182902001805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015610c1e5780601f10610bf357610100808354040283529160200191610c1e565b820191906000526020600020905b815481529060010190602001808311610c0157829003601f168201915b50505050509050919050565b62d7eff781565b600061091782604051806060016040528060298152602001613d7960299139600691906120eb565b610c61611cea565b6001600160a01b0316610c72611270565b6001600160a01b031614610c985760405162461bcd60e51b815260040161073c90613a79565b600085815260166020526040812060010180548692869291610cb657fe5b906000526020600020019190610ccd929190612c39565b50818160166000888152602001908152602001600020600101600181548110610cf257fe5b906000526020600020019190610d09929190612c39565b505050505050565b600f8054900b81565b600d8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106fc5780601f106106d1576101008083540402835291602001916106fc565b60006001600160a01b038216610da35760405162461bcd60e51b815260040161073c9061396c565b6001600160a01b038216600090815260056020526040902061091790611d8a565b610dcc611cea565b6001600160a01b0316610ddd611270565b6001600160a01b031614610e035760405162461bcd60e51b815260040161073c90613a79565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b610e55611cea565b6001600160a01b0316610e66611270565b6001600160a01b031614610e8c5760405162461bcd60e51b815260040161073c90613a79565b60005b8451811015610fbd576000858281518110610ea657fe5b602002602001015190506016600082815260200190815260200160002060020180549050600014610ee95760405162461bcd60e51b815260040161073c90613735565b848281518110610ef557fe5b602090810291909101810151600083815260168352604090208151610f1f93919290910190612cb7565b50828281518110610f2c57fe5b6020026020010151601660008381526020019081526020016000206002019080519060200190610f5d929190612d25565b50838281518110610f6a57fe5b6020026020010151601660008381526020019081526020016000206003019080519060200190610f9b929190612d25565b506000908152601660205260409020600401805460ff19169055600101610e8f565b5050505050565b600080610fdc6010548461210290919063ffffffff16565b90506000610ff0662386f26fc1000061212a565b9050600061100062d7eff761212a565b905061101e6110186110128484612148565b8461217c565b846121ce565b95945050505050565b6002546001600160a01b031690565b61103e611cea565b6001600160a01b031661104f611270565b6001600160a01b0316146110755760405162461bcd60e51b815260040161073c90613a79565b600084815260166020526040902060020154156110a45760405162461bcd60e51b815260040161073c90613735565b600084815260166020908152604090912084516110c392860190612cb7565b50600084815260166020908152604090912082516110e992600290920191840190612d25565b506000848152601660209081526040909120835161110f92600390920191850190612d25565b505050600091825250601660205260409020600401805460ff19169055565b611136611cea565b6001600160a01b0316611147611270565b6001600160a01b03161461116d5760405162461bcd60e51b815260040161073c90613a79565b806001600160a01b03811663a9059cbb611185611270565b6040516370a0823160e01b81526001600160a01b038516906370a08231906111b1903090600401613479565b60206040518083038186803b1580156111c957600080fd5b505afa1580156111dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120191906132c1565b6040518363ffffffff1660e01b815260040161121e9291906134ca565b602060405180830381600087803b15801561123857600080fd5b505af115801561124c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f49190613201565b6000546001600160a01b031690565b60166020908152600091825260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529092918391908301828280156113165780601f106112eb57610100808354040283529160200191611316565b820191906000526020600020905b8154815290600101906020018083116112f957829003601f168201915b5050506004909301549192505060ff1682565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146113715760405162461bcd60e51b815260040161073c90613b67565b6109bb828261225e565b600b8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106fc5780601f106106d1576101008083540402835291602001916106fc565b662386f26fc1000081565b6113ef611cea565b6001546001600160a01b039081169116148061142a575061140e611cea565b6001600160a01b031661141f611270565b6001600160a01b0316145b6114465760405162461bcd60e51b815260040161073c90613834565b6000828152601660205260409020600201546114745760405162461bcd60e51b815260040161073c90613735565b61147d82611cdd565b1561149a5760405162461bcd60e51b815260040161073c90613604565b6109bb8183612285565b6114ac611cea565b6001600160a01b0316826001600160a01b031614156114dd5760405162461bcd60e51b815260040161073c906137fd565b80600960006114ea611cea565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561152e611cea565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611566919061358f565b60405180910390a35050565b600061157c611027565b6001600160a01b0316146115a25760405162461bcd60e51b815260040161073c90613aae565b6115aa611af0565b156115b457610b28565b80156115c65760024301600e556115d9565b6115d560135460145442612349565b6011555b6115e242610fc4565b600f805491810b6001600160801b03166001600160801b031990921691909117808255426010556040517fa838b6e9cbb62d69fe9ac9164c855376e03bfe94f0dcad98327ef2e7727f4ae79261163a92900b906135d1565b60405180910390a150565b61164d611cea565b6002546001600160a01b0390811691161461167a5760405162461bcd60e51b815260040161073c90613ad4565b610b2881612483565b61169461168e611cea565b83611d95565b6116b05760405162461bcd60e51b815260040161073c90613c00565b6116bc848484846124c9565b50505050565b6040805160018082528183019092526060918291906020808301908036833701905050905030816000815181106116f557fe5b6001600160a01b03909216602092830291909101909101529050919050565b6000818152601660205260409020600201546060906117455760405162461bcd60e51b815260040161073c90613735565b61174d612d7e565b6000838152601660209081526040918290208251815460026001821615610100026000190190911604601f8101849004909302810160c090810190945260a081018381529093919284928491908401828280156117eb5780601f106117c0576101008083540402835291602001916117eb565b820191906000526020600020905b8154815290600101906020018083116117ce57829003601f168201915b5050505050815260200160018201805480602002602001604051908101604052809291908181526020016000905b828210156118c45760008481526020908190208301805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156118b05780601f10611885576101008083540402835291602001916118b0565b820191906000526020600020905b81548152906001019060200180831161189357829003601f168201915b505050505081526020019060010190611819565b50505050815260200160028201805480602002602001604051908101604052809291908181526020016000905b8282101561199c5760008481526020908190208301805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156119885780601f1061195d57610100808354040283529160200191611988565b820191906000526020600020905b81548152906001019060200180831161196b57829003601f168201915b5050505050815260200190600101906118f1565b50505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b82821015611a745760008481526020908190208301805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015611a605780601f10611a3557610100808354040283529160200191611a60565b820191906000526020600020905b815481529060010190602001808311611a4357829003601f168201915b5050505050815260200190600101906119c9565b5050505081526020016004820160009054906101000a900460ff1660ff1660ff1681525050905060608160400151826080015160ff1681518110611ab457fe5b60200260200101519050611ac6610d1a565b81604051602001611ad892919061344a565b60405160208183030381529060405292505050919050565b600080600e541180610854575050601154151590565b60008030611b1384611d5c565b6127100291509150915091565b611b28611cea565b6001600160a01b0316611b39611270565b6001600160a01b031614611b5f5760405162461bcd60e51b815260040161073c90613a79565b610b28816124fc565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205460ff1690565b611b9e611cea565b6001600160a01b0316611baf611270565b6001600160a01b031614611bd55760405162461bcd60e51b815260040161073c90613a79565b6001600160a01b038116611bfb5760405162461bcd60e51b815260040161073c906136b8565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b611c5e611cea565b6001600160a01b0316611c6f611270565b6001600160a01b031614611c955760405162461bcd60e51b815260040161073c90613a79565b6001600160a01b038116611cbb5760405162461bcd60e51b815260040161073c90613b41565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600061091760068361250f565b3390565b600081815260086020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611d2382610c31565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081815260166020526040812060040154600160ff90911610611d825750600f61066b565b50600561066b565b60006109178261251b565b6000611da082611cdd565b611dbc5760405162461bcd60e51b815260040161073c906138c3565b6000611dc783610c31565b9050806001600160a01b0316846001600160a01b03161480611e025750836001600160a01b0316611df784610715565b6001600160a01b0316145b80611e125750611e128185611b68565b949350505050565b826001600160a01b0316611e2d82610c31565b6001600160a01b031614611e535760405162461bcd60e51b815260040161073c90613af8565b6001600160a01b038216611e795760405162461bcd60e51b815260040161073c906137b9565b611e848383836107f4565b611e8f600082611cee565b6001600160a01b0383166000908152600560205260409020611eb1908261251f565b506001600160a01b0382166000908152600560205260409020611ed4908261252b565b50611ee160068284612537565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610914838361254d565b6000600e819055600f80546001600160801b0319169055601181905560128190556040517f9e536557517308e18caa7e840b8a94b2b3ff8ee993f14c21a0e17cb4b8157b349190a1565b60005b306001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611fba57600080fd5b505afa158015611fce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff291906132c1565b8110156109bb57604051634f6ccce760e01b81526000903090634f6ccce79061201f908590600401613cab565b60206040518083038186803b15801561203757600080fd5b505afa15801561204b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206f91906132c1565b905060008382604051602001612086929190613420565b60408051601f198184030181529190528051602090910120600f805491925060c083901c91810b810b9082900b13156120c2576120c283612483565b505050600101611f81565b60008080806120dc8686612592565b909450925050505b9250929050565b60006120f88484846125ee565b90505b9392505050565b6000828211156121245760405162461bcd60e51b815260040161073c9061388c565b50900390565b6000677fffffffffffffff82111561214157600080fd5b5060401b90565b6000600f82810b9084900b0360016001607f1b03198112801590612173575060016001607f1b038113155b61091457600080fd5b600081600f0b6000141561218f57600080fd5b600082600f0b604085600f0b901b816121a457fe5b05905060016001607f1b03198112801590612173575060016001607f1b0381131561091457600080fd5b60008060008085600f0b126121f5576121ee603f86600f0b901b8561264d565b9150612219565b61220f603f866000036001600160801b0316901b8561264d565b9150506001831615155b603f82901c91508015612242576001607f1b82111561223757600080fd5b506000039050610917565b60016001607f1b0382111561225657600080fd5b509050610917565b601154821461227f5760405162461bcd60e51b815260040161073c90613790565b60125550565b6001600160a01b0382166122ab5760405162461bcd60e51b815260040161073c906139f8565b6122b481611cdd565b156122d15760405162461bcd60e51b815260040161073c906136fe565b6122dd600083836107f4565b6001600160a01b03821660009081526005602052604090206122ff908261252b565b5061230c60068284612537565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316634000aea07f00000000000000000000000000000000000000000000000000000000000000008587866040516020016123af929190613420565b6040516020818303038152906040526040518463ffffffff1660e01b81526004016123dc939291906134e3565b602060405180830381600087803b1580156123f657600080fd5b505af115801561240a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242e9190613201565b5060008481526003602052604081205461244d90869085903090612820565b60008681526003602052604090205490915061246a90600161285a565b60008681526003602052604090205561101e858261287f565b600081815260166020526040808220600401805460ff191660011790555182917fc200fa2207a7f3b8556185d193ab150ae725ab9d842206741435cc063cf7d0b491a250565b6124d4848484611e1a565b6124e0848484846128b2565b6116bc5760405162461bcd60e51b815260040161073c90613666565b80516109bb90600d906020840190612cb7565b60006109148383612991565b5490565b600061091483836129a9565b60006109148383612a6f565b60006120f884846001600160a01b038516612ab9565b815460009082106125705760405162461bcd60e51b815260040161073c90613624565b82600001828154811061257f57fe5b9060005260206000200154905092915050565b8154600090819083106125b75760405162461bcd60e51b815260040161073c906139b6565b60008460000184815481106125c857fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6000828152600184016020526040812054828161261e5760405162461bcd60e51b815260040161073c91906135be565b5084600001600182038154811061263157fe5b9060005260206000209060020201600101549150509392505050565b60008161265f57506001607f1b610917565b8261266c57506000610917565b600083600160801b8110612682576080918201911c5b68010000000000000000811061269a576040918201911c5b64010000000081106126ae576020918201911c5b6201000081106126c0576010918201911c5b61010081106126d1576008918201911c5b601081106126e1576004918201911c5b600481106126f1576002918201911c5b60028110612700576001820191505b607e19820160008113156127175794851c94612721565b8060000386901b95505b6001607f1b60005b86156127ef5760018716156127915760001990960195908702908201600160ff1b821061275f5760809190911c90600101612767565b607f82901c91505b607e1981121561277f57600095505050505050610917565b6080811261278c57600080fd5b6127ea565b96800296600196871c969290921b91600160ff1b88106127bd57608088901c97506001830192506127c5565b607f88901c97505b607e198312156127dd57600095505050505050610917565b608083126127ea57600080fd5b612729565b60008113156128015790811b90612814565b6000811215612814578060000382901c91505b50935061091792505050565b600084848484604051602001612839949392919061359a565b60408051601f19818403018152919052805160209091012095945050505050565b6000828201838110156109145760405162461bcd60e51b815260040161073c90613759565b60008282604051602001612894929190613420565b60405160208183030381529060405280519060200120905092915050565b60006128c6846001600160a01b0316612b50565b6128d257506001611e12565b606061295a630a85bd0160e11b6128e7611cea565b8887876040516024016128fd949392919061348d565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001613d47603291396001600160a01b0388169190612b56565b9050600081806020019051810190612972919061325a565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b60008181526001830160205260408120548015612a6557835460001980830191908101906000908790839081106129dc57fe5b90600052602060002001549050808760000184815481106129f957fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612a2957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610917565b6000915050610917565b6000612a7b8383612991565b612ab157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610917565b506000610917565b600082815260018401602052604081205480612b1e5750506040805180820182528381526020808201848152865460018181018955600089815284812095516002909302909501918255915190820155865486845281880190925292909120556120fb565b82856000016001830381548110612b3157fe5b90600052602060002090600202016001018190555060009150506120fb565b3b151590565b60606120f8848460008585612b6a85612b50565b612b865760405162461bcd60e51b815260040161073c90613c51565b60006060866001600160a01b03168587604051612ba3919061342e565b60006040518083038185875af1925050503d8060008114612be0576040519150601f19603f3d011682016040523d82523d6000602084013e612be5565b606091505b5091509150612bf5828286612c00565b979650505050505050565b60608315612c0f5750816120fb565b825115612c1f5782518084602001fd5b8160405162461bcd60e51b815260040161073c91906135be565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612c7a5782800160ff19823516178555612ca7565b82800160010185558215612ca7579182015b82811115612ca7578235825591602001919060010190612c8c565b50612cb3929150612db0565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612cf857805160ff1916838001178555612ca7565b82800160010185558215612ca7579182015b82811115612ca7578251825591602001919060010190612d0a565b828054828255906000526020600020908101928215612d72579160200282015b82811115612d725782518051612d62918491602090910190612cb7565b5091602001919060010190612d45565b50612cb3929150612dc5565b6040518060a0016040528060608152602001606081526020016060815260200160608152602001600060ff1681525090565b5b80821115612cb35760008155600101612db1565b80821115612cb3576000612dd98282612de2565b50600101612dc5565b50805460018160011615610100020316600290046000825580601f10612e085750610b28565b601f016020900490600052602060002090810190610b289190612db0565b80356001600160a01b038116811461066b57600080fd5b600082601f830112612e4d578081fd5b8135612e60612e5b82613cd8565b613cb4565b818152915060208083019084810160005b84811015612e9a57612e88888484358a0101612ea5565b84529282019290820190600101612e71565b505050505092915050565b600082601f830112612eb5578081fd5b8135612ec3612e5b82613cd8565b818152915060208083019084810160005b84811015612e9a57612eeb888484358a0101612f3d565b84529282019290820190600101612ed4565b60008083601f840112612f0e578182fd5b50813567ffffffffffffffff811115612f25578182fd5b6020830191508360208285010111156120e457600080fd5b600082601f830112612f4d578081fd5b813567ffffffffffffffff811115612f6157fe5b612f74601f8201601f1916602001613cb4565b9150808252836020828501011115612f8b57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612fb5578081fd5b61091482612e26565b60008060408385031215612fd0578081fd5b612fd983612e26565b9150612fe760208401612e26565b90509250929050565b600080600060608486031215613004578081fd5b61300d84612e26565b925061301b60208501612e26565b9150604084013590509250925092565b60008060008060808587031215613040578081fd5b61304985612e26565b935061305760208601612e26565b925060408501359150606085013567ffffffffffffffff811115613079578182fd5b61308587828801612f3d565b91505092959194509250565b600080604083850312156130a3578182fd5b6130ac83612e26565b915060208301356130bc81613d22565b809150509250929050565b600080604083850312156130d9578182fd5b6130e283612e26565b946020939093013593505050565b60008060008060808587031215613105578384fd5b843567ffffffffffffffff8082111561311c578586fd5b818701915087601f83011261312f578586fd5b813561313d612e5b82613cd8565b80828252602080830192508086018c82838702890101111561315d578a8bfd5b8a96505b8487101561317f578035845260019690960195928101928101613161565b509098508901359350505080821115613196578485fd5b6131a288838901612ea5565b945060408701359150808211156131b7578384fd5b6131c388838901612e3d565b935060608701359150808211156131d8578283fd5b5061308587828801612e3d565b6000602082840312156131f6578081fd5b813561091481613d22565b600060208284031215613212578081fd5b815161091481613d22565b6000806040838503121561322f578182fd5b50508035926020909101359150565b60006020828403121561324f578081fd5b813561091481613d30565b60006020828403121561326b578081fd5b815161091481613d30565b600060208284031215613287578081fd5b813567ffffffffffffffff81111561329d578182fd5b611e1284828501612f3d565b6000602082840312156132ba578081fd5b5035919050565b6000602082840312156132d2578081fd5b5051919050565b600080604083850312156132eb578182fd5b82359150612fe760208401612e26565b600080600080600060608688031215613312578283fd5b85359450602086013567ffffffffffffffff80821115613330578485fd5b61333c89838a01612efd565b90965094506040880135915080821115613354578283fd5b5061336188828901612efd565b969995985093965092949392505050565b60008060008060808587031215613387578182fd5b84359350602085013567ffffffffffffffff808211156133a5578384fd5b6133b188838901612f3d565b945060408701359150808211156133c6578384fd5b6133d288838901612ea5565b935060608701359150808211156133e7578283fd5b5061308587828801612ea5565b6000815180845261340c816020860160208601613cf6565b601f01601f19169290920160200192915050565b918252602082015260400190565b60008251613440818460208701613cf6565b9190910192915050565b6000835161345c818460208801613cf6565b835190830190613470818360208801613cf6565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906134c0908301846133f4565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b600060018060a01b03851682528360208301526060604083015261101e60608301846133f4565b6020808252825182820181905260009190848201906040850190845b8181101561354b5783516001600160a01b031683529284019291840191600101613526565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561354b57835183529284019291840191600101613573565b901515815260200190565b93845260208401929092526001600160a01b03166040830152606082015260800190565b60006020825261091460208301846133f4565b600f9190910b815260200190565b6000604082526135f260408301856133f4565b905060ff831660208301529392505050565b60208082526006908201526565786973747360d01b604082015260600190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252600a90820152691a5b9d985b1a59081a5960b21b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600f908201526e1a5b9d985b1a590b5c995c5d595cdd608a1b604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252601390820152723737ba1036b4b73a32b91037b91037bbb732b960691b604082015260600190565b6020808252601190820152703737ba1030903b30b634b2103a37b5b2b760791b604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600c908201526b1c9b99cb591a5cd8589b195960a21b604082015260600190565b6020808252600a90820152693737ba103237b1ba37b960b11b604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252600c908201526b7a65726f206164647265737360a01b604082015260600190565b6020808252601f908201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c00604082015260600190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252600790820152661b9bcb5c9bdb1b60ca1b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b602080825260099082015268746f6f2d6561726c7960b81b604082015260600190565b90815260200190565b60405181810167ffffffffffffffff81118282101715613cd057fe5b604052919050565b600067ffffffffffffffff821115613cec57fe5b5060209081020190565b60005b83811015613d11578181015183820152602001613cf9565b838111156116bc5750506000910152565b8015158114610b2857600080fd5b6001600160e01b031981168114610b2857600080fdfe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea2646970667358221220e174bf43e09656c290e439b18819b3936dcb9c0e7cd9b723c5048611cd24b08c64736f6c634300070300338be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb7952000000000000000000000000514910771af9ca656af840dff83e8264ecf986caaa77729d3466ca35ae8d28b3bbac7cc36a5031efdc430821c02bc31a238af4450000000000000000000000000000000000000000000000001bc16d674ec80000

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102d65760003560e01c806370a0823111610182578063a140ae23116100e9578063c87b56dd116100a2578063e2d0f04a1161007c578063e2d0f04a14610601578063e985e9c514610614578063f2fde38b14610627578063fca3b5aa1461063a576102d6565b8063c87b56dd146105c5578063cb565320146105d8578063cef6d368146105e0576102d6565b8063a140ae2314610546578063a22cb46514610559578063aa25f47b1461056c578063b48c7fb21461057f578063b88d4fde14610592578063b9c4d9fb146105a5576102d6565b8063894760691161013b57806389476069146104e75780638da5cb5b146104fa5780638f64be301461050257806394985ddd1461052357806395d89b411461053657806396ce07951461053e576102d6565b806370a082311461048b578063715018a61461049e57806374120c5c146104a6578063791b2123146104b95780637ea7118c146104cc5780638362a342146104d4576102d6565b80633bd8094111610241578063503475a3116101fa5780636352211e116101d45780636352211e14610448578063663a93951461045b5780636b2e90e21461046e5780636c0360eb14610483576102d6565b8063503475a314610425578063529ca2071461042d57806358411a1a14610440576102d6565b80633bd80941146103d45780633ccfd60b146103dc57806342842e0e146103e457806348103e65146103f7578063497027911461040a5780634f6ccce714610412576102d6565b806318160ddd1161029357806318160ddd146103765780631c31f7101461038b57806323b872dd1461039e5780632f745c59146103b1578063361464d8146103c457806338af3eed146103cc576102d6565b806301ffc9a7146102db57806306fdde03146103045780630754617214610319578063081812fc1461032e578063095ea7b3146103415780630ebd4c7f14610356575b600080fd5b6102ee6102e936600461323e565b61064d565b6040516102fb919061358f565b60405180910390f35b61030c610670565b6040516102fb91906135be565b610321610706565b6040516102fb9190613479565b61032161033c3660046132a9565b610715565b61035461034f3660046130c7565b610761565b005b6103696103643660046132a9565b6107f9565b6040516102fb9190613557565b61037e610848565b6040516102fb9190613cab565b610354610399366004612fa4565b610859565b6103546103ac366004612ff0565b6108ba565b61037e6103bf3660046130c7565b6108f2565b61037e61091d565b610321610925565b61037e610934565b61035461093a565b6103546103f2366004612ff0565b6109bf565b610354610405366004612fa4565b6109da565b610354610a61565b61037e6104203660046132a9565b610b2c565b61037e610b42565b61030c61043b3660046132a9565b610b4d565b61037e610c2a565b6103216104563660046132a9565b610c31565b6103546104693660046132fb565b610c59565b610476610d11565b6040516102fb91906135d1565b61030c610d1a565b61037e610499366004612fa4565b610d7b565b610354610dc4565b6103546104b43660046130f0565b610e4d565b6104766104c73660046132a9565b610fc4565b610321611027565b6103546104e2366004613372565b611036565b6103546104f5366004612fa4565b61112e565b610321611270565b6105156105103660046132a9565b61127f565b6040516102fb9291906135df565b61035461053136600461321d565b611329565b61030c61137b565b61037e6113dc565b6103546105543660046132d9565b6113e7565b610354610567366004613091565b6114a4565b61035461057a3660046131e5565b611572565b61035461058d3660046132a9565b611645565b6103546105a036600461302b565b611683565b6105b86105b33660046132a9565b6116c2565b6040516102fb919061350a565b61030c6105d33660046132a9565b611714565b6102ee611af0565b6105f36105ee3660046132a9565b611b06565b6040516102fb9291906134ca565b61035461060f366004613276565b611b20565b6102ee610622366004612fbe565b611b68565b610354610635366004612fa4565b611b96565b610354610648366004612fa4565b611c56565b6001600160e01b0319811660009081526004602052604090205460ff165b919050565b600a8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106fc5780601f106106d1576101008083540402835291602001916106fc565b820191906000526020600020905b8154815290600101906020018083116106df57829003601f168201915b5050505050905090565b6001546001600160a01b031690565b600061072082611cdd565b6107455760405162461bcd60e51b815260040161073c90613a2d565b60405180910390fd5b506000908152600860205260409020546001600160a01b031690565b600061076c82610c31565b9050806001600160a01b0316836001600160a01b031614156107a05760405162461bcd60e51b815260040161073c90613b9e565b806001600160a01b03166107b2611cea565b6001600160a01b031614806107ce57506107ce81610622611cea565b6107ea5760405162461bcd60e51b815260040161073c9061390f565b6107f48383611cee565b505050565b6040805160018082528183019092526060918291906020808301908036833701905050905061082783611d5c565b6064028160008151811061083757fe5b602090810291909101015292915050565b60006108546006611d8a565b905090565b610861611cea565b6001600160a01b0316610872611270565b6001600160a01b0316146108985760405162461bcd60e51b815260040161073c90613a79565b601580546001600160a01b0319166001600160a01b0392909216919091179055565b6108cb6108c5611cea565b82611d95565b6108e75760405162461bcd60e51b815260040161073c90613c00565b6107f4838383611e1a565b6001600160a01b03821660009081526005602052604081206109149083611f28565b90505b92915050565b630966018081565b6015546001600160a01b031681565b60105481565b610942611cea565b6001600160a01b0316610953611270565b6001600160a01b0316146109795760405162461bcd60e51b815260040161073c90613a79565b6000610983611270565b6040519091506001600160a01b038216904780156108fc02916000818181858888f193505050501580156109bb573d6000803e3d6000fd5b5050565b6107f483838360405180602001604052806000815250611683565b6109e2611cea565b6001600160a01b03166109f3611270565b6001600160a01b031614610a195760405162461bcd60e51b815260040161073c90613a79565b6001600160a01b038116610a3f5760405162461bcd60e51b815260040161073c90613b41565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610a69611af0565b610a855760405162461bcd60e51b815260040161073c90613bdf565b600e5460009015610ace57600e544311610ab15760405162461bcd60e51b815260040161073c90613c88565b50600e544080610ac957610ac3611f34565b50610b2a565b610b17565b601254158015610ae35750611c206010544203115b15610af057610ac3611f34565b600060125411610b125760405162461bcd60e51b815260040161073c90613c88565b506012545b610b2081611f7e565b610b28611f34565b505b565b600080610b3a6006846120cd565b509392505050565b66071afd498d000081565b6060610b5882611cdd565b610b745760405162461bcd60e51b815260040161073c90613861565b60008281526016602052604081206001018054909190610b9057fe5b600091825260209182902001805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015610c1e5780601f10610bf357610100808354040283529160200191610c1e565b820191906000526020600020905b815481529060010190602001808311610c0157829003601f168201915b50505050509050919050565b62d7eff781565b600061091782604051806060016040528060298152602001613d7960299139600691906120eb565b610c61611cea565b6001600160a01b0316610c72611270565b6001600160a01b031614610c985760405162461bcd60e51b815260040161073c90613a79565b600085815260166020526040812060010180548692869291610cb657fe5b906000526020600020019190610ccd929190612c39565b50818160166000888152602001908152602001600020600101600181548110610cf257fe5b906000526020600020019190610d09929190612c39565b505050505050565b600f8054900b81565b600d8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106fc5780601f106106d1576101008083540402835291602001916106fc565b60006001600160a01b038216610da35760405162461bcd60e51b815260040161073c9061396c565b6001600160a01b038216600090815260056020526040902061091790611d8a565b610dcc611cea565b6001600160a01b0316610ddd611270565b6001600160a01b031614610e035760405162461bcd60e51b815260040161073c90613a79565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b610e55611cea565b6001600160a01b0316610e66611270565b6001600160a01b031614610e8c5760405162461bcd60e51b815260040161073c90613a79565b60005b8451811015610fbd576000858281518110610ea657fe5b602002602001015190506016600082815260200190815260200160002060020180549050600014610ee95760405162461bcd60e51b815260040161073c90613735565b848281518110610ef557fe5b602090810291909101810151600083815260168352604090208151610f1f93919290910190612cb7565b50828281518110610f2c57fe5b6020026020010151601660008381526020019081526020016000206002019080519060200190610f5d929190612d25565b50838281518110610f6a57fe5b6020026020010151601660008381526020019081526020016000206003019080519060200190610f9b929190612d25565b506000908152601660205260409020600401805460ff19169055600101610e8f565b5050505050565b600080610fdc6010548461210290919063ffffffff16565b90506000610ff0662386f26fc1000061212a565b9050600061100062d7eff761212a565b905061101e6110186110128484612148565b8461217c565b846121ce565b95945050505050565b6002546001600160a01b031690565b61103e611cea565b6001600160a01b031661104f611270565b6001600160a01b0316146110755760405162461bcd60e51b815260040161073c90613a79565b600084815260166020526040902060020154156110a45760405162461bcd60e51b815260040161073c90613735565b600084815260166020908152604090912084516110c392860190612cb7565b50600084815260166020908152604090912082516110e992600290920191840190612d25565b506000848152601660209081526040909120835161110f92600390920191850190612d25565b505050600091825250601660205260409020600401805460ff19169055565b611136611cea565b6001600160a01b0316611147611270565b6001600160a01b03161461116d5760405162461bcd60e51b815260040161073c90613a79565b806001600160a01b03811663a9059cbb611185611270565b6040516370a0823160e01b81526001600160a01b038516906370a08231906111b1903090600401613479565b60206040518083038186803b1580156111c957600080fd5b505afa1580156111dd573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061120191906132c1565b6040518363ffffffff1660e01b815260040161121e9291906134ca565b602060405180830381600087803b15801561123857600080fd5b505af115801561124c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f49190613201565b6000546001600160a01b031690565b60166020908152600091825260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529092918391908301828280156113165780601f106112eb57610100808354040283529160200191611316565b820191906000526020600020905b8154815290600101906020018083116112f957829003601f168201915b5050506004909301549192505060ff1682565b336001600160a01b037f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795216146113715760405162461bcd60e51b815260040161073c90613b67565b6109bb828261225e565b600b8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156106fc5780601f106106d1576101008083540402835291602001916106fc565b662386f26fc1000081565b6113ef611cea565b6001546001600160a01b039081169116148061142a575061140e611cea565b6001600160a01b031661141f611270565b6001600160a01b0316145b6114465760405162461bcd60e51b815260040161073c90613834565b6000828152601660205260409020600201546114745760405162461bcd60e51b815260040161073c90613735565b61147d82611cdd565b1561149a5760405162461bcd60e51b815260040161073c90613604565b6109bb8183612285565b6114ac611cea565b6001600160a01b0316826001600160a01b031614156114dd5760405162461bcd60e51b815260040161073c906137fd565b80600960006114ea611cea565b6001600160a01b03908116825260208083019390935260409182016000908120918716808252919093529120805460ff19169215159290921790915561152e611cea565b6001600160a01b03167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3183604051611566919061358f565b60405180910390a35050565b600061157c611027565b6001600160a01b0316146115a25760405162461bcd60e51b815260040161073c90613aae565b6115aa611af0565b156115b457610b28565b80156115c65760024301600e556115d9565b6115d560135460145442612349565b6011555b6115e242610fc4565b600f805491810b6001600160801b03166001600160801b031990921691909117808255426010556040517fa838b6e9cbb62d69fe9ac9164c855376e03bfe94f0dcad98327ef2e7727f4ae79261163a92900b906135d1565b60405180910390a150565b61164d611cea565b6002546001600160a01b0390811691161461167a5760405162461bcd60e51b815260040161073c90613ad4565b610b2881612483565b61169461168e611cea565b83611d95565b6116b05760405162461bcd60e51b815260040161073c90613c00565b6116bc848484846124c9565b50505050565b6040805160018082528183019092526060918291906020808301908036833701905050905030816000815181106116f557fe5b6001600160a01b03909216602092830291909101909101529050919050565b6000818152601660205260409020600201546060906117455760405162461bcd60e51b815260040161073c90613735565b61174d612d7e565b6000838152601660209081526040918290208251815460026001821615610100026000190190911604601f8101849004909302810160c090810190945260a081018381529093919284928491908401828280156117eb5780601f106117c0576101008083540402835291602001916117eb565b820191906000526020600020905b8154815290600101906020018083116117ce57829003601f168201915b5050505050815260200160018201805480602002602001604051908101604052809291908181526020016000905b828210156118c45760008481526020908190208301805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156118b05780601f10611885576101008083540402835291602001916118b0565b820191906000526020600020905b81548152906001019060200180831161189357829003601f168201915b505050505081526020019060010190611819565b50505050815260200160028201805480602002602001604051908101604052809291908181526020016000905b8282101561199c5760008481526020908190208301805460408051601f60026000196101006001871615020190941693909304928301859004850281018501909152818152928301828280156119885780601f1061195d57610100808354040283529160200191611988565b820191906000526020600020905b81548152906001019060200180831161196b57829003601f168201915b5050505050815260200190600101906118f1565b50505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b82821015611a745760008481526020908190208301805460408051601f6002600019610100600187161502019094169390930492830185900485028101850190915281815292830182828015611a605780601f10611a3557610100808354040283529160200191611a60565b820191906000526020600020905b815481529060010190602001808311611a4357829003601f168201915b5050505050815260200190600101906119c9565b5050505081526020016004820160009054906101000a900460ff1660ff1660ff1681525050905060608160400151826080015160ff1681518110611ab457fe5b60200260200101519050611ac6610d1a565b81604051602001611ad892919061344a565b60405160208183030381529060405292505050919050565b600080600e541180610854575050601154151590565b60008030611b1384611d5c565b6127100291509150915091565b611b28611cea565b6001600160a01b0316611b39611270565b6001600160a01b031614611b5f5760405162461bcd60e51b815260040161073c90613a79565b610b28816124fc565b6001600160a01b03918216600090815260096020908152604080832093909416825291909152205460ff1690565b611b9e611cea565b6001600160a01b0316611baf611270565b6001600160a01b031614611bd55760405162461bcd60e51b815260040161073c90613a79565b6001600160a01b038116611bfb5760405162461bcd60e51b815260040161073c906136b8565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b611c5e611cea565b6001600160a01b0316611c6f611270565b6001600160a01b031614611c955760405162461bcd60e51b815260040161073c90613a79565b6001600160a01b038116611cbb5760405162461bcd60e51b815260040161073c90613b41565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b600061091760068361250f565b3390565b600081815260086020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611d2382610c31565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600081815260166020526040812060040154600160ff90911610611d825750600f61066b565b50600561066b565b60006109178261251b565b6000611da082611cdd565b611dbc5760405162461bcd60e51b815260040161073c906138c3565b6000611dc783610c31565b9050806001600160a01b0316846001600160a01b03161480611e025750836001600160a01b0316611df784610715565b6001600160a01b0316145b80611e125750611e128185611b68565b949350505050565b826001600160a01b0316611e2d82610c31565b6001600160a01b031614611e535760405162461bcd60e51b815260040161073c90613af8565b6001600160a01b038216611e795760405162461bcd60e51b815260040161073c906137b9565b611e848383836107f4565b611e8f600082611cee565b6001600160a01b0383166000908152600560205260409020611eb1908261251f565b506001600160a01b0382166000908152600560205260409020611ed4908261252b565b50611ee160068284612537565b5080826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6000610914838361254d565b6000600e819055600f80546001600160801b0319169055601181905560128190556040517f9e536557517308e18caa7e840b8a94b2b3ff8ee993f14c21a0e17cb4b8157b349190a1565b60005b306001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611fba57600080fd5b505afa158015611fce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ff291906132c1565b8110156109bb57604051634f6ccce760e01b81526000903090634f6ccce79061201f908590600401613cab565b60206040518083038186803b15801561203757600080fd5b505afa15801561204b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206f91906132c1565b905060008382604051602001612086929190613420565b60408051601f198184030181529190528051602090910120600f805491925060c083901c91810b810b9082900b13156120c2576120c283612483565b505050600101611f81565b60008080806120dc8686612592565b909450925050505b9250929050565b60006120f88484846125ee565b90505b9392505050565b6000828211156121245760405162461bcd60e51b815260040161073c9061388c565b50900390565b6000677fffffffffffffff82111561214157600080fd5b5060401b90565b6000600f82810b9084900b0360016001607f1b03198112801590612173575060016001607f1b038113155b61091457600080fd5b600081600f0b6000141561218f57600080fd5b600082600f0b604085600f0b901b816121a457fe5b05905060016001607f1b03198112801590612173575060016001607f1b0381131561091457600080fd5b60008060008085600f0b126121f5576121ee603f86600f0b901b8561264d565b9150612219565b61220f603f866000036001600160801b0316901b8561264d565b9150506001831615155b603f82901c91508015612242576001607f1b82111561223757600080fd5b506000039050610917565b60016001607f1b0382111561225657600080fd5b509050610917565b601154821461227f5760405162461bcd60e51b815260040161073c90613790565b60125550565b6001600160a01b0382166122ab5760405162461bcd60e51b815260040161073c906139f8565b6122b481611cdd565b156122d15760405162461bcd60e51b815260040161073c906136fe565b6122dd600083836107f4565b6001600160a01b03821660009081526005602052604090206122ff908261252b565b5061230c60068284612537565b5060405181906001600160a01b038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb79528587866040516020016123af929190613420565b6040516020818303038152906040526040518463ffffffff1660e01b81526004016123dc939291906134e3565b602060405180830381600087803b1580156123f657600080fd5b505af115801561240a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242e9190613201565b5060008481526003602052604081205461244d90869085903090612820565b60008681526003602052604090205490915061246a90600161285a565b60008681526003602052604090205561101e858261287f565b600081815260166020526040808220600401805460ff191660011790555182917fc200fa2207a7f3b8556185d193ab150ae725ab9d842206741435cc063cf7d0b491a250565b6124d4848484611e1a565b6124e0848484846128b2565b6116bc5760405162461bcd60e51b815260040161073c90613666565b80516109bb90600d906020840190612cb7565b60006109148383612991565b5490565b600061091483836129a9565b60006109148383612a6f565b60006120f884846001600160a01b038516612ab9565b815460009082106125705760405162461bcd60e51b815260040161073c90613624565b82600001828154811061257f57fe5b9060005260206000200154905092915050565b8154600090819083106125b75760405162461bcd60e51b815260040161073c906139b6565b60008460000184815481106125c857fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b6000828152600184016020526040812054828161261e5760405162461bcd60e51b815260040161073c91906135be565b5084600001600182038154811061263157fe5b9060005260206000209060020201600101549150509392505050565b60008161265f57506001607f1b610917565b8261266c57506000610917565b600083600160801b8110612682576080918201911c5b68010000000000000000811061269a576040918201911c5b64010000000081106126ae576020918201911c5b6201000081106126c0576010918201911c5b61010081106126d1576008918201911c5b601081106126e1576004918201911c5b600481106126f1576002918201911c5b60028110612700576001820191505b607e19820160008113156127175794851c94612721565b8060000386901b95505b6001607f1b60005b86156127ef5760018716156127915760001990960195908702908201600160ff1b821061275f5760809190911c90600101612767565b607f82901c91505b607e1981121561277f57600095505050505050610917565b6080811261278c57600080fd5b6127ea565b96800296600196871c969290921b91600160ff1b88106127bd57608088901c97506001830192506127c5565b607f88901c97505b607e198312156127dd57600095505050505050610917565b608083126127ea57600080fd5b612729565b60008113156128015790811b90612814565b6000811215612814578060000382901c91505b50935061091792505050565b600084848484604051602001612839949392919061359a565b60408051601f19818403018152919052805160209091012095945050505050565b6000828201838110156109145760405162461bcd60e51b815260040161073c90613759565b60008282604051602001612894929190613420565b60405160208183030381529060405280519060200120905092915050565b60006128c6846001600160a01b0316612b50565b6128d257506001611e12565b606061295a630a85bd0160e11b6128e7611cea565b8887876040516024016128fd949392919061348d565b604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b038381831617835250505050604051806060016040528060328152602001613d47603291396001600160a01b0388169190612b56565b9050600081806020019051810190612972919061325a565b6001600160e01b031916630a85bd0160e11b1492505050949350505050565b60009081526001919091016020526040902054151590565b60008181526001830160205260408120548015612a6557835460001980830191908101906000908790839081106129dc57fe5b90600052602060002001549050808760000184815481106129f957fe5b600091825260208083209091019290925582815260018981019092526040902090840190558654879080612a2957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610917565b6000915050610917565b6000612a7b8383612991565b612ab157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610917565b506000610917565b600082815260018401602052604081205480612b1e5750506040805180820182528381526020808201848152865460018181018955600089815284812095516002909302909501918255915190820155865486845281880190925292909120556120fb565b82856000016001830381548110612b3157fe5b90600052602060002090600202016001018190555060009150506120fb565b3b151590565b60606120f8848460008585612b6a85612b50565b612b865760405162461bcd60e51b815260040161073c90613c51565b60006060866001600160a01b03168587604051612ba3919061342e565b60006040518083038185875af1925050503d8060008114612be0576040519150601f19603f3d011682016040523d82523d6000602084013e612be5565b606091505b5091509150612bf5828286612c00565b979650505050505050565b60608315612c0f5750816120fb565b825115612c1f5782518084602001fd5b8160405162461bcd60e51b815260040161073c91906135be565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612c7a5782800160ff19823516178555612ca7565b82800160010185558215612ca7579182015b82811115612ca7578235825591602001919060010190612c8c565b50612cb3929150612db0565b5090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612cf857805160ff1916838001178555612ca7565b82800160010185558215612ca7579182015b82811115612ca7578251825591602001919060010190612d0a565b828054828255906000526020600020908101928215612d72579160200282015b82811115612d725782518051612d62918491602090910190612cb7565b5091602001919060010190612d45565b50612cb3929150612dc5565b6040518060a0016040528060608152602001606081526020016060815260200160608152602001600060ff1681525090565b5b80821115612cb35760008155600101612db1565b80821115612cb3576000612dd98282612de2565b50600101612dc5565b50805460018160011615610100020316600290046000825580601f10612e085750610b28565b601f016020900490600052602060002090810190610b289190612db0565b80356001600160a01b038116811461066b57600080fd5b600082601f830112612e4d578081fd5b8135612e60612e5b82613cd8565b613cb4565b818152915060208083019084810160005b84811015612e9a57612e88888484358a0101612ea5565b84529282019290820190600101612e71565b505050505092915050565b600082601f830112612eb5578081fd5b8135612ec3612e5b82613cd8565b818152915060208083019084810160005b84811015612e9a57612eeb888484358a0101612f3d565b84529282019290820190600101612ed4565b60008083601f840112612f0e578182fd5b50813567ffffffffffffffff811115612f25578182fd5b6020830191508360208285010111156120e457600080fd5b600082601f830112612f4d578081fd5b813567ffffffffffffffff811115612f6157fe5b612f74601f8201601f1916602001613cb4565b9150808252836020828501011115612f8b57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215612fb5578081fd5b61091482612e26565b60008060408385031215612fd0578081fd5b612fd983612e26565b9150612fe760208401612e26565b90509250929050565b600080600060608486031215613004578081fd5b61300d84612e26565b925061301b60208501612e26565b9150604084013590509250925092565b60008060008060808587031215613040578081fd5b61304985612e26565b935061305760208601612e26565b925060408501359150606085013567ffffffffffffffff811115613079578182fd5b61308587828801612f3d565b91505092959194509250565b600080604083850312156130a3578182fd5b6130ac83612e26565b915060208301356130bc81613d22565b809150509250929050565b600080604083850312156130d9578182fd5b6130e283612e26565b946020939093013593505050565b60008060008060808587031215613105578384fd5b843567ffffffffffffffff8082111561311c578586fd5b818701915087601f83011261312f578586fd5b813561313d612e5b82613cd8565b80828252602080830192508086018c82838702890101111561315d578a8bfd5b8a96505b8487101561317f578035845260019690960195928101928101613161565b509098508901359350505080821115613196578485fd5b6131a288838901612ea5565b945060408701359150808211156131b7578384fd5b6131c388838901612e3d565b935060608701359150808211156131d8578283fd5b5061308587828801612e3d565b6000602082840312156131f6578081fd5b813561091481613d22565b600060208284031215613212578081fd5b815161091481613d22565b6000806040838503121561322f578182fd5b50508035926020909101359150565b60006020828403121561324f578081fd5b813561091481613d30565b60006020828403121561326b578081fd5b815161091481613d30565b600060208284031215613287578081fd5b813567ffffffffffffffff81111561329d578182fd5b611e1284828501612f3d565b6000602082840312156132ba578081fd5b5035919050565b6000602082840312156132d2578081fd5b5051919050565b600080604083850312156132eb578182fd5b82359150612fe760208401612e26565b600080600080600060608688031215613312578283fd5b85359450602086013567ffffffffffffffff80821115613330578485fd5b61333c89838a01612efd565b90965094506040880135915080821115613354578283fd5b5061336188828901612efd565b969995985093965092949392505050565b60008060008060808587031215613387578182fd5b84359350602085013567ffffffffffffffff808211156133a5578384fd5b6133b188838901612f3d565b945060408701359150808211156133c6578384fd5b6133d288838901612ea5565b935060608701359150808211156133e7578283fd5b5061308587828801612ea5565b6000815180845261340c816020860160208601613cf6565b601f01601f19169290920160200192915050565b918252602082015260400190565b60008251613440818460208701613cf6565b9190910192915050565b6000835161345c818460208801613cf6565b835190830190613470818360208801613cf6565b01949350505050565b6001600160a01b0391909116815260200190565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906134c0908301846133f4565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b600060018060a01b03851682528360208301526060604083015261101e60608301846133f4565b6020808252825182820181905260009190848201906040850190845b8181101561354b5783516001600160a01b031683529284019291840191600101613526565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561354b57835183529284019291840191600101613573565b901515815260200190565b93845260208401929092526001600160a01b03166040830152606082015260800190565b60006020825261091460208301846133f4565b600f9190910b815260200190565b6000604082526135f260408301856133f4565b905060ff831660208301529392505050565b60208082526006908201526565786973747360d01b604082015260600190565b60208082526022908201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b6020808252600a90820152691a5b9d985b1a59081a5960b21b604082015260600190565b6020808252601b908201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604082015260600190565b6020808252600f908201526e1a5b9d985b1a590b5c995c5d595cdd608a1b604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252601390820152723737ba1036b4b73a32b91037b91037bbb732b960691b604082015260600190565b6020808252601190820152703737ba1030903b30b634b2103a37b5b2b760791b604082015260600190565b6020808252601e908201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526022908201527f456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e604082015261647360f01b606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252600c908201526b1c9b99cb591a5cd8589b195960a21b604082015260600190565b6020808252600a90820152693737ba103237b1ba37b960b11b604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201526839903737ba1037bbb760b91b606082015260800190565b6020808252600c908201526b7a65726f206164647265737360a01b604082015260600190565b6020808252601f908201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c00604082015260600190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252600790820152661b9bcb5c9bdb1b60ca1b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601d908201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604082015260600190565b602080825260099082015268746f6f2d6561726c7960b81b604082015260600190565b90815260200190565b60405181810167ffffffffffffffff81118282101715613cd057fe5b604052919050565b600067ffffffffffffffff821115613cec57fe5b5060209081020190565b60005b83811015613d11578181015183820152602001613cf9565b838111156116bc5750506000910152565b8015158114610b2857600080fd5b6001600160e01b031981168114610b2857600080fdfe4552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656ea2646970667358221220e174bf43e09656c290e439b18819b3936dcb9c0e7cd9b723c5048611cd24b08c64736f6c63430007030033

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

000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb7952000000000000000000000000514910771af9ca656af840dff83e8264ecf986caaa77729d3466ca35ae8d28b3bbac7cc36a5031efdc430821c02bc31a238af4450000000000000000000000000000000000000000000000001bc16d674ec80000

-----Decoded View---------------
Arg [0] : vrfConfig (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb7952
Arg [1] : 000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca
Arg [2] : aa77729d3466ca35ae8d28b3bbac7cc36a5031efdc430821c02bc31a238af445
Arg [3] : 0000000000000000000000000000000000000000000000001bc16d674ec80000


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.