Contract 0xd79a536581166551b5a4ded9eAC6822627e755bE

Contract Overview

Balance:
0 Ether

Token:
Txn Hash
Method
Block
From
To
Value
0x40cf9ece3f88dfedc5708cc6449f9764cfe0c75e0bd7c92b053a47321010e68c0xb248ac6a85438882021-05-07 13:13:43423 days 11 hrs ago0x3c2b0bd2b784e5e453d9ed31b3c8eeb82ba97ede IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.000069433.1
0xf9915d4f269ff66d34027f2398c8dbbb27d38248791dfbdf1f28b1f0f18383b70xb248ac6a85438832021-05-07 13:12:28423 days 11 hrs ago0x3c2b0bd2b784e5e453d9ed31b3c8eeb82ba97ede IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.000022391
0xf205bcd69a5f1e4ba3da8f253eb991c3d04cce0f7d7a093b5ff523914d879ad20xb248ac6a85438832021-05-07 13:12:28423 days 11 hrs ago0x3c2b0bd2b784e5e453d9ed31b3c8eeb82ba97ede IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.000022391
0x3dba93905862bbacbabc04ffdfb34b39e1b4d537351d7c19b82c96e9d7fc0e6f0xb248ac6a85438122021-05-07 12:54:43423 days 11 hrs ago0x3c2b0bd2b784e5e453d9ed31b3c8eeb82ba97ede IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.000022391
0x06188737c6258715ec2e77efd5090d0246d66a32f1a802e3718c66d502b2e4f60xb248ac6a85437252021-05-07 12:32:57423 days 11 hrs ago0x3c2b0bd2b784e5e453d9ed31b3c8eeb82ba97ede IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.000069433.1
0x06e1a998da550c14752cd84476e002ed419b7e441cbb2f39a75931304e573ad7Start Sales By N...85034412021-04-30 12:36:27430 days 11 hrs ago0xc6ef8a96f20d50e347ed9a1c84142d02b1efedc0 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.000030161
0x2286de1f8b897ec8b3ad8e99871f5fc5748e4fc37cec4f3bc1352a2d9ff981dfGet Sales By Nft...84978372021-04-29 13:14:44431 days 11 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0x46fe8a40460617d8db015564d9ce527d8bde8af72156f02f59ee5e0fed0c48d5Get Sales By Nft...84978342021-04-29 13:13:59431 days 11 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0x40de128428cd00f2efd2269575f9d484068d901f4a40e854b0d80ed6ecf25bcbGet Sales By Nft...84978292021-04-29 13:12:44431 days 11 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0xefa2d4c538777be3635b1ba5056b64734ac1c7cf506f2dbb24b78a0787a16342Get Sales By Nft...84978122021-04-29 13:08:29431 days 11 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0x2bc6c805807d4d840756ae4e6010c52824e409a10b7d696c6544ce46d638ee5bBuy By Nft Id84973812021-04-29 11:20:35431 days 13 hrs ago0xeb531429a602229c4ffe4e98b00ff26e9aab2219 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0037546820
0x1b8409aa98377ce7abf875b40c846dec8530ac4494753eaeabb0d9a58318fd7eGet Sales By Nft...84973802021-04-29 11:20:20431 days 13 hrs ago0xeb531429a602229c4ffe4e98b00ff26e9aab2219 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0xbbfe207c6fee5db8c126b91e6d09d8c9c6372f8d2e9383454c231b705be7450cGet Sales By Nft...84973732021-04-29 11:18:35431 days 13 hrs ago0xeb531429a602229c4ffe4e98b00ff26e9aab2219 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0xb8003d681f75eff19648b76520fd7d963adf4273bc6ff7d2f10e2a53f584ba1aStart Sales84973632021-04-29 11:16:05431 days 13 hrs ago0xeb531429a602229c4ffe4e98b00ff26e9aab2219 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.00516420
0x935c945fe8ef1f0f06543818618cef8a04385ac0477914ad3ae55a8d576c529dStart Sales84965362021-04-29 7:49:16431 days 16 hrs ago0xeb531429a602229c4ffe4e98b00ff26e9aab2219 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.00516420
0x1fdfc50431c0746b35492f7cde1325526d82042ed7489e552d9f51fe56caf62cBuy By Nft Id84927702021-04-28 16:07:33432 days 8 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0006858820
0x0c762f4a800212064a244e3f48a9a91c70842254667031acced5c3aeba9d1941Start Sales84927692021-04-28 16:07:18432 days 8 hrs ago0xeb531429a602229c4ffe4e98b00ff26e9aab2219 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.00516420
0x429e8fd64525b89d508b08c7a046717053e24cad5972352973e47da42277434aGet Sales By Nft...84927692021-04-28 16:07:18432 days 8 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0x3c209fdd1e9f55c1832f6bcc567b3a5f58064b21ae20fab55f7be4e46443e93cBuy By Nft Id84927612021-04-28 16:05:18432 days 8 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0006858820
0x40d356b7432e5d98b90012227fcfead2505b86238ccc9f714651b1648ea04e8cGet Sales By Nft...84927602021-04-28 16:05:03432 days 8 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0x8aaeb110665db360795510c82c6a9f35d9d923129189bf7668a5b88a2ff3c903Set Is Start Use...84927562021-04-28 16:04:03432 days 8 hrs ago0xeb531429a602229c4ffe4e98b00ff26e9aab2219 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0004820220
0x8feefaefab831014d13e8e44a4f2299d58ef713ed2f248d13f416fc50efd0338Buy By Nft Id84927552021-04-28 16:03:48432 days 8 hrs ago0xf58ad9e329f83b43ba1e41aa8bbcf14cd615a951 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0006858820
0xd8c4a5e12be855905689d91cae43ab9138b24d0c604b337d21e5d361e51fae0dGet Sales By Nft...84927542021-04-28 16:03:33432 days 8 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
0x13f532cbaaa1d76090cbe884263625eeb31e3debd3d2f67476cd44102bd6d2dbBuy By Nft Id84927372021-04-28 15:59:18432 days 8 hrs ago0xf58ad9e329f83b43ba1e41aa8bbcf14cd615a951 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0006858820
0xceb6095097213189398481bdd6de3527ba8fb8f6c92beecc805e8c54b549ea32Get Sales By Nft...84927362021-04-28 15:59:03432 days 8 hrs ago0x5bded8f6bdae766c361edae25c5dc966bcaf8f43 IN  0xd79a536581166551b5a4ded9eac6822627e755be0 Ether0.0007902620
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x2bc6c805807d4d840756ae4e6010c52824e409a10b7d696c6544ce46d638ee5b84973812021-04-29 11:20:35431 days 13 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0x2bc6c805807d4d840756ae4e6010c52824e409a10b7d696c6544ce46d638ee5b84973812021-04-29 11:20:35431 days 13 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x168840df293413a930d3d40bab6e1cd8f406719d0 Ether
0x2bc6c805807d4d840756ae4e6010c52824e409a10b7d696c6544ce46d638ee5b84973812021-04-29 11:20:35431 days 13 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x168840df293413a930d3d40bab6e1cd8f406719d0 Ether
0x2bc6c805807d4d840756ae4e6010c52824e409a10b7d696c6544ce46d638ee5b84973812021-04-29 11:20:35431 days 13 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0xb8003d681f75eff19648b76520fd7d963adf4273bc6ff7d2f10e2a53f584ba1a84973632021-04-29 11:16:05431 days 13 hrs ago 0x7115abcca5f0702e177f172c1c14b3f686d6a63a 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0xb8003d681f75eff19648b76520fd7d963adf4273bc6ff7d2f10e2a53f584ba1a84973632021-04-29 11:16:05431 days 13 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0x935c945fe8ef1f0f06543818618cef8a04385ac0477914ad3ae55a8d576c529d84965362021-04-29 7:49:16431 days 16 hrs ago 0x7115abcca5f0702e177f172c1c14b3f686d6a63a 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0x935c945fe8ef1f0f06543818618cef8a04385ac0477914ad3ae55a8d576c529d84965362021-04-29 7:49:16431 days 16 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0x0c762f4a800212064a244e3f48a9a91c70842254667031acced5c3aeba9d194184927692021-04-28 16:07:18432 days 8 hrs ago 0x7115abcca5f0702e177f172c1c14b3f686d6a63a 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0x0c762f4a800212064a244e3f48a9a91c70842254667031acced5c3aeba9d194184927692021-04-28 16:07:18432 days 8 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0x618995f684b8b1aeeb07346e202191c276540f64b4061cda9b338e5ecfa8880784926472021-04-28 15:36:46432 days 8 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0x618995f684b8b1aeeb07346e202191c276540f64b4061cda9b338e5ecfa8880784926472021-04-28 15:36:46432 days 8 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x168840df293413a930d3d40bab6e1cd8f406719d0 Ether
0x618995f684b8b1aeeb07346e202191c276540f64b4061cda9b338e5ecfa8880784926472021-04-28 15:36:46432 days 8 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x168840df293413a930d3d40bab6e1cd8f406719d0 Ether
0x618995f684b8b1aeeb07346e202191c276540f64b4061cda9b338e5ecfa8880784926472021-04-28 15:36:46432 days 8 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0xae714de7379a35d7fa101b8b885d080dcf16f1d3dc22fda1fe140eacededcb7184926342021-04-28 15:33:31432 days 8 hrs ago 0x7115abcca5f0702e177f172c1c14b3f686d6a63a 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0xae714de7379a35d7fa101b8b885d080dcf16f1d3dc22fda1fe140eacededcb7184926342021-04-28 15:33:31432 days 8 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0xdc5b6152ba6399efd6252218d148d027dcb5c2f628324f1305573115769f594684866732021-04-27 14:41:58433 days 9 hrs ago 0x7115abcca5f0702e177f172c1c14b3f686d6a63a 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0xdc5b6152ba6399efd6252218d148d027dcb5c2f628324f1305573115769f594684866732021-04-27 14:41:58433 days 9 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0xf293f1694fbc45d068a8dba1915e1b312414230dd8c2cf2509b321242b5379d784866672021-04-27 14:40:28433 days 9 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0xf293f1694fbc45d068a8dba1915e1b312414230dd8c2cf2509b321242b5379d784866672021-04-27 14:40:28433 days 9 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x168840df293413a930d3d40bab6e1cd8f406719d0 Ether
0xf293f1694fbc45d068a8dba1915e1b312414230dd8c2cf2509b321242b5379d784866672021-04-27 14:40:28433 days 9 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x168840df293413a930d3d40bab6e1cd8f406719d0 Ether
0xf293f1694fbc45d068a8dba1915e1b312414230dd8c2cf2509b321242b5379d784866672021-04-27 14:40:28433 days 9 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0x9edf3c7f776e394dbaf395b583955517434140b09ff593d40850f87db7cece8784866622021-04-27 14:39:13433 days 9 hrs ago 0x7115abcca5f0702e177f172c1c14b3f686d6a63a 0xd79a536581166551b5a4ded9eac6822627e755be0 Ether
0x9edf3c7f776e394dbaf395b583955517434140b09ff593d40850f87db7cece8784866622021-04-27 14:39:13433 days 9 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
0x0f78fe57173556382c4f1e48ca2366d310862defbbcf21782a46422a8ccc16bd84866582021-04-27 14:38:13433 days 9 hrs ago 0xd79a536581166551b5a4ded9eac6822627e755be 0x7115abcca5f0702e177f172c1c14b3f686d6a63a0 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
NftMarket

Compiler Version
v0.6.7+commit.b8d736ae

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion
File 1 of 22 : CrownsToken.sol
// contracts/Crowns.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.7;

import "./../../../../openzeppelin/contracts/access/Ownable.sol";
import "./../../../../openzeppelin/contracts/GSN/Context.sol";
import "./../../../../openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./../../../../openzeppelin/contracts/math/SafeMath.sol";
import "./../../../../openzeppelin/contracts/utils/Address.sol";

/// @title Official token of Blocklords and the Seascape ecosystem.
/// @author Medet Ahmetson
/// @notice Crowns (CWS) is an ERC-20 token with a Rebase feature.
/// Rebasing is a distribution of spent tokens among all current token holders.
/// In order to appear in balance, rebased tokens need to be claimed by users by triggering transaction with the ERC-20 contract.
/// @dev Implementation of the {IERC20} interface.
contract CrownsToken is Context, IERC20, Ownable {
    using SafeMath for uint256;
    using Address for address;

    struct Account {
        uint256 balance;
        uint256 lastRebase;
    }

    mapping (address => Account) private _accounts;
    mapping (address => mapping (address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;
    uint8 private _decimals;

    uint256 private constant _minSpend = 10 ** 6;
    uint256 private constant _decimalFactor = 10 ** 18;
    uint256 private constant _million = 1000000;

    /// @notice Total amount of tokens that have yet to be transferred to token holders as part of a rebase.
    /// @dev Used Variable tracking unclaimed rebase token amounts.
    uint256 public unclaimedRebase = 0;
    /// @notice Amount of tokens spent by users that have not been rebased yet.
    /// @dev Calling the rebase function will move the amount to {totalRebase}
    uint256 public unconfirmedRebase = 0;
    /// @notice Total amount of tokens that were rebased overall.
    /// @dev Total aggregate rebase amount that is always increasing.
    uint256 public totalRebase = 0;

    /**
     * @dev Sets the {name} and {symbol} of token.
     * Initializes {decimals} with a default value of 18.
     * Mints all tokens.
     * Transfers ownership to another account. So, the token creator will not be counted as an owner.
     */
    constructor () public {
        _name = "Crowns";
        _symbol = "CWS";
        _decimals = 18;

        // Grant the minter roles to a specified account
        address inGameAirdropper     = 0xFa4D7D1AC9b7a7454D09B8eAdc35aA70599329EA;
        address rechargeDexManager   = 0x53bd91aEF5e84A61F9B87781A024ee648733f973;
        address teamManager          = 0xB5de2b5186E1Edc947B73019F3102EF53c2Ac691;
        address investManager        = 0x1D3Db9BCA5aa2CE931cE13B7B51f8E14F5895368;
        address communityManager     = 0x0811e2DFb6482507461ca2Ab583844313f2549B5;
        address newOwner             = msg.sender;

        // 3 million tokens
        uint256 inGameAirdrop        = 3 * _million * _decimalFactor;
        uint256 rechargeDex          = inGameAirdrop;
        // 1 million tokens
        uint256 teamAllocation       = 1 * _million * _decimalFactor;
        uint256 investment           = teamAllocation;
        // 750,000 tokens
        uint256 communityBounty      = 750000 * _decimalFactor;
        // 1,25 million tokens
        uint256 inGameReserve        = 1250000 * _decimalFactor; // reserve for the next 5 years.

        _mint(inGameAirdropper,      inGameAirdrop);
        _mint(rechargeDexManager,    rechargeDex);
        _mint(teamManager,           teamAllocation);
        _mint(investManager,         investment);
        _mint(communityManager,      communityBounty);
        _mint(newOwner,              inGameReserve);

        transferOwnership(newOwner);
   }

    /**
     * @notice Return amount of tokens that {account} gets during rebase
     * @dev Used both internally and externally to calculate the rebase amount
     * @param account is an address of token holder to calculate for
     * @return amount of tokens that player could get
     */
    function rebaseOwing (address account) public view returns(uint256) {
        Account memory _account = _accounts[account];

        uint256 newRebase = totalRebase.sub(_account.lastRebase);
        uint256 proportion = _account.balance.mul(newRebase);

        // The rebase is not a part of total supply, since it was moved out of balances
        uint256 supply = _totalSupply.sub(newRebase);

        // rebase owed proportional to current balance of the account.
        // The decimal factor is used to avoid floating issue.
        uint256 rebase = proportion.mul(_decimalFactor).div(supply).div(_decimalFactor);

        return rebase;
    }

    /**
     * @dev Called before any edit of {account} balance.
     * Modifier moves the belonging rebase amount to its balance.
     * @param account is an address of Token holder.
     */
    modifier updateAccount(address account) {
        uint256 owing = rebaseOwing(account);
        _accounts[account].lastRebase = totalRebase;

        if (owing > 0) {
            _accounts[account].balance    = _accounts[account].balance.add(owing);
            unclaimedRebase     = unclaimedRebase.sub(owing);

            emit Transfer(
                address(0),
                account,
                owing
            );
        }

        _;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5,05` (`505 / 10 ** 2`).
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view returns (uint8) {
        return _decimals;
    }

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() public view override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) public view override returns (uint256) {
        return _getBalance(account);
    }

    /**
     * @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) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @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) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @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) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @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) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);
        _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal updateAccount(sender) updateAccount(recipient) virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");
        require(amount > 0, "Can not send 0 token");
        require(_getBalance(sender) >= amount, "ERC20: Not enough token to send");

        _beforeTokenTransfer(sender, recipient, amount);

        _accounts[sender].balance =  _accounts[sender].balance.sub(amount);
        _accounts[recipient].balance = _accounts[recipient].balance.add(amount);

        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply = _totalSupply.add(amount);
        _accounts[account].balance = _accounts[account].balance.add(amount);
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Moves `amount` tokens from `account` to {unconfirmedRebase} without reducing the
     * total supply. Will be rebased among token holders.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal updateAccount(account) virtual {
        require(account != address(0), "ERC20: burn from the zero address");
        require(_getBalance(account) >= amount, "ERC20: Not enough token to burn");

        _beforeTokenTransfer(account, address(0), amount);

        _accounts[account].balance = _accounts[account].balance.sub(amount);

        unconfirmedRebase = unconfirmedRebase.add(amount);

        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
     *
     * This is internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(address owner, address spender, uint256 amount) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

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

    /**
     * @notice Spend some token from caller's balance in the game.
     * @dev Moves `amount` of token from caller to `unconfirmedRebase`.
     * @param amount Amount of token used to spend
     */
    function spend(uint256 amount) public returns(bool) {
        require(amount > _minSpend, "Crowns: trying to spend less than expected");
        require(_getBalance(msg.sender) >= amount, "Crowns: Not enough balance");

        _burn(msg.sender, amount);

	return true;
    }

    function spendFrom(address sender, uint256 amount) public returns(bool) {
	require(amount > _minSpend, "Crowns: trying to spend less than expected");
	require(_getBalance(sender) >= amount, "Crowns: not enough balance");

	_burn(sender, amount);
	_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));

	return true;
    }

    /**
     * @notice Return the rebase amount, when `account` balance was updated.
     */
    function getLastRebase(address account) public view returns (uint256) {
        return _accounts[account].lastRebase;
    }

    /**
     * @dev Returns actual balance of account as a sum of owned divends and current balance.
     * @param account Address of Token holder.
     * @return Token amount
     */
    function _getBalance(address account) private view returns (uint256) {
        uint256 balance = _accounts[account].balance;
    	if (balance == 0) {
    		return 0;
    	}
    	uint256 owing = rebaseOwing(account);

    	return balance.add(owing);
    }

    /**
     * @dev Emitted when `spent` tokens are moved `unconfirmedRebase` to `totalRebase`.
     */
    event Rebase(
        uint256 spent,
        uint256 totalRebase
    );

    /**
     * @notice Rebasing is a unique feature of Crowns (CWS) token. It redistributes tokens spenth within game among all token holders.
     * @dev Moves tokens from {unconfirmedRebase} to {totalRebase}.
     * Any account balance related functions will use {totalRebase} to calculate the dividend shares for each account.
     *
     * Emits a {Rebase} event.
     */
    function rebase() public onlyOwner() returns (bool) {
    	totalRebase = totalRebase.add(unconfirmedRebase);
    	unclaimedRebase = unclaimedRebase.add(unconfirmedRebase);
    	unconfirmedRebase = 0;

        emit Rebase (
            unconfirmedRebase,
            totalRebase
        );

        return true;
    }
}

File 2 of 22 : NftMarket.sol
pragma solidity ^0.6.7;

pragma experimental ABIEncoderV2;


import "./../openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./../openzeppelin/contracts/math/SafeMath.sol";
import "./../openzeppelin/contracts/token/ERC721/IERC721.sol";
import "./../openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "./../openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./../crowns/erc-20/contracts/CrownsToken/CrownsToken.sol";
import "./../openzeppelin/contracts/access/Ownable.sol";
import "./../seascape_nft/SeascapeNft.sol";
import "./ReentrancyGuard.sol";



contract NftMarket is IERC721Receiver,  ReentrancyGuard, Ownable {

    using SafeERC20 for IERC20;
    using SafeMath for uint256;

    // seascape token
    IERC20 public crowns;
    SeascapeNft private nft;

    struct SalesObject {
        uint256 id;               // object id
        uint256 tokenId;
        uint256 startTime;        // timestamp when the sale starts
        uint256 price;
        uint8 status;             // 2 = sale canceled, 1 = sold, 0 = for sale
        address payable seller;   // seller address
        address payable buyer;    // buyer address
    }


    uint256 public _salesAmount;   // keeps count of sales

    SalesObject[] _salesObjects;  // store sales in an array

    mapping(uint256 => uint256) public nftIdToIndex;

    mapping(address => bool) public _supportNft;
    bool public _isStartUserSales;  // enable/disable trading

    uint256 public _tipsFeeRate; // feeAmount = (_tipsFeeRate / 1000) * price
    address payable _tipsFeeWallet; // reciever of fees

    event Buy(
        uint256 indexed id,
        uint256 tokenId,
        address buyer,
        uint256 price,
        uint256 tipsFee
    );

    event Sell(
        uint256 indexed id,
        uint256 tokenId,
        address seller,
        address buyer,
        uint256 startTime,
        uint256 price
    );

    event SaleCanceled(
        uint256 indexed id,
        uint256 tokenId
    );

    event NftReceived(address operator, address from, uint256 tokenId, bytes data);


    constructor(address _crowns, address _nft,
      address payable tipsFeeWallet, uint256 tipsFeeRate) public {
      _tipsFeeWallet = tipsFeeWallet;
      _tipsFeeRate = tipsFeeRate;
      crowns = IERC20(_crowns);
      nft = SeascapeNft(_nft);
      initReentrancyStatus();
    }

    // recieve tokens
    receive() external payable { }
    //@note Prefer using a receive function only, whenever possible
    //fallback() external [payable] { }


    // index cant be higher than sales amsellingount
    modifier checkIndex(uint index) {
        require(index <= _salesObjects.length, "overflow");
        _;
    }


  // enable/disable trading
  function setIsStartUserSales(bool isStartUserSales) public onlyOwner {
      _isStartUserSales = isStartUserSales;
  }

  // set address to recieve fees
  function setTipsFeeWallet(address payable wallet) public onlyOwner {
      _tipsFeeWallet = wallet;
  }

  // adjust tips rate in percents
  function setTipsFeeRate(uint256 rate) external onlyOwner {
      _tipsFeeRate = rate;
  }

  function getSalesAmount() external returns(uint) {
    return _salesAmount;
  }

  function getSalesByNftId(uint tokenId) public {
    uint index = nftIdToIndex[tokenId];
    getSales(index);
  }

  // returns sales by index
  function getSales(uint index) public view checkIndex(index) returns(SalesObject memory) {
      return _salesObjects[index];
  }


  // returns just the price of sale by index - may be deleted
  function getSalesPrice(uint index)
      external
      view
      checkIndex(index)
      returns (uint256)
  {
      SalesObject storage obj = _salesObjects[index];
      return obj.price;
  }

  function cancelSalesByNftId(uint tokenId, address currency) public {
    uint index = nftIdToIndex[tokenId];
    cancelSales(index);
  }

  // cancel a sale - only nft owner can call
  function cancelSales(uint index)
    public
    checkIndex(index)
    nonReentrant
    {
      SalesObject storage obj = _salesObjects[index];
      require(obj.status == 0, "sorry, selling out");
      require(obj.seller == msg.sender || msg.sender == owner(), "author & owner");
      require(_isStartUserSales, "cannot sales");
      obj.status = 2;
      nft.safeTransferFrom(address(this), obj.seller, obj.tokenId);

      emit SaleCanceled(index, obj.tokenId);
  }

  function startSalesByNftId(uint256 tokenId, uint256 price, address currency) public {
    uint index = nftIdToIndex[tokenId];
    startSales(index, price, currency);
  }

  // put nft for sale
  function startSales(uint256 tokenId,
                      uint256 price,
                      address currency)
      public
      nonReentrant
      returns(uint)
  {
      require(tokenId != 0, "invalid token");
      require(_isStartUserSales, "cannot sales");

      nft.safeTransferFrom(msg.sender, address(this), tokenId);

      _salesAmount++;
      SalesObject memory obj;

      obj.id = _salesAmount;
      obj.tokenId = tokenId;
      obj.seller = msg.sender;
      obj.buyer = address(0x0);
      obj.startTime = now;
      obj.price = price;
      obj.status = 0;

      _salesObjects.push(obj);

      nftIdToIndex[tokenId] = _salesAmount - 1;

      uint256 tmpPrice = price;
      emit Sell(obj.id, tokenId, msg.sender, address(0x0), now, tmpPrice);
      return _salesAmount;
  }

  // upon transfer, log nft reciept
  function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public override returns (bytes4) {
     //only receive the _nft staff
     if(address(this) != operator) {
         //invalid from nft
         return 0;
     }

     //success
     emit NftReceived(operator, from, tokenId, data);
     return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
  }


  function buyByNftId(uint tokenId, address currency) public {
    uint index = nftIdToIndex[tokenId];
    buy(index, currency);
  }

  // buy nft
  function buy(uint index, address currency)
      public
      nonReentrant
      checkIndex(index)
      payable
  {
    SalesObject storage obj = _salesObjects[index];
    require(obj.status == 0, "sorry, selling out");
    require(obj.startTime <= now, "!open");
    require(_isStartUserSales, "cannot sales");

    uint256 price = this.getSalesPrice(index);
    uint256 tipsFee = price.mul(_tipsFeeRate).div(1000);
    uint256 purchase = price.sub(tipsFee);

    if (currency == address(0x0)){
        require (msg.value >= this.getSalesPrice(index), "umm.....  your price is too low");
        uint256 returnBack = msg.value.sub(price);
        if(returnBack > 0) {
            msg.sender.transfer(returnBack);
        }
        if(tipsFee > 0) {
            _tipsFeeWallet.transfer(tipsFee);
        }
        obj.seller.transfer(purchase);
    }
    else{
        IERC20(currency).safeTransferFrom(msg.sender, _tipsFeeWallet, tipsFee);
        IERC20(currency).safeTransferFrom(msg.sender, obj.seller, purchase);
    }

      nft.safeTransferFrom(address(this), msg.sender, obj.tokenId);
      obj.buyer = msg.sender;
      //obj.finalPrice = price;

      obj.status = 1;
      emit Buy(index, obj.tokenId, msg.sender, price, tipsFee);
  }

}

File 3 of 22 : ReentrancyGuard.sol
// File: contracts/library/ReentrancyGuard.sol

pragma solidity ^0.6.7;

contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

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

    uint256 private _status;

    constructor() internal {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

    function initReentrancyStatus() internal {
        _status = _NOT_ENTERED;
    }
}

File 4 of 22 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

File 5 of 22 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

File 6 of 22 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "./IERC165.sol";

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

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

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

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

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

File 7 of 22 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

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

pragma solidity ^0.6.0;

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

        return c;
    }

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

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

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

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

    // Base URI
    string private _baseURI;

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

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

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

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

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

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

        return _holderTokens[owner].length();
    }

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

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

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

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

        string memory _tokenURI = _tokenURIs[tokenId];

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

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

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

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

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

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

        _holderTokens[owner].remove(tokenId);

        _tokenOwners.remove(tokenId);

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

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

        _beforeTokenTransfer(from, to, tokenId);

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

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

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

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

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

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

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

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

File 12 of 22 : ERC721Burnable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../../GSN/Context.sol";
import "./ERC721.sol";

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be irreversibly burned (destroyed).
 */
abstract contract ERC721Burnable is Context, ERC721 {
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
        _burn(tokenId);
    }
}

File 13 of 22 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 14 of 22 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

import "./IERC721.sol";

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

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

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

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

File 15 of 22 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

import "./IERC721.sol";

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

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

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

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

File 16 of 22 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

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

File 17 of 22 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.2;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

pragma solidity ^0.6.0;

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

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

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

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

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

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

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

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

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

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

            MapEntry storage lastEntry = map._entries[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

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

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

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

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

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

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

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

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

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

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

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

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

pragma solidity ^0.6.0;

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

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

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

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

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

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

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

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

            bytes32 lastvalue = set._values[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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


    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

pragma solidity ^0.6.0;

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

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

File 22 of 22 : SeascapeNft.sol
// Seascape NFT
// SPDX-License-Identifier: MIT
pragma solidity 0.6.7;

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

/// @author Medet Ahmetson
contract SeascapeNft is ERC721, ERC721Burnable, Ownable {
    using Counters for Counters.Counter;

    Counters.Counter private tokenId;

    struct Params {
	uint256 quality;   // seascape points
	uint8 generation;
    }

    address private factory;

    mapping(uint256 => Params) public paramsOf;

    event Minted(address indexed owner, uint256 indexed id, uint256 generation, uint8 quality);
    
    /**
     * @dev Sets the {name} and {symbol} of token.
     * Initializes {decimals} with a default value of 18.
     * Mints all tokens.
     * Transfers ownership to another account. So, the token creator will not be counted as an owner.
     */
    constructor() public ERC721("Seascape NFT", "SCAPES") {
	tokenId.increment();
    }

    modifier onlyFactory() {
	require(factory == _msgSender(), "Seascape NFT: Only NFT Factory can call the method");
	_;
    }

    function mint(address _to, uint256 _generation, uint8 _quality) public onlyFactory returns(uint256) {
	uint256 _tokenId = tokenId.current();

	_safeMint(_to, _tokenId);

	paramsOf[_tokenId] = Params(_generation, _quality);

	tokenId.increment();

	emit Minted(_to, _tokenId, _generation, _quality);
	return _tokenId;
    }

    function setOwner(address _owner) public onlyOwner {
	transferOwnership(_owner);
    }

    function setFactory(address _factory) public onlyOwner {
	factory = _factory;
    }

    function setBaseUri(string memory _uri) public onlyOwner {
	_setBaseURI(_uri);
    }
}

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

Contract ABI

[{"inputs":[{"internalType":"address","name":"_crowns","type":"address"},{"internalType":"address","name":"_nft","type":"address"},{"internalType":"address payable","name":"tipsFeeWallet","type":"address"},{"internalType":"uint256","name":"tipsFeeRate","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tipsFee","type":"uint256"}],"name":"Buy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"NftReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"SaleCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"Sell","type":"event"},{"inputs":[],"name":"_isStartUserSales","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_salesAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_supportNft","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_tipsFeeRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"address","name":"currency","type":"address"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"currency","type":"address"}],"name":"buyByNftId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"cancelSales","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"currency","type":"address"}],"name":"cancelSalesByNftId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"crowns","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getSales","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint8","name":"status","type":"uint8"},{"internalType":"address payable","name":"seller","type":"address"},{"internalType":"address payable","name":"buyer","type":"address"}],"internalType":"struct NftMarket.SalesObject","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSalesAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getSalesByNftId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getSalesPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nftIdToIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"isStartUserSales","type":"bool"}],"name":"setIsStartUserSales","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rate","type":"uint256"}],"name":"setTipsFeeRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"wallet","type":"address"}],"name":"setTipsFeeWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"currency","type":"address"}],"name":"startSales","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"currency","type":"address"}],"name":"startSalesByNftId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b50604051620033833803806200338383398181016040528101906200003791906200022b565b6001600081905550600062000051620001d460201b60201c565b905080600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35081600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060098190555083600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555082600360006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550620001ca620001dc60201b60201c565b5050505062000337565b600033905090565b6001600081905550565b600081519050620001f781620002e9565b92915050565b6000815190506200020e8162000303565b92915050565b60008151905062000225816200031d565b92915050565b600080600080608085870312156200024257600080fd5b60006200025287828801620001e6565b94505060206200026587828801620001e6565b93505060406200027887828801620001fd565b92505060606200028b8782880162000214565b91505092959194509250565b6000620002a482620002bf565b9050919050565b6000620002b882620002bf565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b620002f48162000297565b81146200030057600080fd5b50565b6200030e81620002ab565b81146200031a57600080fd5b50565b6200032881620002df565b81146200033457600080fd5b50565b61303c80620003476000396000f3fe6080604052600436106101445760003560e01c80637deb6025116100b6578063c211b7051161006f578063c211b7051461046c578063ccd8a07914610495578063e70319aa146104be578063ea5ed05d146104e7578063f2fde38b14610512578063fbcdb2a01461053b5761014b565b80637deb60251461037d5780638da5cb5b14610399578063942ec85a146103c4578063a08a1a59146103ed578063a6883f6f14610418578063c0b2687a146104415761014b565b80633f262d77116101085780633f262d771461025b5780634341a9eb146102985780635a0b27e5146102c15780636f905b78146102fe578063715018a61461033b57806373616bb8146103525761014b565b80630d9262e114610150578063150b7a021461017b5780631d73cf34146101b8578063315f6de1146101f5578063357c51721461021e5761014b565b3661014b57005b600080fd5b34801561015c57600080fd5b50610165610564565b6040516101729190612d10565b60405180910390f35b34801561018757600080fd5b506101a2600480360381019061019d9190612267565b61056e565b6040516101af9190612afd565b60405180910390f35b3480156101c457600080fd5b506101df60048036038101906101da9190612215565b61060b565b6040516101ec9190612ae2565b60405180910390f35b34801561020157600080fd5b5061021c60048036038101906102179190612334565b61062b565b005b34801561022a57600080fd5b50610245600480360381019061024091906123c2565b6106cc565b6040516102529190612d10565b60405180910390f35b34801561026757600080fd5b50610282600480360381019061027d9190612334565b610a8a565b60405161028f9190612d10565b60405180910390f35b3480156102a457600080fd5b506102bf60048036038101906102ba91906123c2565b610aa2565b005b3480156102cd57600080fd5b506102e860048036038101906102e39190612334565b610acc565b6040516102f59190612d10565b60405180910390f35b34801561030a57600080fd5b5061032560048036038101906103209190612334565b610b44565b6040516103329190612cf5565b60405180910390f35b34801561034757600080fd5b50610350610cb4565b005b34801561035e57600080fd5b50610367610e0c565b6040516103749190612ae2565b60405180910390f35b61039760048036038101906103929190612386565b610e1f565b005b3480156103a557600080fd5b506103ae6114c9565b6040516103bb9190612a0d565b60405180910390f35b3480156103d057600080fd5b506103eb60048036038101906103e69190612334565b6114f3565b005b3480156103f957600080fd5b5061040261183e565b60405161040f9190612d10565b60405180910390f35b34801561042457600080fd5b5061043f600480360381019061043a919061223e565b611844565b005b34801561044d57600080fd5b5061045661191f565b6040516104639190612d10565b60405180910390f35b34801561047857600080fd5b50610493600480360381019061048e91906122e2565b611925565b005b3480156104a157600080fd5b506104bc60048036038101906104b79190612334565b6119d9565b005b3480156104ca57600080fd5b506104e560048036038101906104e09190612386565b6119ff565b005b3480156104f357600080fd5b506104fc611a26565b6040516105099190612b18565b60405180910390f35b34801561051e57600080fd5b5061053960048036038101906105349190612215565b611a4c565b005b34801561054757600080fd5b50610562600480360381019061055d9190612386565b611c13565b005b6000600454905090565b60008473ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff16146105af57600060e01b9050610603565b7f0895c277367ff99b8c0dec875f3149fc2c82df592f63ca6f0747ac2095169087858585856040516105e49493929190612a96565b60405180910390a16040516105f8906129f8565b604051809103902090505b949350505050565b60076020528060005260406000206000915054906101000a900460ff1681565b610633611c39565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146106c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106b990612bf5565b60405180910390fd5b8060098190555050565b600060026000541415610714576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070b90612cd5565b60405180910390fd5b60026000819055506000841415610760576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161075790612bd5565b60405180910390fd5b600860009054906101000a900460ff166107af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a690612b95565b60405180910390fd5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342842e0e3330876040518463ffffffff1660e01b815260040161080e93929190612a28565b600060405180830381600087803b15801561082857600080fd5b505af115801561083c573d6000803e3d6000fd5b5050505060046000815480929190600101919050555061085a6120d7565b60045481600001818152505084816020018181525050338160a0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505060008160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505042816040018181525050838160600181815250506000816080019060ff16908160ff168152505060058190806001815401808255809150506001900390600052602060002090600602016000909190919091506000820151816000015560208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a81548160ff021916908360ff16021790555060a08201518160040160016101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060c08201518160050160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050506001600454036006600087815260200190815260200160002081905550600084905081600001517fca286f850f225ef01627405408cd28c0ac8d1479e6626a0131a39f1351af1603873360004286604051610a6c959493929190612d2b565b60405180910390a26004549250505060016000819055509392505050565b60066020528060005260406000206000915090505481565b600060066000858152602001908152602001600020549050610ac58184846106cc565b5050505050565b600081600580549050811115610b17576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0e90612c95565b60405180910390fd5b600060058481548110610b2657fe5b90600052602060002090600602019050806003015492505050919050565b610b4c6120d7565b81600580549050811115610b95576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b8c90612c95565b60405180910390fd5b60058381548110610ba257fe5b90600052602060002090600602016040518060e0016040529081600082015481526020016001820154815260200160028201548152602001600382015481526020016004820160009054906101000a900460ff1660ff1660ff1681526020016004820160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016005820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681525050915050919050565b610cbc611c39565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610d4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d4290612bf5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b600860009054906101000a900460ff1681565b60026000541415610e65576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e5c90612cd5565b60405180910390fd5b600260008190555081600580549050811115610eb6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ead90612c95565b60405180910390fd5b600060058481548110610ec557fe5b9060005260206000209060060201905060008160040160009054906101000a900460ff1660ff1614610f2c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f2390612b55565b60405180910390fd5b4281600201541115610f73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f6a90612cb5565b60405180910390fd5b600860009054906101000a900460ff16610fc2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fb990612b95565b60405180910390fd5b60003073ffffffffffffffffffffffffffffffffffffffff16635a0b27e5866040518263ffffffff1660e01b8152600401610ffd9190612d10565b60206040518083038186803b15801561101557600080fd5b505afa158015611029573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104d919061235d565b9050600061107a6103e861106c60095485611c4190919063ffffffff16565b611cb190919063ffffffff16565b905060006110918284611cfb90919063ffffffff16565b9050600073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614156112df573073ffffffffffffffffffffffffffffffffffffffff16635a0b27e5886040518263ffffffff1660e01b81526004016111019190612d10565b60206040518083038186803b15801561111957600080fd5b505afa15801561112d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611151919061235d565b341015611193576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118a90612c75565b60405180910390fd5b60006111a88434611cfb90919063ffffffff16565b905060008111156111fb573373ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156111f9573d6000803e3d6000fd5b505b600083111561126e57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f1935050505015801561126c573d6000803e3d6000fd5b505b8460040160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166108fc839081150290604051600060405180830381858888f193505050501580156112d8573d6000803e3d6000fd5b5050611380565b61132e33600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16848973ffffffffffffffffffffffffffffffffffffffff16611d45909392919063ffffffff16565b61137f338560040160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff16838973ffffffffffffffffffffffffffffffffffffffff16611d45909392919063ffffffff16565b5b600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342842e0e303387600101546040518463ffffffff1660e01b81526004016113e393929190612a28565b600060405180830381600087803b1580156113fd57600080fd5b505af1158015611411573d6000803e3d6000fd5b50505050338460050160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060018460040160006101000a81548160ff021916908360ff160217905550867f4f5841c14d8fb6438d032b715493c21095339919ae0fcf5a69af900bd484c3b785600101543386866040516114b09493929190612d7e565b60405180910390a2505050505060016000819055505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b8060058054905081111561153c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161153390612c95565b60405180910390fd5b60026000541415611582576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161157990612cd5565b60405180910390fd5b600260008190555060006005838154811061159957fe5b9060005260206000209060060201905060008160040160009054906101000a900460ff1660ff1614611600576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115f790612b55565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff168160040160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16148061169057506116616114c9565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b6116cf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116c690612c35565b60405180910390fd5b600860009054906101000a900460ff1661171e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161171590612b95565b60405180910390fd5b60028160040160006101000a81548160ff021916908360ff160217905550600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166342842e0e308360040160019054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684600101546040518463ffffffff1660e01b81526004016117c393929190612a28565b600060405180830381600087803b1580156117dd57600080fd5b505af11580156117f1573d6000803e3d6000fd5b50505050827ff47bd6ad197977120284fd5ccd8b99b59816009cd45e58894d3644a66c3fdb1182600101546040516118299190612d10565b60405180910390a25060016000819055505050565b60045481565b61184c611c39565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146118db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118d290612bf5565b60405180910390fd5b80600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60095481565b61192d611c39565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146119bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b390612bf5565b60405180910390fd5b80600860006101000a81548160ff02191690831515021790555050565b6000600660008381526020019081526020016000205490506119fa81610b44565b505050565b600060066000848152602001908152602001600020549050611a218183610e1f565b505050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b611a54611c39565b73ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611ae3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ada90612bf5565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611b53576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b4a90612b75565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600060066000848152602001908152602001600020549050611c34816114f3565b505050565b600033905090565b600080831415611c545760009050611cab565b6000828402905082848281611c6557fe5b0414611ca6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c9d90612bb5565b60405180910390fd5b809150505b92915050565b6000611cf383836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611dce565b905092915050565b6000611d3d83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611e2f565b905092915050565b611dc8846323b872dd60e01b858585604051602401611d6693929190612a5f565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611e8a565b50505050565b60008083118290611e15576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0c9190612b33565b60405180910390fd5b506000838581611e2157fe5b049050809150509392505050565b6000838311158290611e77576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e6e9190612b33565b60405180910390fd5b5060008385039050809150509392505050565b6060611eec826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611f519092919063ffffffff16565b9050600081511115611f4c5780806020019051810190611f0c919061230b565b611f4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f4290612c55565b60405180910390fd5b5b505050565b6060611f608484600085611f69565b90509392505050565b6060611f748561208c565b611fb3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611faa90612c15565b60405180910390fd5b600060608673ffffffffffffffffffffffffffffffffffffffff168587604051611fdd91906129e1565b60006040518083038185875af1925050503d806000811461201a576040519150601f19603f3d011682016040523d82523d6000602084013e61201f565b606091505b50915091508115612034578092505050612084565b6000815111156120475780518082602001fd5b836040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161207b9190612b33565b60405180910390fd5b949350505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f91508082141580156120ce57506000801b8214155b92505050919050565b6040518060e0016040528060008152602001600081526020016000815260200160008152602001600060ff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff1681525090565b60008135905061215281612faa565b92915050565b60008135905061216781612fc1565b92915050565b60008135905061217c81612fd8565b92915050565b60008151905061219181612fd8565b92915050565b600082601f8301126121a857600080fd5b81356121bb6121b682612df0565b612dc3565b915080825260208301602083018583830111156121d757600080fd5b6121e2838284612f57565b50505092915050565b6000813590506121fa81612fef565b92915050565b60008151905061220f81612fef565b92915050565b60006020828403121561222757600080fd5b600061223584828501612143565b91505092915050565b60006020828403121561225057600080fd5b600061225e84828501612158565b91505092915050565b6000806000806080858703121561227d57600080fd5b600061228b87828801612143565b945050602061229c87828801612143565b93505060406122ad878288016121eb565b925050606085013567ffffffffffffffff8111156122ca57600080fd5b6122d687828801612197565b91505092959194509250565b6000602082840312156122f457600080fd5b60006123028482850161216d565b91505092915050565b60006020828403121561231d57600080fd5b600061232b84828501612182565b91505092915050565b60006020828403121561234657600080fd5b6000612354848285016121eb565b91505092915050565b60006020828403121561236f57600080fd5b600061237d84828501612200565b91505092915050565b6000806040838503121561239957600080fd5b60006123a7858286016121eb565b92505060206123b885828601612143565b9150509250929050565b6000806000606084860312156123d757600080fd5b60006123e5868287016121eb565b93505060206123f6868287016121eb565b925050604061240786828701612143565b9150509250925092565b61241a81612efd565b82525050565b61242981612e7c565b82525050565b61243881612e6a565b82525050565b61244781612e8e565b82525050565b61245681612e9a565b82525050565b600061246782612e1c565b6124718185612e32565b9350612481818560208601612f66565b61248a81612f99565b840191505092915050565b60006124a082612e1c565b6124aa8185612e43565b93506124ba818560208601612f66565b80840191505092915050565b6124cf81612f0f565b82525050565b60006124e082612e27565b6124ea8185612e4e565b93506124fa818560208601612f66565b61250381612f99565b840191505092915050565b600061251b601283612e4e565b91507f736f7272792c2073656c6c696e67206f757400000000000000000000000000006000830152602082019050919050565b600061255b602f83612e5f565b91507f6f6e455243373231526563656976656428616464726573732c6164647265737360008301527f2c75696e743235362c62797465732900000000000000000000000000000000006020830152602f82019050919050565b60006125c1602683612e4e565b91507f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008301527f64647265737300000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000612627600c83612e4e565b91507f63616e6e6f742073616c657300000000000000000000000000000000000000006000830152602082019050919050565b6000612667602183612e4e565b91507f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f60008301527f77000000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b60006126cd600d83612e4e565b91507f696e76616c696420746f6b656e000000000000000000000000000000000000006000830152602082019050919050565b600061270d602083612e4e565b91507f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726000830152602082019050919050565b600061274d601d83612e4e565b91507f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006000830152602082019050919050565b600061278d600e83612e4e565b91507f617574686f722026206f776e65720000000000000000000000000000000000006000830152602082019050919050565b60006127cd602a83612e4e565b91507f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008301527f6f742073756363656564000000000000000000000000000000000000000000006020830152604082019050919050565b6000612833601f83612e4e565b91507f756d6d2e2e2e2e2e2020796f757220707269636520697320746f6f206c6f77006000830152602082019050919050565b6000612873600883612e4e565b91507f6f766572666c6f770000000000000000000000000000000000000000000000006000830152602082019050919050565b60006128b3600583612e4e565b91507f216f70656e0000000000000000000000000000000000000000000000000000006000830152602082019050919050565b60006128f3601f83612e4e565b91507f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006000830152602082019050919050565b60e08201600082015161293c60008501826129b4565b50602082015161294f60208501826129b4565b50604082015161296260408501826129b4565b50606082015161297560608501826129b4565b50608082015161298860808501826129d2565b5060a082015161299b60a0850182612420565b5060c08201516129ae60c0850182612420565b50505050565b6129bd81612ee6565b82525050565b6129cc81612ee6565b82525050565b6129db81612ef0565b82525050565b60006129ed8284612495565b915081905092915050565b6000612a038261254e565b9150819050919050565b6000602082019050612a22600083018461242f565b92915050565b6000606082019050612a3d6000830186612411565b612a4a6020830185612411565b612a5760408301846129c3565b949350505050565b6000606082019050612a74600083018661242f565b612a81602083018561242f565b612a8e60408301846129c3565b949350505050565b6000608082019050612aab600083018761242f565b612ab8602083018661242f565b612ac560408301856129c3565b8181036060830152612ad7818461245c565b905095945050505050565b6000602082019050612af7600083018461243e565b92915050565b6000602082019050612b12600083018461244d565b92915050565b6000602082019050612b2d60008301846124c6565b92915050565b60006020820190508181036000830152612b4d81846124d5565b905092915050565b60006020820190508181036000830152612b6e8161250e565b9050919050565b60006020820190508181036000830152612b8e816125b4565b9050919050565b60006020820190508181036000830152612bae8161261a565b9050919050565b60006020820190508181036000830152612bce8161265a565b9050919050565b60006020820190508181036000830152612bee816126c0565b9050919050565b60006020820190508181036000830152612c0e81612700565b9050919050565b60006020820190508181036000830152612c2e81612740565b9050919050565b60006020820190508181036000830152612c4e81612780565b9050919050565b60006020820190508181036000830152612c6e816127c0565b9050919050565b60006020820190508181036000830152612c8e81612826565b9050919050565b60006020820190508181036000830152612cae81612866565b9050919050565b60006020820190508181036000830152612cce816128a6565b9050919050565b60006020820190508181036000830152612cee816128e6565b9050919050565b600060e082019050612d0a6000830184612926565b92915050565b6000602082019050612d2560008301846129c3565b92915050565b600060a082019050612d4060008301886129c3565b612d4d6020830187612411565b612d5a6040830186612411565b612d6760608301856129c3565b612d7460808301846129c3565b9695505050505050565b6000608082019050612d9360008301876129c3565b612da06020830186612411565b612dad60408301856129c3565b612dba60608301846129c3565b95945050505050565b6000604051905081810181811067ffffffffffffffff82111715612de657600080fd5b8060405250919050565b600067ffffffffffffffff821115612e0757600080fd5b601f19601f8301169050602081019050919050565b600081519050919050565b600081519050919050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b6000612e7582612ec6565b9050919050565b6000612e8782612ec6565b9050919050565b60008115159050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b6000612f0882612f33565b9050919050565b6000612f1a82612f21565b9050919050565b6000612f2c82612ec6565b9050919050565b6000612f3e82612f45565b9050919050565b6000612f5082612ec6565b9050919050565b82818337600083830152505050565b60005b83811015612f84578082015181840152602081019050612f69565b83811115612f93576000848401525b50505050565b6000601f19601f8301169050919050565b612fb381612e6a565b8114612fbe57600080fd5b50565b612fca81612e7c565b8114612fd557600080fd5b50565b612fe181612e8e565b8114612fec57600080fd5b50565b612ff881612ee6565b811461300357600080fd5b5056fea26469706673582212204252d61e930c70bbec0963f848f7424fe617094d47674312e3be3079ff3ce17364736f6c63430006070033000000000000000000000000168840df293413a930d3d40bab6e1cd8f406719d0000000000000000000000007115abcca5f0702e177f172c1c14b3f686d6a63a0000000000000000000000005bded8f6bdae766c361edae25c5dc966bcaf8f430000000000000000000000000000000000000000000000000000000000000064

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

000000000000000000000000168840df293413a930d3d40bab6e1cd8f406719d0000000000000000000000007115abcca5f0702e177f172c1c14b3f686d6a63a0000000000000000000000005bded8f6bdae766c361edae25c5dc966bcaf8f430000000000000000000000000000000000000000000000000000000000000064

-----Decoded View---------------
Arg [0] : _crowns (address): 0x168840df293413a930d3d40bab6e1cd8f406719d
Arg [1] : _nft (address): 0x7115abcca5f0702e177f172c1c14b3f686d6a63a
Arg [2] : tipsFeeWallet (address): 0x5bded8f6bdae766c361edae25c5dc966bcaf8f43
Arg [3] : tipsFeeRate (uint256): 100

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000168840df293413a930d3d40bab6e1cd8f406719d
Arg [1] : 0000000000000000000000007115abcca5f0702e177f172c1c14b3f686d6a63a
Arg [2] : 0000000000000000000000005bded8f6bdae766c361edae25c5dc966bcaf8f43
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000064


Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading

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