Contract 0xa84108b2d248e0991b5c214db29ceab989f0bea1

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x59f20e2b49cbe24d31b03eda64294cd427df9f30bfffc3776558d09982bd2cdbSettle Tax300476432022-06-27 5:35:5990 days 4 hrs ago0x2af159c310e5ba57c5c0936b65267267b9c89e47 IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.005018185536 91.567715942
0x45f60bd80c8f8fd0c0302ff7ecc5cb0be74bdf50d9bc911c093049c2c78a4ad9Set Pixel293799502022-06-10 3:11:48107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.002188650001 30.000000023
0xbf573c8d5c2545664aa302d798e83aac2fc92bf886310e192c0a290c301db5a4Set Pixel293799502022-06-10 3:11:48107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.002188290001 30.000000023
0xdfc51e72bde42213c8149b83bfb9513125919e967cc1c3473161d3e20df931c6Set Pixel293799502022-06-10 3:11:48107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.002188290001 30.000000023
0xad8ac79c051e0e88aa5fe920197673b09860a86a78f753090a6d777278b830e7Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001527630001 30.000000024
0x62e3b864280de1dbc50dff92b43f22cf704d271fd09e9e5e8bde835d3918f4dfSet Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001527630001 30.000000024
0xd8a677fbfb6e67c165c50ffd107e1055daabf80631fb14a3e85afcd6eb2f1837Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001495140001 30.000000024
0x3ac86291baf6625808be41304222041a694a32ca08a787ab29964ccbf20b07f5Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001495140001 30.000000024
0xd1ea7435f9a4c1031313ab0d089ea08347e567e5aa5087ad0db7d9100a026221Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001495140001 30.000000024
0xcaf822f7d0bbcd94a6d4b17dc7ce541c22550f591cf0dfd919ab401d2498a719Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001495140001 30.000000024
0x54463930f875af65a2f8ac068b8995c89b2fbcc1cefe0b1830fd1f692d295f51Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001514880376 30.396090868
0xa90aab055c13850044eb000523f3b8fe74722b1040c01fac8152463344f380a5Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001678867548 33.686495206
0xbb051287ed12fd0ec7ddd04c6c387608d731960d68a528b2ef68ea6928e2fd8cSet Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001545796302 31.016419252
0xef0ebfa32fd0e028f9f9accce027ca35fc1d742b1292881e0dc15d8d31c8de27Set Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001592002443 31.943545958
0x70652f67227f95fe0451344bdc1e69ee271f11615c53a67b2bdd631570d50fdeSet Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001495140001 30.000000024
0x094b5273af8814b7dee284fa041cb57ad4d51c6bc95fb424a2d8bde7ed49303bSet Pixel293799492022-06-10 3:11:46107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001691999621 33.949990389
0x41010088df96a092bff3c6cdb35110c353d61db088c059fe08d27a34fffb40c2Set Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001746084492 35.035203911
0xb0d688b40f4631c4017fbfc6c0d167ed85208bf76bd7d1f47f8b3acdb0000b90Set Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001818644704 36.491125339
0x082258cf65c72b6842bde89b11106cd884e7f6b4428e81cfd21065a5b4c55156Set Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001913154538 38.387466167
0xd85ac152fcd318491236a64e0e0fd9f63aa740d8a1548d7e32f3bab66cf06866Set Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.00149862832 30.069993192
0x98de998562389ce32bc8af018bd6c17ac5f366a7b54e8df25ecf99657c62b64cSet Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.00149862832 30.069993192
0x171f95539829df23018608383e4aace5c455ec3b8f1c6695b8ed5cda299c5aefSet Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.002065800702 41.450313074
0x3246b757fd0c8fc54ea7874b4b4b2caadf9244a44f8368660741539bac57f4a6Set Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.002065800702 41.450313074
0xbf989efbf9555f3115e1770324e48705636801cd45ed221ab5445cfc61107179Set Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001513357752 30.365539395
0xb61b4bbe5fc24e0acbf58bbeb5af2278e22ad358b1be82a1019304487dc50aafSet Pixel293799482022-06-10 3:11:44107 days 7 hrs ago0x2f1d205b16d3e99e6e9430716e4a4fa01cf4914e IN  0xa84108b2d248e0991b5c214db29ceab989f0bea10 MATIC0.001498628582 30.069998451
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0xeeb332aea55eafb86b33e61b98453288b950d571592af2d01c2ee60a3bc58c41289815632022-05-31 6:14:35117 days 4 hrs ago 0xa84108b2d248e0991b5c214db29ceab989f0bea1  Contract Creation0 MATIC
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
TheSpace

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 26 : TheSpace.sol
//SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/utils/Multicall.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import "./ACLManager.sol";
import "./TheSpaceRegistry.sol";
import "./ITheSpaceRegistry.sol";
import "./ITheSpace.sol";

contract TheSpace is ITheSpace, Multicall, ReentrancyGuard, ACLManager {
    TheSpaceRegistry public registry;

    // token image shared by all tokens
    string public tokenImageURI = "ipfs://";

    constructor(
        address currencyAddress_,
        string memory tokenImageURI_,
        address aclManager_,
        address marketAdmin_,
        address treasuryAdmin_
    ) ACLManager(aclManager_, marketAdmin_, treasuryAdmin_) {
        registry = new TheSpaceRegistry(
            "Planck", // property name
            "PLK", // property symbol
            1000000, // total supply
            12, // taxRate
            0, // treasuryShare
            1 * (10**uint256(ERC20(currencyAddress_).decimals())), // mintTax, 1 $SPACE
            currencyAddress_
        );

        tokenImageURI = tokenImageURI_;
    }

    /**
     * @notice See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId_) external view virtual returns (bool) {
        return interfaceId_ == type(ITheSpace).interfaceId;
    }

    //////////////////////////////
    /// Upgradability
    //////////////////////////////

    /// @inheritdoc ITheSpace
    function upgradeTo(address newImplementation) external onlyRole(Role.aclManager) {
        registry.transferOwnership(newImplementation);
    }

    //////////////////////////////
    /// Configuration / Admin
    //////////////////////////////

    function setTotalSupply(uint256 totalSupply_) external onlyRole(Role.marketAdmin) {
        registry.setTotalSupply(totalSupply_);
    }

    /// @inheritdoc ITheSpace
    function setTaxConfig(ITheSpaceRegistry.ConfigOptions option_, uint256 value_) external onlyRole(Role.marketAdmin) {
        registry.setTaxConfig(option_, value_);
    }

    /// @inheritdoc ITheSpace
    function withdrawTreasury(address to_) external onlyRole(Role.treasuryAdmin) {
        (uint256 accumulatedUBI, uint256 accumulatedTreasury, uint256 treasuryWithdrawn) = registry.treasuryRecord();

        // calculate available amount and transfer
        uint256 amount = accumulatedTreasury - treasuryWithdrawn;
        registry.transferCurrency(to_, amount);
        registry.emitTreasury(to_, amount);

        // set `treasuryWithdrawn` to `accumulatedTreasury`
        registry.setTreasuryRecord(accumulatedUBI, accumulatedTreasury, accumulatedTreasury);
    }

    /// @inheritdoc ITheSpace
    function setTokenImageURI(string memory uri_) external onlyRole(Role.aclManager) {
        tokenImageURI = uri_;
    }

    //////////////////////////////
    /// Pixel
    //////////////////////////////

    /// @inheritdoc ITheSpace
    function getPixel(uint256 tokenId_) external view returns (ITheSpaceRegistry.Pixel memory pixel) {
        return _getPixel(tokenId_);
    }

    function _getPixel(uint256 tokenId_) internal view returns (ITheSpaceRegistry.Pixel memory pixel) {
        (, uint256 lastTaxCollection, ) = registry.tokenRecord(tokenId_);

        pixel = ITheSpaceRegistry.Pixel(
            tokenId_,
            getPrice(tokenId_),
            lastTaxCollection,
            ubiAvailable(tokenId_),
            getOwner(tokenId_),
            registry.pixelColor(tokenId_)
        );
    }

    /// @inheritdoc ITheSpace
    function setPixel(
        uint256 tokenId_,
        uint256 bidPrice_,
        uint256 newPrice_,
        uint256 color_
    ) external {
        bid(tokenId_, bidPrice_);
        setPrice(tokenId_, newPrice_);
        _setColor(tokenId_, color_, msg.sender);
    }

    /// @inheritdoc ITheSpace
    function setColor(uint256 tokenId_, uint256 color_) public {
        if (!registry.isApprovedOrOwner(msg.sender, tokenId_)) revert Unauthorized();

        _setColor(tokenId_, color_, registry.ownerOf(tokenId_));
    }

    function _setColor(
        uint256 tokenId_,
        uint256 color_,
        address owner_
    ) internal {
        if (registry.pixelColor(tokenId_) == color_) return;

        registry.setColor(tokenId_, color_, owner_);
    }

    /// @inheritdoc ITheSpace
    function getColor(uint256 tokenId) public view returns (uint256 color) {
        color = registry.pixelColor(tokenId);
    }

    /// @inheritdoc ITheSpace
    function getPixelsByOwner(
        address owner_,
        uint256 limit_,
        uint256 offset_
    )
        external
        view
        returns (
            uint256 total,
            uint256 limit,
            uint256 offset,
            ITheSpaceRegistry.Pixel[] memory pixels
        )
    {
        uint256 _total = registry.balanceOf(owner_);
        if (limit_ == 0) {
            return (_total, limit_, offset_, new ITheSpaceRegistry.Pixel[](0));
        }

        if (offset_ >= _total) {
            return (_total, limit_, offset_, new ITheSpaceRegistry.Pixel[](0));
        }
        uint256 left = _total - offset_;
        uint256 size = left > limit_ ? limit_ : left;

        ITheSpaceRegistry.Pixel[] memory _pixels = new ITheSpaceRegistry.Pixel[](size);

        for (uint256 i = 0; i < size; i++) {
            uint256 tokenId = registry.tokenOfOwnerByIndex(owner_, i + offset_);
            _pixels[i] = _getPixel(tokenId);
        }

        return (_total, limit_, offset_, _pixels);
    }

    //////////////////////////////
    /// Trading
    //////////////////////////////

    /// @inheritdoc ITheSpace
    function getPrice(uint256 tokenId_) public view returns (uint256 price) {
        return
            registry.exists(tokenId_)
                ? _getPrice(tokenId_)
                : registry.taxConfig(ITheSpaceRegistry.ConfigOptions.mintTax);
    }

    function _getPrice(uint256 tokenId_) internal view returns (uint256) {
        (uint256 price, , ) = registry.tokenRecord(tokenId_);
        return price;
    }

    /// @inheritdoc ITheSpace
    function setPrice(uint256 tokenId_, uint256 price_) public {
        if (!(registry.isApprovedOrOwner(msg.sender, tokenId_))) revert Unauthorized();
        if (price_ == _getPrice(tokenId_)) return;

        bool success = settleTax(tokenId_);
        if (success) _setPrice(tokenId_, price_);
    }

    /**
     * @dev Internal function to set price without checking
     */
    function _setPrice(uint256 tokenId_, uint256 price_) private {
        _setPrice(tokenId_, price_, registry.ownerOf(tokenId_));
    }

    function _setPrice(
        uint256 tokenId_,
        uint256 price_,
        address operator_
    ) private {
        // max price to prevent overflow of `_getTax`
        uint256 maxPrice = registry.currency().totalSupply();
        if (price_ > maxPrice) revert PriceTooHigh(maxPrice);

        (, , uint256 ubiWithdrawn) = registry.tokenRecord(tokenId_);

        registry.setTokenRecord(tokenId_, price_, block.number, ubiWithdrawn);
        registry.emitPrice(tokenId_, price_, operator_);
    }

    /// @inheritdoc ITheSpace
    function getOwner(uint256 tokenId_) public view returns (address owner) {
        return registry.exists(tokenId_) ? registry.ownerOf(tokenId_) : address(0);
    }

    /// @inheritdoc ITheSpace
    function bid(uint256 tokenId_, uint256 price_) public nonReentrant {
        address owner = getOwner(tokenId_);
        uint256 askPrice = _getPrice(tokenId_);
        uint256 mintTax = registry.taxConfig(ITheSpaceRegistry.ConfigOptions.mintTax);

        // bid price and payee is calculated based on tax and token status
        uint256 bidPrice;

        if (registry.exists(tokenId_)) {
            // skip if already own
            if (owner == msg.sender) return;

            // clear tax
            bool success = _collectTax(tokenId_);

            // proceed with transfer
            if (success) {
                // if tax fully paid, owner get paid normally
                bidPrice = askPrice;

                // revert if price too low
                if (price_ < bidPrice) revert PriceTooLow();

                // settle ERC20 token
                registry.transferCurrencyFrom(msg.sender, owner, bidPrice);

                // settle ERC721 token
                registry.safeTransferByMarket(owner, msg.sender, tokenId_);

                // emit deal event
                registry.emitDeal(tokenId_, owner, msg.sender, bidPrice);

                // update price to ask price if difference
                if (price_ > askPrice) _setPrice(tokenId_, price_, msg.sender);

                return;
            } else {
                // if tax not fully paid, token is treated as defaulted and mint tax is collected and recorded
                registry.burn(tokenId_);
            }
        }

        // mint tax is collected and recorded
        bidPrice = mintTax;

        // revert if price too low
        if (price_ < bidPrice) revert PriceTooLow();

        // settle ERC20 token
        registry.transferCurrencyFrom(msg.sender, address(registry), bidPrice);

        // record as tax income
        _recordTax(tokenId_, msg.sender, mintTax);

        // settle ERC721 token
        registry.mint(msg.sender, tokenId_);

        // emit deal event
        registry.emitDeal(tokenId_, address(0), msg.sender, bidPrice);

        // update price to ask price if difference
        if (price_ > askPrice) _setPrice(tokenId_, price_, msg.sender);
    }

    //////////////////////////////
    /// Tax & UBI
    //////////////////////////////

    /// @inheritdoc ITheSpace
    function getTax(uint256 tokenId_) public view returns (uint256) {
        if (!registry.exists(tokenId_)) revert TokenNotExists();

        return _getTax(tokenId_);
    }

    function _getTax(uint256 tokenId_) internal view returns (uint256) {
        (uint256 price, uint256 lastTaxCollection, ) = registry.tokenRecord(tokenId_);

        if (price == 0) return 0;

        uint256 taxRate = registry.taxConfig(ITheSpaceRegistry.ConfigOptions.taxRate);

        // `1000` for every `1000` blocks, `10000` for conversion from bps
        return ((price * taxRate * (block.number - lastTaxCollection)) / (1000 * 10000));
    }

    /// @inheritdoc ITheSpace
    function evaluateOwnership(uint256 tokenId_) public view returns (uint256 collectable, bool shouldDefault) {
        uint256 tax = getTax(tokenId_);

        if (tax > 0) {
            // calculate collectable amount
            address taxpayer = registry.ownerOf(tokenId_);
            uint256 allowance = registry.currency().allowance(taxpayer, address(registry));
            uint256 balance = registry.currency().balanceOf(taxpayer);
            uint256 available = allowance < balance ? allowance : balance;

            if (available >= tax) {
                // can pay tax fully and do not need to be defaulted
                return (tax, false);
            } else {
                // cannot pay tax fully and need to be defaulted
                return (available, true);
            }
        } else {
            // not tax needed
            return (0, false);
        }
    }

    /**
     * @notice Collect outstanding tax for a given token, put token on tax sale if obligation not met.
     * @dev Emits a {Tax} event
     * @dev Emits a {Price} event (when properties are put on tax sale).
     */
    function _collectTax(uint256 tokenId_) private returns (bool success) {
        (uint256 collectable, bool shouldDefault) = evaluateOwnership(tokenId_);

        if (collectable > 0) {
            // collect and record tax
            address owner = registry.ownerOf(tokenId_);
            registry.transferCurrencyFrom(owner, address(registry), collectable);
            _recordTax(tokenId_, owner, collectable);
        }

        return !shouldDefault;
    }

    /**
     * @notice Update tax record and emit Tax event.
     */
    function _recordTax(
        uint256 tokenId_,
        address taxpayer_,
        uint256 amount_
    ) private {
        // calculate treasury change
        uint256 treasuryShare = registry.taxConfig(ITheSpaceRegistry.ConfigOptions.treasuryShare);
        uint256 treasuryAdded = (amount_ * treasuryShare) / 10000;

        // set treasury record
        (uint256 accumulatedUBI, uint256 accumulatedTreasury, uint256 treasuryWithdrawn) = registry.treasuryRecord();
        registry.setTreasuryRecord(
            accumulatedUBI + (amount_ - treasuryAdded),
            accumulatedTreasury + treasuryAdded,
            treasuryWithdrawn
        );

        // update lastTaxCollection and emit tax event
        (uint256 price, , uint256 ubiWithdrawn) = registry.tokenRecord(tokenId_);
        registry.setTokenRecord(tokenId_, price, block.number, ubiWithdrawn);
        registry.emitTax(tokenId_, taxpayer_, amount_);
    }

    /// @inheritdoc ITheSpace
    function settleTax(uint256 tokenId_) public returns (bool success) {
        success = _collectTax(tokenId_);
        if (!success) registry.burn(tokenId_);
    }

    /// @inheritdoc ITheSpace
    function ubiAvailable(uint256 tokenId_) public view returns (uint256) {
        (uint256 accumulatedUBI, , ) = registry.treasuryRecord();
        (, , uint256 ubiWithdrawn) = registry.tokenRecord(tokenId_);

        return accumulatedUBI / registry.totalSupply() - ubiWithdrawn;
    }

    /// @inheritdoc ITheSpace
    function withdrawUbi(uint256 tokenId_) external {
        uint256 amount = ubiAvailable(tokenId_);

        if (amount > 0) {
            // transfer
            address recipient = registry.ownerOf(tokenId_);
            registry.transferCurrency(recipient, amount);

            // record
            (uint256 price, uint256 lastTaxCollection, uint256 ubiWithdrawn) = registry.tokenRecord(tokenId_);
            registry.setTokenRecord(tokenId_, price, lastTaxCollection, ubiWithdrawn + amount);

            // emit event
            registry.emitUBI(tokenId_, recipient, amount);
        }
    }

    //////////////////////////////
    /// Registry backcall
    //////////////////////////////

    /// @inheritdoc ITheSpace
    function _beforeTransferByRegistry(uint256 tokenId_) external returns (bool success) {
        if (msg.sender != address(registry)) revert Unauthorized();

        // clear tax or default
        settleTax(tokenId_);

        // proceed with transfer if tax settled
        if (registry.exists(tokenId_)) {
            // transfer is regarded as setting price to 0, then bid for free
            // this is to prevent transferring huge tax obligation as a form of attack
            _setPrice(tokenId_, 0);

            success = true;
        } else {
            success = false;
        }
    }

    /// @inheritdoc ITheSpace
    function _tokenURI(uint256 tokenId_) external view returns (string memory uri) {
        if (msg.sender != address(registry)) revert Unauthorized();

        if (!registry.exists(tokenId_)) revert TokenNotExists();

        string memory tokenName = string(abi.encodePacked("Planck #", Strings.toString(tokenId_)));
        string memory description = "One of 1 million pixels traded under Harberger Tax and UBI.";

        string memory json = Base64.encode(
            bytes(
                string(
                    abi.encodePacked(
                        '{"name": "',
                        tokenName,
                        '", "description": "',
                        description,
                        '", "attributes": [',
                        '], "image": "',
                        tokenImageURI,
                        '"}'
                    )
                )
            )
        );

        uri = string(abi.encodePacked("data:application/json;base64,", json));
    }
}

File 2 of 26 : Multicall.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Multicall.sol)

pragma solidity ^0.8.0;

import "./Address.sol";

/**
 * @dev Provides a function to batch together multiple calls in a single external call.
 *
 * _Available since v4.1._
 */
abstract contract Multicall {
    /**
     * @dev Receives and executes a batch of function calls on this contract.
     */
    function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
        results = new bytes[](data.length);
        for (uint256 i = 0; i < data.length; i++) {
            results[i] = Address.functionDelegateCall(address(this), data[i]);
        }
        return results;
    }
}

File 3 of 26 : Base64.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Provides a set of functions to operate with Base64 strings.
 */
library Base64 {
    /**
     * @dev Base64 Encoding/Decoding Table
     */
    string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

    /**
     * @dev Converts a `bytes` to its Bytes64 `string` representation.
     */
    function encode(bytes memory data) internal pure returns (string memory) {
        /**
         * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
         * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
         */
        if (data.length == 0) return "";

        // Loads the table into memory
        string memory table = _TABLE;

        // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
        // and split into 4 numbers of 6 bits.
        // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
        // - `data.length + 2`  -> Round up
        // - `/ 3`              -> Number of 3-bytes chunks
        // - `4 *`              -> 4 characters for each chunk
        string memory result = new string(4 * ((data.length + 2) / 3));

        assembly {
            // Prepare the lookup table (skip the first "length" byte)
            let tablePtr := add(table, 1)

            // Prepare result pointer, jump over length
            let resultPtr := add(result, 32)

            // Run over the input, 3 bytes at a time
            for {
                let dataPtr := data
                let endPtr := add(data, mload(data))
            } lt(dataPtr, endPtr) {

            } {
                // Advance 3 bytes
                dataPtr := add(dataPtr, 3)
                let input := mload(dataPtr)

                // To write each character, shift the 3 bytes (18 bits) chunk
                // 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
                // and apply logical AND with 0x3F which is the number of
                // the previous character in the ASCII table prior to the Base64 Table
                // The result is then added to the table to get the character to write,
                // and finally write it in the result pointer but with a left shift
                // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits

                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance

                mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
                resultPtr := add(resultPtr, 1) // Advance
            }

            // When data `bytes` is not exactly 3 bytes long
            // it is padded with `=` characters at the end
            switch mod(mload(data), 3)
            case 1 {
                mstore8(sub(resultPtr, 1), 0x3d)
                mstore8(sub(resultPtr, 2), 0x3d)
            }
            case 2 {
                mstore8(sub(resultPtr, 1), 0x3d)
            }
        }

        return result;
    }
}

File 4 of 26 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override 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`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * 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 virtual override returns (uint8) {
        return 18;
    }

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

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        uint256 currentAllowance = _allowances[sender][_msgSender()];
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
            unchecked {
                _approve(sender, _msgSender(), currentAllowance - amount);
            }
        }

        _transfer(sender, recipient, amount);

        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] + 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) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `sender` to `recipient`.
     *
     * This 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 virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[sender] = senderBalance - amount;
        }
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);

        _afterTokenTransfer(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:
     *
     * - `account` 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 += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * 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 virtual {
        require(account != address(0), "ERC20: burn from the zero address");

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

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

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

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This 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 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 {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 5 of 26 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract 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() {
        _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 making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 6 of 26 : ACLManager.sol
//SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Context.sol";

import "./IACLManager.sol";

contract ACLManager is IACLManager, Context {
    mapping(Role => address) private _roles;

    constructor(
        address aclManager_,
        address marketAdmin_,
        address treasuryAdmin_
    ) {
        if (aclManager_ == address(0)) revert ZeroAddress();

        _transferRole(Role.aclManager, aclManager_);
        _transferRole(Role.marketAdmin, marketAdmin_);
        _transferRole(Role.treasuryAdmin, treasuryAdmin_);
    }

    /**
     * @dev Throws if called by any address other than the role address.
     */
    modifier onlyRole(Role role) {
        if (!_hasRole(role, _msgSender())) revert RoleRequired(role);
        _;
    }

    /// @inheritdoc IACLManager
    function hasRole(Role role, address account) public view returns (bool) {
        return _hasRole(role, account);
    }

    function _hasRole(Role role, address account) internal view returns (bool) {
        return _roles[role] == account;
    }

    /// @inheritdoc IACLManager
    function grantRole(Role role, address newAccount) public virtual onlyRole(Role.aclManager) {
        if (role == Role.aclManager) revert Forbidden();
        if (newAccount == address(0)) revert ZeroAddress();

        _transferRole(role, newAccount);
    }

    /// @inheritdoc IACLManager
    function transferRole(Role role, address newAccount) public virtual onlyRole(role) {
        if (newAccount == address(0)) revert ZeroAddress();

        _transferRole(role, newAccount);
    }

    /// @inheritdoc IACLManager
    function renounceRole(Role role) public virtual onlyRole(role) {
        if (role == Role.aclManager) revert Forbidden();

        _transferRole(role, address(0));
    }

    /**
     * @dev Transfers role to a new account (`newAccount`).
     * Internal function without access restriction.
     */
    function _transferRole(Role role, address newAccount) internal virtual {
        address oldAccount = _roles[role];
        _roles[role] = newAccount;
        emit RoleTransferred(role, oldAccount, newAccount);
    }
}

File 7 of 26 : TheSpaceRegistry.sol
//SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import "./ITheSpace.sol";
import "./ITheSpaceRegistry.sol";

contract TheSpaceRegistry is ITheSpaceRegistry, ERC721Enumerable, Ownable {
    /**
     * @dev Total possible number of ERC721 token
     */
    uint256 private _totalSupply;

    /**
     * @dev ERC20 token used as currency
     */
    ERC20 public immutable currency;

    /**
     * @dev Record for all tokens (tokenId => TokenRecord).
     */
    mapping(uint256 => TokenRecord) public tokenRecord;

    /**
     * @dev Color of each token.
     */
    mapping(uint256 => uint256) public pixelColor;

    /**
     * @dev Tax configuration of market.
     */
    mapping(ConfigOptions => uint256) public taxConfig;

    /**
     * @dev Global state of tax and treasury.
     */
    TreasuryRecord public treasuryRecord;

    /**
     * @dev Create Property contract, setup attached currency contract, setup tax rate.
     */
    constructor(
        string memory propertyName_,
        string memory propertySymbol_,
        uint256 totalSupply_,
        uint256 taxRate_,
        uint256 treasuryShare_,
        uint256 mintTax_,
        address currencyAddress_
    ) ERC721(propertyName_, propertySymbol_) {
        // initialize total supply
        _totalSupply = totalSupply_;

        // initialize currency contract
        currency = ERC20(currencyAddress_);

        // initialize tax config
        taxConfig[ConfigOptions.taxRate] = taxRate_;
        emit Config(ConfigOptions.taxRate, taxRate_);
        taxConfig[ConfigOptions.treasuryShare] = treasuryShare_;
        emit Config(ConfigOptions.treasuryShare, treasuryShare_);
        taxConfig[ConfigOptions.mintTax] = mintTax_;
        emit Config(ConfigOptions.mintTax, mintTax_);
    }

    //////////////////////////////
    /// Getters & Setters
    //////////////////////////////

    /**
     * @notice See {IERC20-totalSupply}.
     * @dev Always return total possible amount of supply, instead of current token in circulation.
     */
    function totalSupply() public view override(ERC721Enumerable, IERC721Enumerable) returns (uint256) {
        return _totalSupply;
    }

    //////////////////////////////
    /// Setters for global variables
    //////////////////////////////

    /// @inheritdoc ITheSpaceRegistry
    function setTotalSupply(uint256 totalSupply_) external onlyOwner {
        emit TotalSupply(_totalSupply, totalSupply_);

        _totalSupply = totalSupply_;
    }

    /// @inheritdoc ITheSpaceRegistry
    function setTaxConfig(ConfigOptions option_, uint256 value_) external onlyOwner {
        taxConfig[option_] = value_;

        emit Config(option_, value_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function setTreasuryRecord(
        uint256 accumulatedUBI_,
        uint256 accumulatedTreasury_,
        uint256 treasuryWithdrawn_
    ) external onlyOwner {
        treasuryRecord = TreasuryRecord(accumulatedUBI_, accumulatedTreasury_, treasuryWithdrawn_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function setTokenRecord(
        uint256 tokenId_,
        uint256 price_,
        uint256 lastTaxCollection_,
        uint256 ubiWithdrawn_
    ) external onlyOwner {
        tokenRecord[tokenId_] = TokenRecord(price_, lastTaxCollection_, ubiWithdrawn_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function setColor(
        uint256 tokenId_,
        uint256 color_,
        address owner_
    ) external onlyOwner {
        pixelColor[tokenId_] = color_;
        emit Color(tokenId_, color_, owner_);
    }

    //////////////////////////////
    /// Event emission
    //////////////////////////////

    /// @inheritdoc ITheSpaceRegistry
    function emitTax(
        uint256 tokenId_,
        address taxpayer_,
        uint256 amount_
    ) external onlyOwner {
        emit Tax(tokenId_, taxpayer_, amount_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function emitPrice(
        uint256 tokenId_,
        uint256 price_,
        address operator_
    ) external onlyOwner {
        emit Price(tokenId_, price_, operator_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function emitUBI(
        uint256 tokenId_,
        address recipient_,
        uint256 amount_
    ) external onlyOwner {
        emit UBI(tokenId_, recipient_, amount_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function emitTreasury(address recipient_, uint256 amount_) external onlyOwner {
        emit Treasury(recipient_, amount_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function emitDeal(
        uint256 tokenId_,
        address from_,
        address to_,
        uint256 amount_
    ) external onlyOwner {
        emit Deal(tokenId_, from_, to_, amount_);
    }

    //////////////////////////////
    /// ERC721 property related
    //////////////////////////////

    /// @inheritdoc ITheSpaceRegistry
    function mint(address to_, uint256 tokenId_) external onlyOwner {
        if (tokenId_ > _totalSupply || tokenId_ < 1) revert InvalidTokenId(1, _totalSupply);
        _safeMint(to_, tokenId_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function burn(uint256 tokenId_) external onlyOwner {
        _burn(tokenId_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function safeTransferByMarket(
        address from_,
        address to_,
        uint256 tokenId_
    ) external onlyOwner {
        _safeTransfer(from_, to_, tokenId_, "");
    }

    /// @inheritdoc ITheSpaceRegistry
    function exists(uint256 tokenId_) external view returns (bool) {
        return _exists(tokenId_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function isApprovedOrOwner(address spender_, uint256 tokenId_) external view returns (bool) {
        return _isApprovedOrOwner(spender_, tokenId_);
    }

    /**
     * @notice See {IERC721-transferFrom}.
     * @dev Override to collect tax and set price before transfer.
     */
    function transferFrom(
        address from_,
        address to_,
        uint256 tokenId_
    ) public override(ERC721, IERC721) {
        safeTransferFrom(from_, to_, tokenId_, "");
    }

    /**
     * @notice See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from_,
        address to_,
        uint256 tokenId_,
        bytes memory data_
    ) public override(ERC721, IERC721) {
        // solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(msg.sender, tokenId_), "ERC721: transfer caller is not owner nor approved");

        ITheSpace market = ITheSpace(owner());

        bool success = market._beforeTransferByRegistry(tokenId_);

        if (success) {
            _safeTransfer(from_, to_, tokenId_, data_);
        }
    }

    /**
     * @notice See {IERC721-tokenURI}.
     */
    function tokenURI(uint256 tokenId_) public view override returns (string memory uri) {
        ITheSpace market = ITheSpace(owner());

        uri = market._tokenURI(tokenId_);
    }

    //////////////////////////////
    /// ERC20 currency related
    //////////////////////////////

    /// @inheritdoc ITheSpaceRegistry
    function transferCurrency(address to_, uint256 amount_) external onlyOwner {
        currency.transfer(to_, amount_);
    }

    /// @inheritdoc ITheSpaceRegistry
    function transferCurrencyFrom(
        address from_,
        address to_,
        uint256 amount_
    ) external onlyOwner {
        currency.transferFrom(from_, to_, amount_);
    }
}

File 8 of 26 : ITheSpaceRegistry.sol
//SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

/**
 * @title The interface for `TheSpaceRegistry` contract.
 * @notice Storage contract for `TheSpace` contract.
 * @dev It stores all states related to the market, and is owned by the TheSpace contract.
 * @dev The market contract can be upgraded by changing the owner of this contract to the new implementation contract.
 */
interface ITheSpaceRegistry is IERC721Enumerable {
    //////////////////////////////
    /// Error types
    //////////////////////////////

    /**
     * @notice Token id is out of range.
     * @param min Lower range of possible token id.
     * @param max Higher range of possible token id.
     */
    error InvalidTokenId(uint256 min, uint256 max);

    //////////////////////////////
    /// Event types
    //////////////////////////////

    /**
     * @notice A token updated price.
     * @param tokenId Id of token that updated price.
     * @param price New price after update.
     * @param owner Token owner during price update.
     */
    event Price(uint256 indexed tokenId, uint256 price, address indexed owner);

    /**
     * @notice Global configuration is updated.
     * @param option Field of config been updated.
     * @param value New value after update.
     */
    event Config(ConfigOptions indexed option, uint256 value);

    /**
     * @notice Total is updated.
     * @param previousSupply Total supply amount before update.
     * @param newSupply New supply amount after update.
     */
    event TotalSupply(uint256 previousSupply, uint256 newSupply);

    /**
     * @notice Tax is collected for a token.
     * @param tokenId Id of token that has been taxed.
     * @param taxpayer user address who has paid the tax.
     * @param amount Amount of tax been collected.
     */
    event Tax(uint256 indexed tokenId, address indexed taxpayer, uint256 amount);

    /**
     * @notice UBI (universal basic income) is withdrawn for a token.
     * @param tokenId Id of token that UBI has been withdrawn for.
     * @param recipient user address who got this withdrawn UBI.
     * @param amount Amount of UBI withdrawn.
     */
    event UBI(uint256 indexed tokenId, address indexed recipient, uint256 amount);

    /**
     * @notice Treasury is withdrawn.
     * @param recipient address who got this withdrawn treasury.
     * @param amount Amount of withdrawn.
     */
    event Treasury(address indexed recipient, uint256 amount);

    /**
     * @notice A token has been succefully bid.
     * @param tokenId Id of token that has been bid.
     * @param from Original owner before bid.
     * @param to New owner after bid.
     * @param amount Amount of currency used for bidding.
     */
    event Deal(uint256 indexed tokenId, address indexed from, address indexed to, uint256 amount);

    /**
     * @notice Emitted when the color of a pixel is updated.
     * @param tokenId Id of token that has been bid.
     * @param color Color index defined by client.
     * @param owner Token owner.
     */
    event Color(uint256 indexed tokenId, uint256 indexed color, address indexed owner);

    //////////////////////////////
    /// Data structure
    //////////////////////////////

    /**
     * @notice Options for global tax configuration.
     * @param taxRate: Tax rate in bps every 1000 blocks
     * @param treasuryShare: Share to treasury in bps.
     * @param mintTax: Tax to mint a token. It should be non-zero to prevent attacker constantly mint, default and mint token again.
     */
    enum ConfigOptions {
        taxRate,
        treasuryShare,
        mintTax
    }

    /**
     * @notice Record of each token.
     * @param price Current price.
     * @param lastTaxCollection Block number of last tax collection.
     * @param ubiWithdrawn Amount of UBI been withdrawn.
     */
    struct TokenRecord {
        uint256 price;
        uint256 lastTaxCollection;
        uint256 ubiWithdrawn;
    }

    /**
     * @notice Global state of tax and treasury.
     * @param accumulatedUBI Total amount of currency allocated for UBI.
     * @param accumulatedTreasury Total amount of currency allocated for treasury.
     * @param treasuryWithdrawn Total amount of treasury been withdrawn.
     */
    struct TreasuryRecord {
        uint256 accumulatedUBI;
        uint256 accumulatedTreasury;
        uint256 treasuryWithdrawn;
    }

    /**
     * @dev Packed pixel info.
     */
    struct Pixel {
        uint256 tokenId;
        uint256 price;
        uint256 lastTaxCollection;
        uint256 ubi;
        address owner;
        uint256 color;
    }

    //////////////////////////////
    /// Getters & Setters
    //////////////////////////////

    /**
     * @notice Update total supply of ERC721 token.
     * @param totalSupply_ New amount of total supply.
     */
    function setTotalSupply(uint256 totalSupply_) external;

    /**
     * @notice Update global tax settings.
     * @param option_ Tax config options, see {ConfigOptions} for detail.
     * @param value_ New value for tax setting.
     */
    function setTaxConfig(ConfigOptions option_, uint256 value_) external;

    /**
     * @notice Update UBI and treasury.
     * @param accumulatedUBI_ Total amount of currency allocated for UBI.
     * @param accumulatedTreasury_ Total amount of currency allocated for treasury.
     * @param treasuryWithdrawn_ Total amount of treasury been withdrawn.
     */
    function setTreasuryRecord(
        uint256 accumulatedUBI_,
        uint256 accumulatedTreasury_,
        uint256 treasuryWithdrawn_
    ) external;

    /**
     * @notice Set record for a given token.
     * @param tokenId_ Id of token to be set.
     * @param price_ Current price.
     * @param lastTaxCollection_ Block number of last tax collection.
     * @param ubiWithdrawn_ Amount of UBI been withdrawn.
     */
    function setTokenRecord(
        uint256 tokenId_,
        uint256 price_,
        uint256 lastTaxCollection_,
        uint256 ubiWithdrawn_
    ) external;

    /**
     * @notice Set color for a given token.
     * @param tokenId_ Token id to be set.
     * @param color_ Color Id.
     * @param owner_ Token owner.
     */
    function setColor(
        uint256 tokenId_,
        uint256 color_,
        address owner_
    ) external;

    //////////////////////////////
    /// Event emission
    //////////////////////////////

    /**
     * @dev Emit {Tax} event
     */
    function emitTax(
        uint256 tokenId_,
        address taxpayer_,
        uint256 amount_
    ) external;

    /**
     * @dev Emit {Price} event
     */
    function emitPrice(
        uint256 tokenId_,
        uint256 price_,
        address operator_
    ) external;

    /**
     * @dev Emit {UBI} event
     */
    function emitUBI(
        uint256 tokenId_,
        address recipient_,
        uint256 amount_
    ) external;

    /**
     * @dev Emit {Treasury} event
     */
    function emitTreasury(address recipient_, uint256 amount_) external;

    /**
     * @dev Emit {Deal} event
     */
    function emitDeal(
        uint256 tokenId_,
        address from_,
        address to_,
        uint256 amount_
    ) external;

    //////////////////////////////
    /// ERC721 property related
    //////////////////////////////

    /**
     * @dev Mint an ERC721 token.
     */
    function mint(address to_, uint256 tokenId_) external;

    /**
     * @dev Burn an ERC721 token.
     */
    function burn(uint256 tokenId_) external;

    /**
     * @dev Perform ERC721 token transfer by market contract.
     */
    function safeTransferByMarket(
        address from_,
        address to_,
        uint256 tokenId_
    ) external;

    /**
     * @dev If an ERC721 token has been minted.
     */
    function exists(uint256 tokenId_) external view returns (bool);

    /**
     * @dev If an address is allowed to transfer an ERC721 token.
     */
    function isApprovedOrOwner(address spender_, uint256 tokenId_) external view returns (bool);

    //////////////////////////////
    /// ERC20 currency related
    //////////////////////////////

    /**
     * @dev Perform ERC20 token transfer by market contract.
     */
    function transferCurrency(address to_, uint256 amount_) external;

    /**
     * @dev Perform ERC20 token transferFrom by market contract.
     */
    function transferCurrencyFrom(
        address from_,
        address to_,
        uint256 amount_
    ) external;
}

File 9 of 26 : ITheSpace.sol
//SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

import "./ITheSpaceRegistry.sol";

/**
 * @title The interface for `TheSpace` contract
 * @notice _The Space_ is a pixel space owned by a decentralized autonomous organization (DAO), where members can tokenize, own, trade and color pixels.
 *
 * Pixels are tokenized as ERC721 tokens and traded under Harberger tax, while members receive dividend based on the share of pixels they own.
 *
 * #### Trading
 * - User needs to call `approve` on currency contract before starting. If there is not sufficient allowance for taxing, the corresponding assets are defaulted.
 * - User buy pixel: call [`bid` function](./ITheSpace.md).
 * - User set pixel price: call [`setPrice` function](./ITheSpace.md).
 *
 * @dev This contract holds the logic of market place, while read from and write into {TheSpaceRegistry}, which is the storage contact.
 * @dev This contract owns a {TheSpaceRegistry} contract for storage, and can be updated by transfering ownership to a new implementation contract.
 */

interface ITheSpace {
    //////////////////////////////
    /// Error types
    //////////////////////////////

    /**
     * @dev Price too low to bid the given token.
     */
    error PriceTooLow();

    /**
     * @dev Price too high to set.
     */
    error PriceTooHigh(uint256 maxPrice);

    /**
     * @dev Sender is not authorized for given operation.
     */
    error Unauthorized();

    /**
     * @dev The give token does not exist and needs to be minted first via bidding.
     */
    error TokenNotExists();

    //////////////////////////////
    /// Upgradability
    //////////////////////////////

    /**
     * @notice Switch logic contract to another one.
     *
     * @dev Access: only `Role.aclManager`.
     * @dev Throws: `RoleRequired` error.
     *
     * @param newImplementation address of new logic contract.
     */
    function upgradeTo(address newImplementation) external;

    //////////////////////////////
    /// Configuration / Admin
    //////////////////////////////

    /**
     * @notice Update total supply of ERC721 token.
     *
     * @dev Access: only `Role.marketAdmin`.
     * @dev Throws: `RoleRequired` error.
     *
     * @param totalSupply_ New amount of total supply.
     */
    function setTotalSupply(uint256 totalSupply_) external;

    /**
     * @notice Update current tax configuration.
     *
     * @dev Access: only `Role.marketAdmin`.
     * @dev Emits: `Config` event.
     * @dev Throws: `RoleRequired` error.
     *
     * @param option_ Field of config been updated.
     * @param value_ New value after update.
     */
    function setTaxConfig(ITheSpaceRegistry.ConfigOptions option_, uint256 value_) external;

    /**
     * @notice Withdraw all available treasury.
     *
     * @dev Access: only `Role.treasuryAdmin`.
     * @dev Throws: `RoleRequired` error.
     *
     * @param to_ address of DAO treasury.
     */
    function withdrawTreasury(address to_) external;

    /**
     * @notice Set token image URI.
     *
     * @dev Access: only `Role.aclManager`.
     * @dev Throws: `RoleRequired` error.
     *
     * @param uri_ new URI
     */
    function setTokenImageURI(string memory uri_) external;

    //////////////////////////////
    /// Pixel
    //////////////////////////////

    /**
     * @notice Get pixel info.
     * @param tokenId_ Token id to be queried.
     * @return pixel Packed pixel info.
     */
    function getPixel(uint256 tokenId_) external view returns (ITheSpaceRegistry.Pixel memory pixel);

    /**
     * @notice Bid pixel, then set price and color.
     *
     * @dev Throws: inherits from `bid` and `setPrice`.
     *
     * @param tokenId_ Token id to be bid and set.
     * @param bidPrice_ Bid price.
     * @param newPrice_ New price to be set.
     * @param color_ Color to be set.
     */
    function setPixel(
        uint256 tokenId_,
        uint256 bidPrice_,
        uint256 newPrice_,
        uint256 color_
    ) external;

    /**
     * @notice Set color for a pixel.
     *
     * @dev Access: only token owner or approved operator.
     * @dev Throws: `Unauthorized` or `ERC721: operator query for nonexistent token` error.
     * @dev Emits: `Color` event.
     *
     * @param tokenId_ Token id to be set.
     * @param color_ Color to be set.
     */
    function setColor(uint256 tokenId_, uint256 color_) external;

    /**
     * @notice Get color for a pixel.
     * @param tokenId_ Token id to be queried.
     * @return color Color.
     */
    function getColor(uint256 tokenId_) external view returns (uint256 color);

    /**
     * @notice Get pixels owned by a given address.
     * @param owner_ Owner address.
     * @param limit_ Limit of returned pixels.
     * @param offset_ Offset of returned pixels.
     * @return total Total number of pixels.
     * @return limit Limit of returned pixels.
     * @return offset Offset of returned pixels.
     * @return pixels Packed pixels.
     * @dev offset-based pagination
     */
    function getPixelsByOwner(
        address owner_,
        uint256 limit_,
        uint256 offset_
    )
        external
        view
        returns (
            uint256 total,
            uint256 limit,
            uint256 offset,
            ITheSpaceRegistry.Pixel[] memory pixels
        );

    //////////////////////////////
    /// Trading
    //////////////////////////////

    /**
     * @notice Returns the current price of a token by id.
     * @param tokenId_ Token id to be queried.
     * @return price Current price.
     */
    function getPrice(uint256 tokenId_) external view returns (uint256 price);

    /**
     * @notice Set the current price of a token with id. Triggers tax settle first, price is succefully updated after tax is successfully collected.
     *
     * @dev Access: only token owner or approved operator.
     * @dev Throws: `Unauthorized` or `ERC721: operator query for nonexistent token` error.
     * @dev Emits: `Price` event.
     *
     * @param tokenId_ Id of token been updated.
     * @param price_ New price to be updated.
     */
    function setPrice(uint256 tokenId_, uint256 price_) external;

    /**
     * @notice Returns the current owner of an Harberger property with token id.
     * @dev If token does not exisit, return zero address and user can bid the token as usual.
     * @param tokenId_ Token id to be queried.
     * @return owner Current owner address.
     */
    function getOwner(uint256 tokenId_) external view returns (address owner);

    /**
     * @notice Purchase property with bid higher than current price.
     * If bid price is higher than ask price, only ask price will be deducted.
     * @dev Clear tax for owner before transfer.
     *
     * @dev Throws: `PriceTooLow` or `InvalidTokenId` error.
     * @dev Emits: `Deal`, `Tax` events.
     *
     * @param tokenId_ Id of token been bid.
     * @param price_ Bid price.
     */
    function bid(uint256 tokenId_, uint256 price_) external;

    //////////////////////////////
    /// Tax & UBI
    //////////////////////////////

    /**
     * @notice Calculate outstanding tax for a token.
     * @param tokenId_ Token id to be queried.
     * @return amount Current amount of tax that needs to be paid.
     */
    function getTax(uint256 tokenId_) external view returns (uint256 amount);

    /**
     * @notice Calculate amount of tax that can be collected, and determine if token should be defaulted.
     * @param tokenId_ Token id to be queried.
     * @return collectable Amount of currency that can be collected, considering balance and allowance.
     * @return shouldDefault Whether current token should be defaulted.
     */
    function evaluateOwnership(uint256 tokenId_) external view returns (uint256 collectable, bool shouldDefault);

    /**
     * @notice Collect outstanding tax of a token and default it if needed.
     * @dev Anyone can trigger this function. It could be desirable for the developer team to trigger it once a while to make sure all tokens meet their tax obligation.
     *
     * @dev Throws: `PriceTooLow` or `InvalidTokenId` error.
     * @dev Emits: `Tax` events.
     *
     * @param tokenId_ Id of token been settled.
     * @return success Whether tax is fully collected without token been defaulted.
     */
    function settleTax(uint256 tokenId_) external returns (bool success);

    /**
     * @notice Amount of UBI available for withdraw on given token.
     * @param tokenId_ Token id to be queried.
     * @param amount Amount of UBI available to be collected
     */
    function ubiAvailable(uint256 tokenId_) external view returns (uint256 amount);

    /**
     * @notice Withdraw all UBI on given token.
     *
     * @dev Emits: `UBI` event.
     *
     * @param tokenId_ Id of token been withdrawn.
     */
    function withdrawUbi(uint256 tokenId_) external;

    //////////////////////////////
    /// Registry backcall
    //////////////////////////////

    /**
     * @notice Perform before `safeTransfer` and `safeTransferFrom` by registry contract.
     * @dev Collect tax and set price.
     *
     * @dev Access: only registry.
     * @dev Throws: `Unauthorized` error.
     *
     * @param tokenId_ Token id to be transferred.
     * @return success Whether tax is fully collected without token been defaulted.
     */
    function _beforeTransferByRegistry(uint256 tokenId_) external returns (bool success);

    /**
     * @notice Get token URI by registry contract.
     *
     * @dev Access: only registry.
     * @dev Throws: `Unauthorized` or `TokenNotExists` error.
     *
     * @param tokenId_ Token id to be transferred.
     * @return uri Base64 encoded URI.
     */
    function _tokenURI(uint256 tokenId_) external view returns (string memory uri);
}

File 10 of 26 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

File 11 of 26 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `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 12 of 26 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

pragma solidity ^0.8.0;

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

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

File 14 of 26 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol)

pragma solidity ^0.8.0;

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

File 15 of 26 : IACLManager.sol
//SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;

/**
 * @title The interface for `ACLManager` contract to manage _The Space_ market.
 * @notice Access Control List Manager is a role-based access control mechanism.
 * @dev Each role can be granted to an address.
 * @dev All available roles are defined in `Role` enum.
 */
interface IACLManager {
    //////////////////////////////
    /// Error types
    //////////////////////////////

    /**
     * @dev Given operation is requires a given role.
     */
    error RoleRequired(Role role);

    /**
     * @dev Given operation is forbidden.
     */
    error Forbidden();

    /**
     * @dev Given a zero address.
     */
    error ZeroAddress();

    //////////////////////////////
    /// Eevent types
    //////////////////////////////

    /**
     * @notice Role is transferred to a new address.
     * @param role Role transferred.
     * @param prevAccount Old address.
     * @param newAccount New address.
     */
    event RoleTransferred(Role indexed role, address indexed prevAccount, address indexed newAccount);

    /**
     * @notice Available roles.
     * @param aclManager: responsible for assigning and revoking roles of other addresses
     * @param marketAdmin: responsible for updating configuration, e.g. tax rate or treasury rate.
     * @param treasuryAdmin: responsible for withdrawing treasury from contract.
     */
    enum Role {
        aclManager,
        marketAdmin,
        treasuryAdmin
    }

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

    /**
     * @notice Grant role to a account (`newAccount`).
     * @dev Cannot grant `Role.aclManager`.
     *
     * @dev Access: only `Role.aclManager`.
     * @dev Throws: `RoleRequired`, `Forbidden` or `ZeroAddress` error.
     */
    function grantRole(Role role, address newAccount) external;

    /**
     * @notice Transfers role to a new account (`newAccount`).
     * @dev Acces: only current role address.
     * @dev Throws: `RoleRequired`, or `ZeroAddress` error.
     */
    function transferRole(Role role, address newAccount) external;

    /**
     * @notice Revokes role from the role address.
     * @dev `Role.aclManager` can not be revoked.
     *
     * @dev Access: only current role address.
     * @dev Throws: `RoleRequired` or `Forbidden` error.
     */
    function renounceRole(Role role) external;
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 18 of 26 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

File 23 of 26 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

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

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

        _afterTokenTransfer(address(0), to, tokenId);
    }

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

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

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

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

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

        _afterTokenTransfer(owner, address(0), tokenId);
    }

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

        _beforeTokenTransfer(from, to, tokenId);

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

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

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 25 of 26 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

Settings
{
  "remappings": [
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "ds-test/=lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "src/=src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london"
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"currencyAddress_","type":"address"},{"internalType":"string","name":"tokenImageURI_","type":"string"},{"internalType":"address","name":"aclManager_","type":"address"},{"internalType":"address","name":"marketAdmin_","type":"address"},{"internalType":"address","name":"treasuryAdmin_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Forbidden","type":"error"},{"inputs":[{"internalType":"uint256","name":"maxPrice","type":"uint256"}],"name":"PriceTooHigh","type":"error"},{"inputs":[],"name":"PriceTooLow","type":"error"},{"inputs":[{"internalType":"enum IACLManager.Role","name":"role","type":"uint8"}],"name":"RoleRequired","type":"error"},{"inputs":[],"name":"TokenNotExists","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum IACLManager.Role","name":"role","type":"uint8"},{"indexed":true,"internalType":"address","name":"prevAccount","type":"address"},{"indexed":true,"internalType":"address","name":"newAccount","type":"address"}],"name":"RoleTransferred","type":"event"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"_beforeTransferByRegistry","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"_tokenURI","outputs":[{"internalType":"string","name":"uri","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"uint256","name":"price_","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"evaluateOwnership","outputs":[{"internalType":"uint256","name":"collectable","type":"uint256"},{"internalType":"bool","name":"shouldDefault","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getColor","outputs":[{"internalType":"uint256","name":"color","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getOwner","outputs":[{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getPixel","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"lastTaxCollection","type":"uint256"},{"internalType":"uint256","name":"ubi","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"color","type":"uint256"}],"internalType":"struct ITheSpaceRegistry.Pixel","name":"pixel","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"uint256","name":"limit_","type":"uint256"},{"internalType":"uint256","name":"offset_","type":"uint256"}],"name":"getPixelsByOwner","outputs":[{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"offset","type":"uint256"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"lastTaxCollection","type":"uint256"},{"internalType":"uint256","name":"ubi","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"color","type":"uint256"}],"internalType":"struct ITheSpaceRegistry.Pixel[]","name":"pixels","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getTax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IACLManager.Role","name":"role","type":"uint8"},{"internalType":"address","name":"newAccount","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IACLManager.Role","name":"role","type":"uint8"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"contract TheSpaceRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IACLManager.Role","name":"role","type":"uint8"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"uint256","name":"color_","type":"uint256"}],"name":"setColor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"uint256","name":"bidPrice_","type":"uint256"},{"internalType":"uint256","name":"newPrice_","type":"uint256"},{"internalType":"uint256","name":"color_","type":"uint256"}],"name":"setPixel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"uint256","name":"price_","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum ITheSpaceRegistry.ConfigOptions","name":"option_","type":"uint8"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"setTaxConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri_","type":"string"}],"name":"setTokenImageURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"totalSupply_","type":"uint256"}],"name":"setTotalSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"settleTax","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId_","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenImageURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IACLManager.Role","name":"role","type":"uint8"},{"internalType":"address","name":"newAccount","type":"address"}],"name":"transferRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"ubiAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to_","type":"address"}],"name":"withdrawTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"withdrawUbi","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040526007608081905266697066733a2f2f60c81b60a09081526200002a916003919062000302565b503480156200003857600080fd5b5060405162006a0438038062006a048339810160408190526200005b91620003e9565b60016000558282826001600160a01b0383166200008b5760405163d92e233d60e01b815260040160405180910390fd5b6200009860008462000214565b620000a560018362000214565b620000b260028262000214565b505050620f4240600c6000876001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015620000fc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000122919062000514565b620001329060ff16600a62000655565b6200013f90600162000663565b886040516200014e9062000391565b60e080825260069082015265506c616e636b60d01b6101008201526101206020820181905260039082015262504c4b60e81b61014082015260408101959095526060850193909352608084019190915260a08301526001600160a01b031660c082015261016001604051809103906000f080158015620001d2573d6000803e3d6000fd5b50600280546001600160a01b0319166001600160a01b039290921691909117905583516200020890600390602087019062000302565b505050505050620006d7565b6000600160008460028111156200022f576200022f62000685565b600281111562000243576200024362000685565b815260208101919091526040016000908120546001600160a01b0316915082906001908560028111156200027b576200027b62000685565b60028111156200028f576200028f62000685565b8152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055828116908216846002811115620002d457620002d462000685565b6040517f796d9fd27d307e851f66684ea6fe5e98600f0d922d136a5717ae5949892cfcf790600090a4505050565b82805462000310906200069b565b90600052602060002090601f0160209004810192826200033457600085556200037f565b82601f106200034f57805160ff19168380011785556200037f565b828001600101855582156200037f579182015b828111156200037f57825182559160200191906001019062000362565b506200038d9291506200039f565b5090565b612994806200407083390190565b5b808211156200038d5760008155600101620003a0565b80516001600160a01b0381168114620003ce57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b600080600080600060a086880312156200040257600080fd5b6200040d86620003b6565b602087810151919650906001600160401b03808211156200042d57600080fd5b818901915089601f8301126200044257600080fd5b815181811115620004575762000457620003d3565b604051601f8201601f19908116603f01168101908382118183101715620004825762000482620003d3565b816040528281528c868487010111156200049b57600080fd5b600093505b82841015620004bf5784840186015181850187015292850192620004a0565b82841115620004d15760008684830101525b809950505050505050620004e860408701620003b6565b9250620004f860608701620003b6565b91506200050860808701620003b6565b90509295509295909350565b6000602082840312156200052757600080fd5b815160ff811681146200053957600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620005975781600019048211156200057b576200057b62000540565b808516156200058957918102915b93841c93908002906200055b565b509250929050565b600082620005b0575060016200064f565b81620005bf575060006200064f565b8160018114620005d85760028114620005e35762000603565b60019150506200064f565b60ff841115620005f757620005f762000540565b50506001821b6200064f565b5060208310610133831016604e8410600b841016171562000628575081810a6200064f565b62000634838362000556565b80600019048211156200064b576200064b62000540565b0290505b92915050565b60006200053983836200059f565b600081600019048311821515161562000680576200068062000540565b500290565b634e487b7160e01b600052602160045260246000fd5b600181811c90821680620006b057607f821691505b602082108103620006d157634e487b7160e01b600052602260045260246000fd5b50919050565b61398980620006e76000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80638ec8c50411610104578063e7572230116100a2578063f7ea7a3d11610071578063f7ea7a3d14610449578063f86c9e9a1461045c578063fce58c171461046f578063ff1644d81461047757600080fd5b8063e7572230146103fd578063ecaf822a14610410578063ee1ef07e14610423578063f7d975771461043657600080fd5b8063b4f80eb9116100de578063b4f80eb91461037f578063c0aed4a71461039f578063c41a360a146103c2578063cf3a421f146103d557600080fd5b80638ec8c504146103395780639e97b8f61461034c578063ac9650d81461035f57600080fd5b80633659cfe6116101715780635d5664e11161014b5780635d5664e1146102c85780637b103999146102db57806380057b9a146103065780638d17e7121461031957600080fd5b80633659cfe61461028f5780633f8c2b5b146102a2578063598647f8146102b557600080fd5b80630f920904116101ad5780630f9209041461024357806310718d3b1461025657806310ac4e7414610269578063242d81cd1461027c57600080fd5b806301ffc9a7146101d4578063057c9cb81461020d578063099da37f14610222575b600080fd5b6101f86101e236600461302b565b6001600160e01b031916631f37ad1b60e21b1490565b60405190151581526020015b60405180910390f35b61022061021b366004613065565b61048a565b005b610235610230366004613082565b6104fe565b604051908152602001610204565b6102206102513660046130b1565b610597565b610220610264366004613177565b6105da565b610235610277366004613082565b610635565b61022061028a3660046131b0565b6107bc565b61022061029d3660046131d2565b6108c3565b6101f86102b0366004613082565b610952565b6102206102c33660046131b0565b610a17565b6102206102d6366004613177565b610f0c565b6002546102ee906001600160a01b031681565b6040516001600160a01b039091168152602001610204565b610235610314366004613082565b610f69565b61032c610327366004613082565b610fd7565b6040516102049190613247565b6101f8610347366004613082565b61112d565b6101f861035a366004613177565b6111a2565b61037261036d36600461325a565b6111b5565b60405161020491906132cf565b61039261038d366004613082565b6112aa565b6040516102049190613371565b6103b26103ad36600461337f565b6112bb565b60405161020494939291906133b4565b6102ee6103d0366004613082565b611532565b6103e86103e3366004613082565b611618565b60408051928352901515602083015201610204565b61023561040b366004613082565b6118b8565b61022061041e36600461341a565b6119a9565b610220610431366004613082565b611a3d565b6102206104443660046131b0565b611c97565b610220610457366004613082565b611d56565b61022061046a3660046131d2565b611db2565b61032c611f79565b610220610485366004613446565b612007565b80610495813361202c565b6104bd5780604051631e6fd6c360e21b81526004016104b491906134ac565b60405180910390fd5b60008260028111156104d1576104d1613478565b036104ef57604051631dd2188d60e31b815260040160405180910390fd5b6104fa826000612081565b5050565b600254604051634f558e7960e01b8152600481018390526000916001600160a01b031690634f558e7990602401602060405180830381865afa158015610548573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056c91906134bf565b61058857604051626f708760e21b815260040160405180910390fd5b61059182612160565b92915050565b60006105a3813361202c565b6105c25780604051631e6fd6c360e21b81526004016104b491906134ac565b81516105d5906003906020850190612f53565b505050565b816105e5813361202c565b6106045780604051631e6fd6c360e21b81526004016104b491906134ac565b6001600160a01b03821661062b5760405163d92e233d60e01b815260040160405180910390fd5b6105d58383612081565b600080600260009054906101000a90046001600160a01b03166001600160a01b0316634d7c7dc76040518163ffffffff1660e01b8152600401606060405180830381865afa15801561068b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106af91906134e1565b5050600254604051631751d10160e21b8152600481018690529192506000916001600160a01b0390911690635d47440490602401606060405180830381865afa158015610700573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072491906134e1565b9250505080600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561077c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a0919061350f565b6107aa9084613554565b6107b49190613568565b949350505050565b60025460405163430c208160e01b8152336004820152602481018490526001600160a01b039091169063430c208190604401602060405180830381865afa15801561080b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082f91906134bf565b61084b576040516282b42960e81b815260040160405180910390fd5b6002546040516331a9108f60e11b8152600481018490526104fa91849184916001600160a01b031690636352211e90602401602060405180830381865afa15801561089a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108be919061357f565b612292565b60006108cf813361202c565b6108ee5780604051631e6fd6c360e21b81526004016104b491906134ac565b60025460405163f2fde38b60e01b81526001600160a01b0384811660048301529091169063f2fde38b906024015b600060405180830381600087803b15801561093657600080fd5b505af115801561094a573d6000803e3d6000fd5b505050505050565b6002546000906001600160a01b0316331461097f576040516282b42960e81b815260040160405180910390fd5b6109888261112d565b50600254604051634f558e7960e01b8152600481018490526001600160a01b0390911690634f558e7990602401602060405180830381865afa1580156109d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f691906134bf565b15610a0e57610a06826000612349565b506001919050565b5060005b919050565b600260005403610a695760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b4565b60026000908155610a7983611532565b90506000610a86846123c1565b6002805460405163e7d6fbbf60e01b81529293506000926001600160a01b039091169163e7d6fbbf91610abc91906004016134ac565b602060405180830381865afa158015610ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afd919061350f565b600254604051634f558e7960e01b8152600481018890529192506000916001600160a01b0390911690634f558e7990602401602060405180830381865afa158015610b4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b7091906134bf565b15610d8157336001600160a01b03851603610b8e5750505050610f03565b6000610b998761243d565b90508015610d215783915081861015610bc557604051636dddf41160e11b815260040160405180910390fd5b600254604051631daa479b60e21b81526001600160a01b03909116906376a91e6c90610bf99033908990879060040161359c565b600060405180830381600087803b158015610c1357600080fd5b505af1158015610c27573d6000803e3d6000fd5b5050600254604051631614022160e21b81526001600160a01b03909116925063585008849150610c5f90889033908c9060040161359c565b600060405180830381600087803b158015610c7957600080fd5b505af1158015610c8d573d6000803e3d6000fd5b5050600254604051638643700760e01b8152600481018b90526001600160a01b03898116602483015233604483015260648201879052909116925063864370079150608401600060405180830381600087803b158015610cec57600080fd5b505af1158015610d00573d6000803e3d6000fd5b5050505083861115610d1757610d17878733612540565b5050505050610f03565b600254604051630852cd8d60e31b8152600481018990526001600160a01b03909116906342966c6890602401600060405180830381600087803b158015610d6757600080fd5b505af1158015610d7b573d6000803e3d6000fd5b50505050505b508080851015610da457604051636dddf41160e11b815260040160405180910390fd5b600254604051631daa479b60e21b81526001600160a01b03909116906376a91e6c90610dd89033908490869060040161359c565b600060405180830381600087803b158015610df257600080fd5b505af1158015610e06573d6000803e3d6000fd5b50505050610e1586338461278c565b6002546040516340c10f1960e01b8152336004820152602481018890526001600160a01b03909116906340c10f1990604401600060405180830381600087803b158015610e6157600080fd5b505af1158015610e75573d6000803e3d6000fd5b5050600254604051638643700760e01b8152600481018a905260006024820152336044820152606481018590526001600160a01b03909116925063864370079150608401600060405180830381600087803b158015610ed357600080fd5b505af1158015610ee7573d6000803e3d6000fd5b5050505082851115610efe57610efe868633612540565b505050505b50506001600055565b6000610f18813361202c565b610f375780604051631e6fd6c360e21b81526004016104b491906134ac565b6000836002811115610f4b57610f4b613478565b0361060457604051631dd2188d60e31b815260040160405180910390fd5b6002546040516303b1a1e960e31b8152600481018390526000916001600160a01b031690631d8d0f4890602401602060405180830381865afa158015610fb3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610591919061350f565b6002546060906001600160a01b03163314611004576040516282b42960e81b815260040160405180910390fd5b600254604051634f558e7960e01b8152600481018490526001600160a01b0390911690634f558e7990602401602060405180830381865afa15801561104d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107191906134bf565b61108d57604051626f708760e21b815260040160405180910390fd5b600061109883612a8e565b6040516020016110a891906135c0565b60408051601f1981840301815260608301909152603b808352909250600091906138b2602083013990506000611101838360036040516020016110ed9392919061362a565b604051602081830303815290604052612b8f565b9050806040516020016111149190613771565b6040516020818303038152906040529350505050919050565b60006111388261243d565b905080610a1257600254604051630852cd8d60e31b8152600481018490526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561118557600080fd5b505af1158015611199573d6000803e3d6000fd5b50505050919050565b60006111ae838361202c565b9392505050565b60608167ffffffffffffffff8111156111d0576111d061309b565b60405190808252806020026020018201604052801561120357816020015b60608152602001906001900390816111ee5790505b50905060005b828110156112a35761127330858584818110611227576112276137b6565b905060200281019061123991906137cc565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612ce292505050565b828281518110611285576112856137b6565b6020026020010181905250808061129b9061381a565b915050611209565b5092915050565b6112b2612fd7565b61059182612d07565b6002546040516370a0823160e01b81526001600160a01b0385811660048301526000928392839260609284929116906370a0823190602401602060405180830381865afa158015611310573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611334919061350f565b9050866000036113835760408051600080825260208201909252829189918991611374565b611361612fd7565b8152602001906001900390816113595790505b50945094509450945050611529565b8086106113ce5760408051600080825260208201909252829189918991611374565b6113ad612fd7565b8152602001906001900390816113a557905050945094509450945050611529565b60006113da8783613568565b905060008882116113eb57816113ed565b885b905060008167ffffffffffffffff81111561140a5761140a61309b565b60405190808252806020026020018201604052801561144357816020015b611430612fd7565b8152602001906001900390816114285790505b50905060005b82811015611519576002546000906001600160a01b0316632f745c598e6114708e86613833565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381865afa1580156114b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114dd919061350f565b90506114e881612d07565b8383815181106114fa576114fa6137b6565b60200260200101819052505080806115119061381a565b915050611449565b5092965088955087945091925050505b93509350935093565b600254604051634f558e7960e01b8152600481018390526000916001600160a01b031690634f558e7990602401602060405180830381865afa15801561157c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115a091906134bf565b6115ab576000610591565b6002546040516331a9108f60e11b8152600481018490526001600160a01b0390911690636352211e90602401602060405180830381865afa1580156115f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610591919061357f565b6000806000611626846104fe565b905080156118ac576002546040516331a9108f60e11b8152600481018690526000916001600160a01b031690636352211e90602401602060405180830381865afa158015611678573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061169c919061357f565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663e5a6b10f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611717919061357f565b600254604051636eb1769f60e11b81526001600160a01b038581166004830152918216602482015291169063dd62ed3e90604401602060405180830381865afa158015611768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061178c919061350f565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663e5a6b10f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611807919061357f565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa15801561184f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611873919061350f565b905060008183106118845781611886565b825b905084811061189e5750929660009650945050505050565b976001975095505050505050565b50600093849350915050565b600254604051634f558e7960e01b8152600481018390526000916001600160a01b031690634f558e7990602401602060405180830381865afa158015611902573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061192691906134bf565b6119a0576002805460405163e7d6fbbf60e01b81526001600160a01b039091169163e7d6fbbf9161195a91906004016134ac565b602060405180830381865afa158015611977573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199b919061350f565b610591565b610591826123c1565b60016119b5813361202c565b6119d45780604051631e6fd6c360e21b81526004016104b491906134ac565b600254604051637657c11560e11b81526001600160a01b039091169063ecaf822a90611a06908690869060040161384b565b600060405180830381600087803b158015611a2057600080fd5b505af1158015611a34573d6000803e3d6000fd5b50505050505050565b6000611a4882610635565b905080156104fa576002546040516331a9108f60e11b8152600481018490526000916001600160a01b031690636352211e90602401602060405180830381865afa158015611a9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611abe919061357f565b60025460405163e3759abd60e01b81526001600160a01b0380841660048301526024820186905292935091169063e3759abd90604401600060405180830381600087803b158015611b0e57600080fd5b505af1158015611b22573d6000803e3d6000fd5b5050600254604051631751d10160e21b8152600481018790526000935083925082916001600160a01b031690635d47440490602401606060405180830381865afa158015611b74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9891906134e1565b60025492955090935091506001600160a01b031663b3e4ee22878585611bbe8a87613833565b6040516001600160e01b031960e087901b1681526004810194909452602484019290925260448301526064820152608401600060405180830381600087803b158015611c0957600080fd5b505af1158015611c1d573d6000803e3d6000fd5b50506002546040516308b26d3b60e11b8152600481018a90526001600160a01b038881166024830152604482018a90529091169250631164da7691506064015b600060405180830381600087803b158015611c7757600080fd5b505af1158015611c8b573d6000803e3d6000fd5b50505050505050505050565b60025460405163430c208160e01b8152336004820152602481018490526001600160a01b039091169063430c208190604401602060405180830381865afa158015611ce6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d0a91906134bf565b611d26576040516282b42960e81b815260040160405180910390fd5b611d2f826123c1565b8103611d39575050565b6000611d448361112d565b905080156105d5576105d58383612349565b6001611d62813361202c565b611d815780604051631e6fd6c360e21b81526004016104b491906134ac565b60025460405163f7ea7a3d60e01b8152600481018490526001600160a01b039091169063f7ea7a3d9060240161091c565b6002611dbe813361202c565b611ddd5780604051631e6fd6c360e21b81526004016104b491906134ac565b6000806000600260009054906101000a90046001600160a01b03166001600160a01b0316634d7c7dc76040518163ffffffff1660e01b8152600401606060405180830381865afa158015611e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e5991906134e1565b919450925090506000611e6c8284613568565b60025460405163e3759abd60e01b81526001600160a01b0389811660048301526024820184905292935091169063e3759abd90604401600060405180830381600087803b158015611ebc57600080fd5b505af1158015611ed0573d6000803e3d6000fd5b5050600254604051635701e25d60e01b81526001600160a01b038a81166004830152602482018690529091169250635701e25d9150604401600060405180830381600087803b158015611f2257600080fd5b505af1158015611f36573d6000803e3d6000fd5b5050600254604051630b07a84960e31b81526004810188905260248101879052604481018790526001600160a01b03909116925063583d42489150606401611c5d565b60038054611f86906135f0565b80601f0160208091040260200160405190810160405280929190818152602001828054611fb2906135f0565b8015611fff5780601f10611fd457610100808354040283529160200191611fff565b820191906000526020600020905b815481529060010190602001808311611fe257829003601f168201915b505050505081565b6120118484610a17565b61201b8483611c97565b612026848233612292565b50505050565b6000816001600160a01b03166001600085600281111561204e5761204e613478565b600281111561205f5761205f613478565b81526020810191909152604001600020546001600160a01b0316149392505050565b60006001600084600281111561209957612099613478565b60028111156120aa576120aa613478565b815260208101919091526040016000908120546001600160a01b0316915082906001908560028111156120df576120df613478565b60028111156120f0576120f0613478565b8152602081019190915260400160002080546001600160a01b0319166001600160a01b0392831617905582811690821684600281111561213257612132613478565b6040517f796d9fd27d307e851f66684ea6fe5e98600f0d922d136a5717ae5949892cfcf790600090a4505050565b600254604051631751d10160e21b815260048101839052600091829182916001600160a01b031690635d47440490602401606060405180830381865afa1580156121ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121d291906134e1565b5091509150816000036121e9575060009392505050565b60025460405163e7d6fbbf60e01b81526000916001600160a01b03169063e7d6fbbf9061221a9084906004016134ac565b602060405180830381865afa158015612237573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225b919061350f565b90506298968061226b8343613568565b6122758386613862565b61227f9190613862565b6122899190613554565b95945050505050565b6002546040516303b1a1e960e31b81526004810185905283916001600160a01b031690631d8d0f4890602401602060405180830381865afa1580156122db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ff919061350f565b0361230957505050565b6002546040516352f2cfd960e11b815260048101859052602481018490526001600160a01b0383811660448301529091169063a5e59fb290606401611a06565b6002546040516331a9108f60e11b8152600481018490526104fa91849184916001600160a01b031690636352211e90602401602060405180830381865afa158015612398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123bc919061357f565b612540565b600254604051631751d10160e21b81526004810183905260009182916001600160a01b0390911690635d47440490602401606060405180830381865afa15801561240f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061243391906134e1565b5090949350505050565b600080600061244b84611618565b90925090508115612538576002546040516331a9108f60e11b8152600481018690526000916001600160a01b031690636352211e90602401602060405180830381865afa1580156124a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c4919061357f565b600254604051631daa479b60e21b81529192506001600160a01b0316906376a91e6c906124f99084908490889060040161359c565b600060405180830381600087803b15801561251357600080fd5b505af1158015612527573d6000803e3d6000fd5b5050505061253685828561278c565b505b159392505050565b6002546040805163e5a6b10f60e01b815290516000926001600160a01b03169163e5a6b10f9160048083019260209291908290030181865afa15801561258a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125ae919061357f565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061260f919061350f565b90508083111561263557604051630c3db3e760e01b8152600481018290526024016104b4565b600254604051631751d10160e21b8152600481018690526000916001600160a01b031690635d47440490602401606060405180830381865afa15801561267f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a391906134e1565b6002546040516359f2771160e11b8152600481018a905260248101899052436044820152606481018390529194506001600160a01b0316925063b3e4ee229150608401600060405180830381600087803b15801561270057600080fd5b505af1158015612714573d6000803e3d6000fd5b505060025460405163d17d14c560e01b815260048101899052602481018890526001600160a01b038781166044830152909116925063d17d14c59150606401600060405180830381600087803b15801561276d57600080fd5b505af1158015612781573d6000803e3d6000fd5b505050505050505050565b60025460405163e7d6fbbf60e01b81526000916001600160a01b03169063e7d6fbbf906127be906001906004016134ac565b602060405180830381865afa1580156127db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127ff919061350f565b905060006127106128108385613862565b61281a9190613554565b90506000806000600260009054906101000a90046001600160a01b03166001600160a01b0316634d7c7dc76040518163ffffffff1660e01b8152600401606060405180830381865afa158015612874573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061289891906134e1565b60025492955090935091506001600160a01b031663583d42486128bb8689613568565b6128c59086613833565b6128cf8786613833565b6040516001600160e01b031960e085901b1681526004810192909252602482015260448101849052606401600060405180830381600087803b15801561291457600080fd5b505af1158015612928573d6000803e3d6000fd5b5050600254604051631751d10160e21b8152600481018c9052600093508392506001600160a01b0390911690635d47440490602401606060405180830381865afa15801561297a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061299e91906134e1565b6002546040516359f2771160e11b8152600481018f905260248101859052436044820152606481018390529395509093506001600160a01b03169163b3e4ee229150608401600060405180830381600087803b1580156129fd57600080fd5b505af1158015612a11573d6000803e3d6000fd5b5050600254604051632b2163b360e01b8152600481018e90526001600160a01b038d81166024830152604482018d90529091169250632b2163b39150606401600060405180830381600087803b158015612a6a57600080fd5b505af1158015612a7e573d6000803e3d6000fd5b5050505050505050505050505050565b606081600003612ab55750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612adf5780612ac98161381a565b9150612ad89050600a83613554565b9150612ab9565b60008167ffffffffffffffff811115612afa57612afa61309b565b6040519080825280601f01601f191660200182016040528015612b24576020820181803683370190505b5090505b84156107b457612b39600183613568565b9150612b46600a86613881565b612b51906030613833565b60f81b818381518110612b6657612b666137b6565b60200101906001600160f81b031916908160001a905350612b88600a86613554565b9450612b28565b60608151600003612bae57505060408051602081019091526000815290565b60006040518060600160405280604081526020016138ed6040913990506000600384516002612bdd9190613833565b612be79190613554565b612bf2906004613862565b67ffffffffffffffff811115612c0a57612c0a61309b565b6040519080825280601f01601f191660200182016040528015612c34576020820181803683370190505b509050600182016020820185865187015b80821015612ca0576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250612c45565b5050600386510660018114612cbc5760028114612ccf57612cd7565b603d6001830353603d6002830353612cd7565b603d60018303535b509195945050505050565b60606111ae838360405180606001604052806027815260200161392d60279139612e3d565b612d0f612fd7565b600254604051631751d10160e21b8152600481018490526000916001600160a01b031690635d47440490602401606060405180830381865afa158015612d59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d7d91906134e1565b509150506040518060c00160405280848152602001612d9b856118b8565b8152602001828152602001612daf85610635565b8152602001612dbd85611532565b6001600160a01b0390811682526002546040516303b1a1e960e31b815260048101889052602090930192911690631d8d0f4890602401602060405180830381865afa158015612e10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e34919061350f565b90529392505050565b60606001600160a01b0384163b612ea55760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016104b4565b600080856001600160a01b031685604051612ec09190613895565b600060405180830381855af49150503d8060008114612efb576040519150601f19603f3d011682016040523d82523d6000602084013e612f00565b606091505b5091509150612f10828286612f1a565b9695505050505050565b60608315612f295750816111ae565b825115612f395782518084602001fd5b8160405162461bcd60e51b81526004016104b49190613247565b828054612f5f906135f0565b90600052602060002090601f016020900481019282612f815760008555612fc7565b82601f10612f9a57805160ff1916838001178555612fc7565b82800160010185558215612fc7579182015b82811115612fc7578251825591602001919060010190612fac565b50612fd3929150613016565b5090565b6040518060c001604052806000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b5b80821115612fd35760008155600101613017565b60006020828403121561303d57600080fd5b81356001600160e01b0319811681146111ae57600080fd5b6003811061306257600080fd5b50565b60006020828403121561307757600080fd5b81356111ae81613055565b60006020828403121561309457600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000602082840312156130c357600080fd5b813567ffffffffffffffff808211156130db57600080fd5b818401915084601f8301126130ef57600080fd5b8135818111156131015761310161309b565b604051601f8201601f19908116603f011681019083821181831017156131295761312961309b565b8160405282815287602084870101111561314257600080fd5b826020860160208301376000928101602001929092525095945050505050565b6001600160a01b038116811461306257600080fd5b6000806040838503121561318a57600080fd5b823561319581613055565b915060208301356131a581613162565b809150509250929050565b600080604083850312156131c357600080fd5b50508035926020909101359150565b6000602082840312156131e457600080fd5b81356111ae81613162565b60005b8381101561320a5781810151838201526020016131f2565b838111156120265750506000910152565b600081518084526132338160208601602086016131ef565b601f01601f19169290920160200192915050565b6020815260006111ae602083018461321b565b6000806020838503121561326d57600080fd5b823567ffffffffffffffff8082111561328557600080fd5b818501915085601f83011261329957600080fd5b8135818111156132a857600080fd5b8660208260051b85010111156132bd57600080fd5b60209290920196919550909350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561332457603f1988860301845261331285835161321b565b945092850192908501906001016132f6565b5092979650505050505050565b805182526020808201519083015260408082015190830152606080820151908301526080808201516001600160a01b03169083015260a090810151910152565b60c081016105918284613331565b60008060006060848603121561339457600080fd5b833561339f81613162565b95602085013595506040909401359392505050565b600060808201868352602086818501528560408501526080606085015281855180845260a086019150828701935060005b8181101561340b576133f8838651613331565b9383019360c092909201916001016133e5565b50909998505050505050505050565b6000806040838503121561342d57600080fd5b823561343881613055565b946020939093013593505050565b6000806000806080858703121561345c57600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052602160045260246000fd5b6003811061306257634e487b7160e01b600052602160045260246000fd5b602081016134b98361348e565b91905290565b6000602082840312156134d157600080fd5b815180151581146111ae57600080fd5b6000806000606084860312156134f657600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561352157600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008261356357613563613528565b500490565b60008282101561357a5761357a61353e565b500390565b60006020828403121561359157600080fd5b81516111ae81613162565b6001600160a01b039384168152919092166020820152604081019190915260600190565b67506c616e636b202360c01b8152600082516135e38160088501602087016131ef565b9190910160080192915050565b600181811c9082168061360457607f821691505b60208210810361362457634e487b7160e01b600052602260045260246000fd5b50919050565b693d913730b6b2911d101160b11b81528351600090602061365182600a8601838a016131ef565b72111610113232b9b1b934b83a34b7b7111d101160691b600a92850192830152855161368381601d8501848a016131ef565b71222c202261747472696275746573223a205b60701b601d93909101928301526c2e96101134b6b0b3b2911d101160991b602f8301528454603c90600090600181811c90808316806136d657607f831692505b86831081036136f357634e487b7160e01b85526022600452602485fd5b808015613707576001811461371c5761374d565b60ff198516898801528389018701955061374d565b60008c81526020902060005b858110156137435781548b82018a0152908401908901613728565b505086848a010195505b50505050506137648161227d60f01b815260020190565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152600082516137a981601d8501602087016131ef565b91909101601d0192915050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126137e357600080fd5b83018035915067ffffffffffffffff8211156137fe57600080fd5b60200191503681900382131561381357600080fd5b9250929050565b60006001820161382c5761382c61353e565b5060010190565b600082198211156138465761384661353e565b500190565b604081016138588461348e565b9281526020015290565b600081600019048311821515161561387c5761387c61353e565b500290565b60008261389057613890613528565b500690565b600082516138a78184602087016131ef565b919091019291505056fe4f6e65206f662031206d696c6c696f6e20706978656c732074726164656420756e646572204861726265726765722054617820616e64205542492e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a6b7d9e34cf20c2888e201e31ac2271734e7e3364ac3f5d2e1335337d8aedeb964736f6c634300080d003360a06040523480156200001157600080fd5b506040516200299438038062002994833981016040819052620000349162000365565b8651879087906200004d906000906020850190620001f2565b50805162000063906001906020840190620001f2565b505050620000806200007a6200019c60201b60201c565b620001a0565b600b8590556001600160a01b0381166080526000808052600e60209081527fe710864318d4a32f37d6ce54cb3fadbef648dd12d8dbdf53973564d56b7f881c86905560408051878152905160008051602062002974833981519152929181900390910190a260016000819052600e60209081527fa7c5ba7114a813b50159add3a36832908dc83db71d0b9a24c2ad0f83be95820785905560408051868152905160008051602062002974833981519152929181900390910190a260026000819052600e60209081527f9adb202b1492743bc00c81d33cdc6423fa8c79109027eb6a845391e8fc1f048184905560408051858152905160008051602062002974833981519152929181900390910190a25050505050505062000452565b3390565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b828054620002009062000416565b90600052602060002090601f0160209004810192826200022457600085556200026f565b82601f106200023f57805160ff19168380011785556200026f565b828001600101855582156200026f579182015b828111156200026f57825182559160200191906001019062000252565b506200027d92915062000281565b5090565b5b808211156200027d576000815560010162000282565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620002c057600080fd5b81516001600160401b0380821115620002dd57620002dd62000298565b604051601f8301601f19908116603f0116810190828211818310171562000308576200030862000298565b816040528381526020925086838588010111156200032557600080fd5b600091505b838210156200034957858201830151818301840152908201906200032a565b838211156200035b5760008385830101525b9695505050505050565b600080600080600080600060e0888a0312156200038157600080fd5b87516001600160401b03808211156200039957600080fd5b620003a78b838c01620002ae565b985060208a0151915080821115620003be57600080fd5b50620003cd8a828b01620002ae565b96505060408801519450606088015193506080880151925060a0880151915060c088015160018060a01b03811681146200040657600080fd5b8091505092959891949750929550565b600181811c908216806200042b57607f821691505b6020821081036200044c57634e487b7160e01b600052602260045260246000fd5b50919050565b6080516124f86200047c6000396000818161053e01528181610dec015261121d01526124f86000f3fe608060405234801561001057600080fd5b50600436106102535760003560e01c80635d47440411610146578063b3e4ee22116100c3578063e5a6b10f11610087578063e5a6b10f14610539578063e7d6fbbf14610560578063e985e9c514610580578063ecaf822a146105bc578063f2fde38b146105cf578063f7ea7a3d146105e257600080fd5b8063b3e4ee22146104da578063b88d4fde146104ed578063c87b56dd14610500578063d17d14c514610513578063e3759abd1461052657600080fd5b8063864370071161010a57806386437007146104885780638da5cb5b1461049b57806395d89b41146104ac578063a22cb465146104b4578063a5e59fb2146104c757600080fd5b80635d474404146104185780636352211e1461044757806370a082311461045a578063715018a61461046d57806376a91e6c1461047557600080fd5b806340c10f19116101d45780634f558e79116101985780634f558e79146103b95780634f6ccce7146103cc5780635701e25d146103df578063583d4248146103f2578063585008841461040557600080fd5b806340c10f191461035357806342842e0e1461031a57806342966c6814610366578063430c2081146103795780634d7c7dc71461038c57600080fd5b806318160ddd1161021b57806318160ddd146102e85780631d8d0f48146102fa57806323b872dd1461031a5780632b2163b31461032d5780632f745c591461034057600080fd5b806301ffc9a71461025857806306fdde0314610280578063081812fc14610295578063095ea7b3146102c05780631164da76146102d5575b600080fd5b61026b610266366004611e7a565b6105f5565b60405190151581526020015b60405180910390f35b610288610620565b6040516102779190611eef565b6102a86102a3366004611f02565b6106b2565b6040516001600160a01b039091168152602001610277565b6102d36102ce366004611f37565b61074c565b005b6102d36102e3366004611f61565b610861565b600b545b604051908152602001610277565b6102ec610308366004611f02565b600d6020526000908152604090205481565b6102d3610328366004611f96565b6108d4565b6102d361033b366004611f61565b6108ef565b6102ec61034e366004611f37565b610955565b6102d3610361366004611f37565b6109eb565b6102d3610374366004611f02565b610a5f565b61026b610387366004611f37565b610a95565b600f5460105460115461039e92919083565b60408051938452602084019290925290820152606001610277565b61026b6103c7366004611f02565b610aa8565b6102ec6103da366004611f02565b610ac7565b6102d36103ed366004611f37565b610b5a565b6102d3610400366004611fc2565b610bcb565b6102d3610413366004611f96565b610c1b565b61039e610426366004611f02565b600c6020526000908152604090208054600182015460029092015490919083565b6102a8610455366004611f02565b610c60565b6102ec610468366004611fee565b610cd7565b6102d3610d5e565b6102d3610483366004611f96565b610d94565b6102d3610496366004612009565b610e5f565b600a546001600160a01b03166102a8565b610288610edd565b6102d36104c236600461205b565b610eec565b6102d36104d5366004612092565b610ef7565b6102d36104e83660046120c7565b610f6b565b6102d36104fb366004612168565b610fd0565b61028861050e366004611f02565b6110e1565b6102d3610521366004612092565b611167565b6102d3610534366004611f37565b6111cd565b6102a87f000000000000000000000000000000000000000000000000000000000000000081565b6102ec61056e366004612222565b600e6020526000908152604090205481565b61026b61058e36600461223d565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102d36105ca366004612270565b61128a565b6102d36105dd366004611fee565b61132f565b6102d36105f0366004611f02565b6113c7565b60006001600160e01b0319821663780e9d6360e01b148061061a575061061a82611432565b92915050565b60606000805461062f9061228c565b80601f016020809104026020016040519081016040528092919081815260200182805461065b9061228c565b80156106a85780601f1061067d576101008083540402835291602001916106a8565b820191906000526020600020905b81548152906001019060200180831161068b57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107305760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061075782610c60565b9050806001600160a01b0316836001600160a01b0316036107c45760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610727565b336001600160a01b03821614806107e057506107e0813361058e565b6108525760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610727565b61085c8383611482565b505050565b600a546001600160a01b0316331461088b5760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b0316837fa760fe80056c46d089c37a35d9dbe762141a463ae0eb8235522d27ab9595286d836040516108c791815260200190565b60405180910390a3505050565b61085c83838360405180602001604052806000815250610fd0565b600a546001600160a01b031633146109195760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b0316837fc5790222911f43ca7d78c4f5ef5cb5a21d7fda4d923d433b80e7db9c295de88a836040516108c791815260200190565b600061096083610cd7565b82106109c25760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610727565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610a155760405162461bcd60e51b8152600401610727906122c6565b600b54811180610a255750600181105b15610a5157600b5460405163168a450960e21b8152600160048201526024810191909152604401610727565b610a5b82826114f0565b5050565b600a546001600160a01b03163314610a895760405162461bcd60e51b8152600401610727906122c6565b610a928161150a565b50565b6000610aa183836115b1565b9392505050565b6000818152600260205260408120546001600160a01b0316151561061a565b6000610ad260085490565b8210610b355760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610727565b60088281548110610b4857610b486122fb565b90600052602060002001549050919050565b600a546001600160a01b03163314610b845760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b03167f782743bed566521eb169ba5186430a0e29079bfd1bdf4fc061bd63b48729846682604051610bbf91815260200190565b60405180910390a25050565b600a546001600160a01b03163314610bf55760405162461bcd60e51b8152600401610727906122c6565b604080516060810182528481526020810184905201819052600f92909255601055601155565b600a546001600160a01b03163314610c455760405162461bcd60e51b8152600401610727906122c6565b61085c838383604051806020016040528060008152506116a8565b6000818152600260205260408120546001600160a01b03168061061a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610727565b60006001600160a01b038216610d425760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610727565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610d885760405162461bcd60e51b8152600401610727906122c6565b610d9260006116db565b565b600a546001600160a01b03163314610dbe5760405162461bcd60e51b8152600401610727906122c6565b6040516323b872dd60e01b81526001600160a01b0384811660048301528381166024830152604482018390527f000000000000000000000000000000000000000000000000000000000000000016906323b872dd906064016020604051808303816000875af1158015610e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e599190612311565b50505050565b600a546001600160a01b03163314610e895760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b0316836001600160a01b0316857fc12a40285e912bef139dd458d6bb29f54ba3b7bb9513d442a8c16a3f0a649eed84604051610ecf91815260200190565b60405180910390a450505050565b60606001805461062f9061228c565b610a5b33838361172d565b600a546001600160a01b03163314610f215760405162461bcd60e51b8152600401610727906122c6565b6000838152600d6020526040808220849055516001600160a01b03831691849186917f8da7074ffa2c919782faaf9705c7edfe7f814551a91b91aed83ee2ef5ac6af2791a4505050565b600a546001600160a01b03163314610f955760405162461bcd60e51b8152600401610727906122c6565b6040805160608101825293845260208085019384528482019283526000958652600c9052909320915182555160018201559051600290910155565b610fda33836115b1565b6110405760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610727565b6000611054600a546001600160a01b031690565b604051633f8c2b5b60e01b8152600481018590529091506000906001600160a01b03831690633f8c2b5b906024016020604051808303816000875af11580156110a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c59190612311565b905080156110d9576110d9868686866116a8565b505050505050565b606060006110f7600a546001600160a01b031690565b60405163468bf38960e11b8152600481018590529091506001600160a01b03821690638d17e71290602401600060405180830381865afa15801561113f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610aa1919081019061232e565b600a546001600160a01b031633146111915760405162461bcd60e51b8152600401610727906122c6565b806001600160a01b0316837f75a0543aefc16d03b25751bdf0b5a2fbbec05c6436fd60b038d40f5b7d1def83846040516108c791815260200190565b600a546001600160a01b031633146111f75760405162461bcd60e51b8152600401610727906122c6565b60405163a9059cbb60e01b81526001600160a01b038381166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015611266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085c9190612311565b600a546001600160a01b031633146112b45760405162461bcd60e51b8152600401610727906122c6565b80600e60008460028111156112cb576112cb6123a5565b60028111156112dc576112dc6123a5565b81526020810191909152604001600020558160028111156112ff576112ff6123a5565b6040518281527f90e64b63a2c952a97e60fcb9bdb464e5e76d2920683504331028687f0cd6643b90602001610bbf565b600a546001600160a01b031633146113595760405162461bcd60e51b8152600401610727906122c6565b6001600160a01b0381166113be5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610727565b610a92816116db565b600a546001600160a01b031633146113f15760405162461bcd60e51b8152600401610727906122c6565b600b5460408051918252602082018390527fce065be89501ad8aef77e0eb0160264c2d1eb1732a004bcb98735bb0b8102205910160405180910390a1600b55565b60006001600160e01b031982166380ac58cd60e01b148061146357506001600160e01b03198216635b5e139f60e01b145b8061061a57506301ffc9a760e01b6001600160e01b031983161461061a565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906114b782610c60565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610a5b8282604051806020016040528060008152506117f3565b600061151582610c60565b905061152381600084611826565b61152e600083611482565b6001600160a01b03811660009081526003602052604081208054600192906115579084906123d1565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000818152600260205260408120546001600160a01b031661162a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610727565b600061163583610c60565b9050806001600160a01b0316846001600160a01b031614806116705750836001600160a01b0316611665846106b2565b6001600160a01b0316145b806116a057506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b6116b38484846118de565b6116bf84848484611a85565b610e595760405162461bcd60e51b8152600401610727906123e8565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361178e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610727565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3191016108c7565b6117fd8383611b86565b61180a6000848484611a85565b61085c5760405162461bcd60e51b8152600401610727906123e8565b6001600160a01b0383166118815761187c81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6118a4565b816001600160a01b0316836001600160a01b0316146118a4576118a48382611cd4565b6001600160a01b0382166118bb5761085c81611d71565b826001600160a01b0316826001600160a01b03161461085c5761085c8282611e20565b826001600160a01b03166118f182610c60565b6001600160a01b0316146119555760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610727565b6001600160a01b0382166119b75760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610727565b6119c2838383611826565b6119cd600082611482565b6001600160a01b03831660009081526003602052604081208054600192906119f69084906123d1565b90915550506001600160a01b0382166000908152600360205260408120805460019290611a2490849061243a565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60006001600160a01b0384163b15611b7b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611ac9903390899088908890600401612452565b6020604051808303816000875af1925050508015611b04575060408051601f3d908101601f19168201909252611b019181019061248f565b60015b611b61573d808015611b32576040519150601f19603f3d011682016040523d82523d6000602084013e611b37565b606091505b508051600003611b595760405162461bcd60e51b8152600401610727906123e8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506116a0565b506001949350505050565b6001600160a01b038216611bdc5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610727565b6000818152600260205260409020546001600160a01b031615611c415760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610727565b611c4d60008383611826565b6001600160a01b0382166000908152600360205260408120805460019290611c7690849061243a565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001611ce184610cd7565b611ceb91906123d1565b600083815260076020526040902054909150808214611d3e576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611d83906001906123d1565b60008381526009602052604081205460088054939450909284908110611dab57611dab6122fb565b906000526020600020015490508060088381548110611dcc57611dcc6122fb565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611e0457611e046124ac565b6001900381819060005260206000200160009055905550505050565b6000611e2b83610cd7565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160e01b031981168114610a9257600080fd5b600060208284031215611e8c57600080fd5b8135610aa181611e64565b60005b83811015611eb2578181015183820152602001611e9a565b83811115610e595750506000910152565b60008151808452611edb816020860160208601611e97565b601f01601f19169290920160200192915050565b602081526000610aa16020830184611ec3565b600060208284031215611f1457600080fd5b5035919050565b80356001600160a01b0381168114611f3257600080fd5b919050565b60008060408385031215611f4a57600080fd5b611f5383611f1b565b946020939093013593505050565b600080600060608486031215611f7657600080fd5b83359250611f8660208501611f1b565b9150604084013590509250925092565b600080600060608486031215611fab57600080fd5b611fb484611f1b565b9250611f8660208501611f1b565b600080600060608486031215611fd757600080fd5b505081359360208301359350604090920135919050565b60006020828403121561200057600080fd5b610aa182611f1b565b6000806000806080858703121561201f57600080fd5b8435935061202f60208601611f1b565b925061203d60408601611f1b565b9396929550929360600135925050565b8015158114610a9257600080fd5b6000806040838503121561206e57600080fd5b61207783611f1b565b915060208301356120878161204d565b809150509250929050565b6000806000606084860312156120a757600080fd5b83359250602084013591506120be60408501611f1b565b90509250925092565b600080600080608085870312156120dd57600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612138576121386120f9565b604052919050565b600067ffffffffffffffff82111561215a5761215a6120f9565b50601f01601f191660200190565b6000806000806080858703121561217e57600080fd5b61218785611f1b565b935061219560208601611f1b565b925060408501359150606085013567ffffffffffffffff8111156121b857600080fd5b8501601f810187136121c957600080fd5b80356121dc6121d782612140565b61210f565b8181528860208385010111156121f157600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b803560038110611f3257600080fd5b60006020828403121561223457600080fd5b610aa182612213565b6000806040838503121561225057600080fd5b61225983611f1b565b915061226760208401611f1b565b90509250929050565b6000806040838503121561228357600080fd5b611f5383612213565b600181811c908216806122a057607f821691505b6020821081036122c057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561232357600080fd5b8151610aa18161204d565b60006020828403121561234057600080fd5b815167ffffffffffffffff81111561235757600080fd5b8201601f8101841361236857600080fd5b80516123766121d782612140565b81815285602083850101111561238b57600080fd5b61239c826020830160208601611e97565b95945050505050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000828210156123e3576123e36123bb565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6000821982111561244d5761244d6123bb565b500190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061248590830184611ec3565b9695505050505050565b6000602082840312156124a157600080fd5b8151610aa181611e64565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220a4486a95fb302039e97091d89901e50103de8ad02f52ad032b2dd5f1a436dae864736f6c634300080d003390e64b63a2c952a97e60fcb9bdb464e5e76d2920683504331028687f0cd6643b000000000000000000000000264808855b0a6a5a318d238c6ee9f299179f27fc00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000edc934329433f7d151bb38c56e91fe5a8d4a2c600000000000000000000000001d52e2b5b74420d3633d8690a60bb3ea0345b58600000000000000000000000011c37333c6204ae05e5450d8a304d22ee4ba8de80000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d5645514a3257675a556b574b7a666b486d4576377638444654526878775a47444868776f69323348766e70620000000000000000000000

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

000000000000000000000000264808855b0a6a5a318d238c6ee9f299179f27fc00000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000edc934329433f7d151bb38c56e91fe5a8d4a2c600000000000000000000000001d52e2b5b74420d3633d8690a60bb3ea0345b58600000000000000000000000011c37333c6204ae05e5450d8a304d22ee4ba8de80000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d5645514a3257675a556b574b7a666b486d4576377638444654526878775a47444868776f69323348766e70620000000000000000000000

-----Decoded View---------------
Arg [0] : currencyAddress_ (address): 0x264808855b0a6a5a318d238c6ee9f299179f27fc
Arg [1] : tokenImageURI_ (string): ipfs://QmVEQJ2WgZUkWKzfkHmEv7v8DFTRhxwZGDHhwoi23Hvnpb
Arg [2] : aclManager_ (address): 0xedc934329433f7d151bb38c56e91fe5a8d4a2c60
Arg [3] : marketAdmin_ (address): 0x1d52e2b5b74420d3633d8690a60bb3ea0345b586
Arg [4] : treasuryAdmin_ (address): 0x11c37333c6204ae05e5450d8a304d22ee4ba8de8

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000264808855b0a6a5a318d238c6ee9f299179f27fc
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [2] : 000000000000000000000000edc934329433f7d151bb38c56e91fe5a8d4a2c60
Arg [3] : 0000000000000000000000001d52e2b5b74420d3633d8690a60bb3ea0345b586
Arg [4] : 00000000000000000000000011c37333c6204ae05e5450d8a304d22ee4ba8de8
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000035
Arg [6] : 697066733a2f2f516d5645514a3257675a556b574b7a666b486d457637763844
Arg [7] : 4654526878775a47444868776f69323348766e70620000000000000000000000


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