Contract 0x9b71045ac2a1563dc5ff8e0c537413a6aae16cd1

 

Contract Overview

The Space: Proxy
Balance:
0 MATIC

MATIC Value:
$0.00

Token:
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x24e548cf49d40ed7512db6bd6b5d04bfa751c63c007cef82b567dab37bdaad99Set Pixel335006042022-09-24 8:36:0210 hrs 21 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000013
0x3dbe647b9d4747a141d42a44b7aef90b2dfb9d3ebb3b39e21bc5b49441209ee5Set Pixel335006002022-09-24 8:35:5410 hrs 21 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000012
0x0570e128b32347e756524638a6bf3d0bfeba170cde5de27df675479b0088fbacSet Pixel335005962022-09-24 8:35:4610 hrs 22 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000013
0x815ff65e9df65b11a6a8bb66b3d1e828b2d80f06c6fef005b33dcad81224756bSet Pixel335005942022-09-24 8:35:4210 hrs 22 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210004 30.000000014
0xe1c979282e1fb41376d607992a272faab34d0d5c597242413d74c9f1b6d167e4Set Pixel335005892022-09-24 8:35:3210 hrs 22 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000013
0x807aa6c97e016661170fc52e3583a1433e76ff9cbbf1c2d0a69bcf5b91cab399Set Pixel335005852022-09-24 8:35:2410 hrs 22 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000013
0x857ea0c12008cd71358b384f3aabc99a903c2ced947a174537a63c1635769a29Set Pixel335005812022-09-24 8:35:1610 hrs 22 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210004 30.000000014
0x6aa1e8c157282e32425be3a3999d2751d232774f032c0b142c4db82947959d8dSet Pixel335005242022-09-24 8:33:1810 hrs 24 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.009791992864 32.980000016
0x928954aa140638e5ca07e8e3d66839ab877b9ed4cf9790d1fe5766b30bd6a0e5Set Pixel335005182022-09-24 8:33:0610 hrs 24 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.009907192777 33.368000005
0xc6c3a86f9694dce1a63fed502aa0785babd972e452e6a24a71d6ce8f9af2ca25Set Pixel335005132022-09-24 8:32:5610 hrs 24 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.010160632591 34.221600001
0xc13d658fcb428e0d2e837188b7f19597b693bdd60e3ee7fa0305bb4204c07366Set Pixel335005092022-09-24 8:32:4810 hrs 25 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000013
0x651d8bd120cb530f0cd9eef309f289356e9a665431b6dc6fb03de76690e9c1d2Set Pixel335004812022-09-24 8:31:5210 hrs 25 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000012
0x26cafdc69c9a091ad2ce2f219b7f4c5e4aed07d143c9975053b90ff5a5797127Set Pixel335004812022-09-24 8:31:5210 hrs 25 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000012
0xcb1de18f76f3a08afe1a8d5a6682270d9bd2e1a2b71fbb56d4b4f2aa2bd1c59fSet Pixel335004672022-09-24 8:31:2010 hrs 26 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000012
0x28b2ed3bd403e2b5b91b6ac4f6bd2c67dea0ffd8b3e74c48afb8f57d11a30093Set Pixel335004632022-09-24 8:31:1210 hrs 26 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000012
0xa8689238b58e06a3d242721abc7db536595cdcf627f6247778fcab3bd21021b9Set Pixel335004602022-09-24 8:31:0610 hrs 26 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000012
0x3045884edd137f94ce3aa408aef30de7ba4887c8536bc7f0d0bc6cc37e5833f4Set Pixel335004572022-09-24 8:31:0010 hrs 26 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000011
0xca22c1f578e4f7ca962d524365ecbe1e65c5b67e9e636daf872a473de577e020Set Pixel335004432022-09-24 8:30:3210 hrs 27 mins ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210003 30.000000012
0x4948ec11464f3a0b64253c0361f4c276a7c988f01a8659c7d1cb825ac4dd766bSet Pixel334745532022-09-23 17:25:331 day 1 hr ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.009480455726 31.93072486
0xf43afcd3b403694d8dcb773e20ec8daca1b76e2cd364ce0218ad58270073a372Set Pixel334309722022-09-22 16:10:112 days 2 hrs ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.009093161236 30.626294553
0x8ccea166a320af7738023ecbca282919454be9abf9a4af920e9764294abda0e3Set Pixel334309722022-09-22 16:10:112 days 2 hrs ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210006 30.000000023
0x43e28b4e278f9f8dc250e55dcf5e5459ba6a879c956068d21c1dcc28bbe6215dSet Pixel334309722022-09-22 16:10:112 days 2 hrs ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008907210006 30.000000023
0x3b7b12a579160b0366c6cec98544a2030e58e28fd79b810f4f10df24331c105bSet Pixel334309722022-09-22 16:10:112 days 2 hrs ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.009071993388 30.555000012
0x4f8002784aacbfcc52ad2edfbf2ec9491f6f296158717bd1029888de2d66f87fSet Pixel334309722022-09-22 16:10:112 days 2 hrs ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.008927993495 30.070000018
0xdcc983a9f623788e662820cb2be8d577c14e1d26e31262bb59cb47828238e742Set Pixel334309722022-09-22 16:10:112 days 2 hrs ago0x6778bac05212728b9998825feefc0521d58081dd IN  The Space: Proxy0 MATIC0.009071993387 30.555000007
[ Download CSV Export 

OVERVIEW

The Space: an everlasting co-creation blockchain graffiti wall shared and governed by all participants through radical market principles.

Parent Txn Hash Block From To Value
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_,
        address registryAddress_,
        string memory tokenImageURI_,
        address aclManager_,
        address marketAdmin_,
        address treasuryAdmin_
    ) ACLManager(aclManager_, marketAdmin_, treasuryAdmin_) {
        // deploy logic contract only and upgrade later
        if (registryAddress_ != address(0)) {
            registry = TheSpaceRegistry(registryAddress_);
        }
        // deploy logic and registry contracts
        else {
            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);

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

    //////////////////////////////
    /// 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",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"currencyAddress_","type":"address"},{"internalType":"address","name":"registryAddress_","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"}]

60c06040526007608081905266697066733a2f2f60c81b60a09081526200002a916003919062000335565b503480156200003857600080fd5b5060405162006a2138038062006a218339810160408190526200005b916200041c565b60016000558282826001600160a01b0383166200008b5760405163d92e233d60e01b815260040160405180910390fd5b6200009860008462000247565b620000a560018362000247565b620000b260028262000247565b5050506001600160a01b03851615620000e657600280546001600160a01b0319166001600160a01b03871617905562000225565b620f4240600c6000886001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156200012d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000153919062000557565b620001639060ff16600a62000698565b62000170906001620006a6565b896040516200017f90620003c4565b60e080825260069082015265506c616e636b60d01b6101008201526101206020820181905260039082015262504c4b60e81b61014082015260408101959095526060850193909352608084019190915260a08301526001600160a01b031660c082015261016001604051809103906000f08015801562000203573d6000803e3d6000fd5b50600280546001600160a01b0319166001600160a01b03929092169190911790555b83516200023a90600390602087019062000335565b505050505050506200071a565b600060016000846002811115620002625762000262620006c8565b6002811115620002765762000276620006c8565b815260208101919091526040016000908120546001600160a01b031691508290600190856002811115620002ae57620002ae620006c8565b6002811115620002c257620002c2620006c8565b8152602081019190915260400160002080546001600160a01b0319166001600160a01b03928316179055828116908216846002811115620003075762000307620006c8565b6040517f796d9fd27d307e851f66684ea6fe5e98600f0d922d136a5717ae5949892cfcf790600090a4505050565b8280546200034390620006de565b90600052602060002090601f016020900481019282620003675760008555620003b2565b82601f106200038257805160ff1916838001178555620003b2565b82800160010185558215620003b2579182015b82811115620003b257825182559160200191906001019062000395565b50620003c0929150620003d2565b5090565b612994806200408d83390190565b5b80821115620003c05760008155600101620003d3565b80516001600160a01b03811681146200040157600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60008060008060008060c087890312156200043657600080fd5b6200044187620003e9565b9550602062000452818901620003e9565b60408901519096506001600160401b03808211156200047057600080fd5b818a0191508a601f8301126200048557600080fd5b8151818111156200049a576200049a62000406565b604051601f8201601f19908116603f01168101908382118183101715620004c557620004c562000406565b816040528281528d86848701011115620004de57600080fd5b600093505b82841015620005025784840186015181850187015292850192620004e3565b82841115620005145760008684830101525b8099505050505050506200052b60608801620003e9565b92506200053b60808801620003e9565b91506200054b60a08801620003e9565b90509295509295509295565b6000602082840312156200056a57600080fd5b815160ff811681146200057c57600080fd5b9392505050565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620005da578160001904821115620005be57620005be62000583565b80851615620005cc57918102915b93841c93908002906200059e565b509250929050565b600082620005f35750600162000692565b81620006025750600062000692565b81600181146200061b5760028114620006265762000646565b600191505062000692565b60ff8411156200063a576200063a62000583565b50506001821b62000692565b5060208310610133831016604e8410600b84101617156200066b575081810a62000692565b62000677838362000599565b80600019048211156200068e576200068e62000583565b0290505b92915050565b60006200057c8383620005e2565b6000816000190483118215151615620006c357620006c362000583565b500290565b634e487b7160e01b600052602160045260246000fd5b600181811c90821680620006f357607f821691505b6020821081036200071457634e487b7160e01b600052602260045260246000fd5b50919050565b613963806200072a6000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80638ec8c50411610104578063e7572230116100a2578063f7ea7a3d11610071578063f7ea7a3d14610449578063f86c9e9a1461045c578063fce58c171461046f578063ff1644d81461047757600080fd5b8063e7572230146103fd578063ecaf822a14610410578063ee1ef07e14610423578063f7d975771461043657600080fd5b8063b4f80eb9116100de578063b4f80eb91461037f578063c0aed4a71461039f578063c41a360a146103c2578063cf3a421f146103d557600080fd5b80638ec8c504146103395780639e97b8f61461034c578063ac9650d81461035f57600080fd5b80633659cfe6116101715780635d5664e11161014b5780635d5664e1146102c85780637b103999146102db57806380057b9a146103065780638d17e7121461031957600080fd5b80633659cfe61461028f5780633f8c2b5b146102a2578063598647f8146102b557600080fd5b80630f920904116101ad5780630f9209041461024357806310718d3b1461025657806310ac4e7414610269578063242d81cd1461027c57600080fd5b806301ffc9a7146101d4578063057c9cb81461020d578063099da37f14610222575b600080fd5b6101f86101e2366004613005565b6001600160e01b031916631f37ad1b60e21b1490565b60405190151581526020015b60405180910390f35b61022061021b36600461303f565b61048a565b005b61023561023036600461305c565b6104fe565b604051908152602001610204565b61022061025136600461308b565b610597565b610220610264366004613151565b6105da565b61023561027736600461305c565b610635565b61022061028a36600461318a565b6107bc565b61022061029d3660046131ac565b6108c3565b6101f86102b036600461305c565b610952565b6102206102c336600461318a565b610a17565b6102206102d6366004613151565b610ee6565b6002546102ee906001600160a01b031681565b6040516001600160a01b039091168152602001610204565b61023561031436600461305c565b610f43565b61032c61032736600461305c565b610fb1565b6040516102049190613221565b6101f861034736600461305c565b611107565b6101f861035a366004613151565b61117c565b61037261036d366004613234565b61118f565b60405161020491906132a9565b61039261038d36600461305c565b611284565b604051610204919061334b565b6103b26103ad366004613359565b611295565b604051610204949392919061338e565b6102ee6103d036600461305c565b61150c565b6103e86103e336600461305c565b6115f2565b60408051928352901515602083015201610204565b61023561040b36600461305c565b611892565b61022061041e3660046133f4565b611983565b61022061043136600461305c565b611a17565b61022061044436600461318a565b611c71565b61022061045736600461305c565b611d30565b61022061046a3660046131ac565b611d8c565b61032c611f53565b610220610485366004613420565b611fe1565b806104958133612006565b6104bd5780604051631e6fd6c360e21b81526004016104b49190613486565b60405180910390fd5b60008260028111156104d1576104d1613452565b036104ef57604051631dd2188d60e31b815260040160405180910390fd5b6104fa82600061205b565b5050565b600254604051634f558e7960e01b8152600481018390526000916001600160a01b031690634f558e7990602401602060405180830381865afa158015610548573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056c9190613499565b61058857604051626f708760e21b815260040160405180910390fd5b6105918261213a565b92915050565b60006105a38133612006565b6105c25780604051631e6fd6c360e21b81526004016104b49190613486565b81516105d5906003906020850190612f2d565b505050565b816105e58133612006565b6106045780604051631e6fd6c360e21b81526004016104b49190613486565b6001600160a01b03821661062b5760405163d92e233d60e01b815260040160405180910390fd5b6105d5838361205b565b600080600260009054906101000a90046001600160a01b03166001600160a01b0316634d7c7dc76040518163ffffffff1660e01b8152600401606060405180830381865afa15801561068b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106af91906134bb565b5050600254604051631751d10160e21b8152600481018690529192506000916001600160a01b0390911690635d47440490602401606060405180830381865afa158015610700573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061072491906134bb565b9250505080600260009054906101000a90046001600160a01b03166001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561077c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107a091906134e9565b6107aa908461352e565b6107b49190613542565b949350505050565b60025460405163430c208160e01b8152336004820152602481018490526001600160a01b039091169063430c208190604401602060405180830381865afa15801561080b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061082f9190613499565b61084b576040516282b42960e81b815260040160405180910390fd5b6002546040516331a9108f60e11b8152600481018490526104fa91849184916001600160a01b031690636352211e90602401602060405180830381865afa15801561089a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108be9190613559565b61226c565b60006108cf8133612006565b6108ee5780604051631e6fd6c360e21b81526004016104b49190613486565b60025460405163f2fde38b60e01b81526001600160a01b0384811660048301529091169063f2fde38b906024015b600060405180830381600087803b15801561093657600080fd5b505af115801561094a573d6000803e3d6000fd5b505050505050565b6002546000906001600160a01b0316331461097f576040516282b42960e81b815260040160405180910390fd5b61098882611107565b50600254604051634f558e7960e01b8152600481018490526001600160a01b0390911690634f558e7990602401602060405180830381865afa1580156109d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f69190613499565b15610a0e57610a06826000612323565b506001919050565b5060005b919050565b600260005403610a695760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b4565b60026000908155610a798361150c565b90506000610a868461239b565b6002805460405163e7d6fbbf60e01b81529293506000926001600160a01b039091169163e7d6fbbf91610abc9190600401613486565b602060405180830381865afa158015610ad9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610afd91906134e9565b600254604051634f558e7960e01b8152600481018890529192506000916001600160a01b0390911690634f558e7990602401602060405180830381865afa158015610b4c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b709190613499565b15610d6e57336001600160a01b03851603610b8e5750505050610edd565b6000610b9987612417565b90508015610d0e5783915081861015610bc557604051636dddf41160e11b815260040160405180910390fd5b600254604051631daa479b60e21b81526001600160a01b03909116906376a91e6c90610bf990339089908790600401613576565b600060405180830381600087803b158015610c1357600080fd5b505af1158015610c27573d6000803e3d6000fd5b5050600254604051631614022160e21b81526001600160a01b03909116925063585008849150610c5f90889033908c90600401613576565b600060405180830381600087803b158015610c7957600080fd5b505af1158015610c8d573d6000803e3d6000fd5b5050600254604051638643700760e01b8152600481018b90526001600160a01b03898116602483015233604483015260648201879052909116925063864370079150608401600060405180830381600087803b158015610cec57600080fd5b505af1158015610d00573d6000803e3d6000fd5b505050505050505050610edd565b600254604051630852cd8d60e31b8152600481018990526001600160a01b03909116906342966c6890602401600060405180830381600087803b158015610d5457600080fd5b505af1158015610d68573d6000803e3d6000fd5b50505050505b508080851015610d9157604051636dddf41160e11b815260040160405180910390fd5b600254604051631daa479b60e21b81526001600160a01b03909116906376a91e6c90610dc590339084908690600401613576565b600060405180830381600087803b158015610ddf57600080fd5b505af1158015610df3573d6000803e3d6000fd5b50505050610e0286338461251a565b6002546040516340c10f1960e01b8152336004820152602481018890526001600160a01b03909116906340c10f1990604401600060405180830381600087803b158015610e4e57600080fd5b505af1158015610e62573d6000803e3d6000fd5b5050600254604051638643700760e01b8152600481018a905260006024820152336044820152606481018590526001600160a01b03909116925063864370079150608401600060405180830381600087803b158015610ec057600080fd5b505af1158015610ed4573d6000803e3d6000fd5b50505050505050505b50506001600055565b6000610ef28133612006565b610f115780604051631e6fd6c360e21b81526004016104b49190613486565b6000836002811115610f2557610f25613452565b0361060457604051631dd2188d60e31b815260040160405180910390fd5b6002546040516303b1a1e960e31b8152600481018390526000916001600160a01b031690631d8d0f4890602401602060405180830381865afa158015610f8d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061059191906134e9565b6002546060906001600160a01b03163314610fde576040516282b42960e81b815260040160405180910390fd5b600254604051634f558e7960e01b8152600481018490526001600160a01b0390911690634f558e7990602401602060405180830381865afa158015611027573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061104b9190613499565b61106757604051626f708760e21b815260040160405180910390fd5b60006110728361281c565b604051602001611082919061359a565b60408051601f1981840301815260608301909152603b8083529092506000919061388c6020830139905060006110db838360036040516020016110c793929190613604565b60405160208183030381529060405261291d565b9050806040516020016110ee919061374b565b6040516020818303038152906040529350505050919050565b600061111282612417565b905080610a1257600254604051630852cd8d60e31b8152600481018490526001600160a01b03909116906342966c6890602401600060405180830381600087803b15801561115f57600080fd5b505af1158015611173573d6000803e3d6000fd5b50505050919050565b60006111888383612006565b9392505050565b60608167ffffffffffffffff8111156111aa576111aa613075565b6040519080825280602002602001820160405280156111dd57816020015b60608152602001906001900390816111c85790505b50905060005b8281101561127d5761124d3085858481811061120157611201613790565b905060200281019061121391906137a6565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612a7092505050565b82828151811061125f5761125f613790565b60200260200101819052508080611275906137f4565b9150506111e3565b5092915050565b61128c612fb1565b61059182612a95565b6002546040516370a0823160e01b81526001600160a01b0385811660048301526000928392839260609284929116906370a0823190602401602060405180830381865afa1580156112ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061130e91906134e9565b90508660000361135d576040805160008082526020820190925282918991899161134e565b61133b612fb1565b8152602001906001900390816113335790505b50945094509450945050611503565b8086106113a8576040805160008082526020820190925282918991899161134e565b611387612fb1565b81526020019060019003908161137f57905050945094509450945050611503565b60006113b48783613542565b905060008882116113c557816113c7565b885b905060008167ffffffffffffffff8111156113e4576113e4613075565b60405190808252806020026020018201604052801561141d57816020015b61140a612fb1565b8152602001906001900390816114025790505b50905060005b828110156114f3576002546000906001600160a01b0316632f745c598e61144a8e8661380d565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401602060405180830381865afa158015611493573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114b791906134e9565b90506114c281612a95565b8383815181106114d4576114d4613790565b60200260200101819052505080806114eb906137f4565b915050611423565b5092965088955087945091925050505b93509350935093565b600254604051634f558e7960e01b8152600481018390526000916001600160a01b031690634f558e7990602401602060405180830381865afa158015611556573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061157a9190613499565b611585576000610591565b6002546040516331a9108f60e11b8152600481018490526001600160a01b0390911690636352211e90602401602060405180830381865afa1580156115ce573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105919190613559565b6000806000611600846104fe565b90508015611886576002546040516331a9108f60e11b8152600481018690526000916001600160a01b031690636352211e90602401602060405180830381865afa158015611652573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116769190613559565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663e5a6b10f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f19190613559565b600254604051636eb1769f60e11b81526001600160a01b038581166004830152918216602482015291169063dd62ed3e90604401602060405180830381865afa158015611742573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061176691906134e9565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663e5a6b10f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117e19190613559565b6040516370a0823160e01b81526001600160a01b03858116600483015291909116906370a0823190602401602060405180830381865afa158015611829573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061184d91906134e9565b9050600081831061185e5781611860565b825b90508481106118785750929660009650945050505050565b976001975095505050505050565b50600093849350915050565b600254604051634f558e7960e01b8152600481018390526000916001600160a01b031690634f558e7990602401602060405180830381865afa1580156118dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119009190613499565b61197a576002805460405163e7d6fbbf60e01b81526001600160a01b039091169163e7d6fbbf916119349190600401613486565b602060405180830381865afa158015611951573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061197591906134e9565b610591565b6105918261239b565b600161198f8133612006565b6119ae5780604051631e6fd6c360e21b81526004016104b49190613486565b600254604051637657c11560e11b81526001600160a01b039091169063ecaf822a906119e09086908690600401613825565b600060405180830381600087803b1580156119fa57600080fd5b505af1158015611a0e573d6000803e3d6000fd5b50505050505050565b6000611a2282610635565b905080156104fa576002546040516331a9108f60e11b8152600481018490526000916001600160a01b031690636352211e90602401602060405180830381865afa158015611a74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a989190613559565b60025460405163e3759abd60e01b81526001600160a01b0380841660048301526024820186905292935091169063e3759abd90604401600060405180830381600087803b158015611ae857600080fd5b505af1158015611afc573d6000803e3d6000fd5b5050600254604051631751d10160e21b8152600481018790526000935083925082916001600160a01b031690635d47440490602401606060405180830381865afa158015611b4e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b7291906134bb565b60025492955090935091506001600160a01b031663b3e4ee22878585611b988a8761380d565b6040516001600160e01b031960e087901b1681526004810194909452602484019290925260448301526064820152608401600060405180830381600087803b158015611be357600080fd5b505af1158015611bf7573d6000803e3d6000fd5b50506002546040516308b26d3b60e11b8152600481018a90526001600160a01b038881166024830152604482018a90529091169250631164da7691506064015b600060405180830381600087803b158015611c5157600080fd5b505af1158015611c65573d6000803e3d6000fd5b50505050505050505050565b60025460405163430c208160e01b8152336004820152602481018490526001600160a01b039091169063430c208190604401602060405180830381865afa158015611cc0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ce49190613499565b611d00576040516282b42960e81b815260040160405180910390fd5b611d098261239b565b8103611d13575050565b6000611d1e83611107565b905080156105d5576105d58383612323565b6001611d3c8133612006565b611d5b5780604051631e6fd6c360e21b81526004016104b49190613486565b60025460405163f7ea7a3d60e01b8152600481018490526001600160a01b039091169063f7ea7a3d9060240161091c565b6002611d988133612006565b611db75780604051631e6fd6c360e21b81526004016104b49190613486565b6000806000600260009054906101000a90046001600160a01b03166001600160a01b0316634d7c7dc76040518163ffffffff1660e01b8152600401606060405180830381865afa158015611e0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e3391906134bb565b919450925090506000611e468284613542565b60025460405163e3759abd60e01b81526001600160a01b0389811660048301526024820184905292935091169063e3759abd90604401600060405180830381600087803b158015611e9657600080fd5b505af1158015611eaa573d6000803e3d6000fd5b5050600254604051635701e25d60e01b81526001600160a01b038a81166004830152602482018690529091169250635701e25d9150604401600060405180830381600087803b158015611efc57600080fd5b505af1158015611f10573d6000803e3d6000fd5b5050600254604051630b07a84960e31b81526004810188905260248101879052604481018790526001600160a01b03909116925063583d42489150606401611c37565b60038054611f60906135ca565b80601f0160208091040260200160405190810160405280929190818152602001828054611f8c906135ca565b8015611fd95780601f10611fae57610100808354040283529160200191611fd9565b820191906000526020600020905b815481529060010190602001808311611fbc57829003601f168201915b505050505081565b611feb8484610a17565b611ff58483611c71565b61200084823361226c565b50505050565b6000816001600160a01b03166001600085600281111561202857612028613452565b600281111561203957612039613452565b81526020810191909152604001600020546001600160a01b0316149392505050565b60006001600084600281111561207357612073613452565b600281111561208457612084613452565b815260208101919091526040016000908120546001600160a01b0316915082906001908560028111156120b9576120b9613452565b60028111156120ca576120ca613452565b8152602081019190915260400160002080546001600160a01b0319166001600160a01b0392831617905582811690821684600281111561210c5761210c613452565b6040517f796d9fd27d307e851f66684ea6fe5e98600f0d922d136a5717ae5949892cfcf790600090a4505050565b600254604051631751d10160e21b815260048101839052600091829182916001600160a01b031690635d47440490602401606060405180830381865afa158015612188573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121ac91906134bb565b5091509150816000036121c3575060009392505050565b60025460405163e7d6fbbf60e01b81526000916001600160a01b03169063e7d6fbbf906121f4908490600401613486565b602060405180830381865afa158015612211573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061223591906134e9565b9050629896806122458343613542565b61224f838661383c565b612259919061383c565b612263919061352e565b95945050505050565b6002546040516303b1a1e960e31b81526004810185905283916001600160a01b031690631d8d0f4890602401602060405180830381865afa1580156122b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122d991906134e9565b036122e357505050565b6002546040516352f2cfd960e11b815260048101859052602481018490526001600160a01b0383811660448301529091169063a5e59fb2906064016119e0565b6002546040516331a9108f60e11b8152600481018490526104fa91849184916001600160a01b031690636352211e90602401602060405180830381865afa158015612372573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123969190613559565b612bcb565b600254604051631751d10160e21b81526004810183905260009182916001600160a01b0390911690635d47440490602401606060405180830381865afa1580156123e9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061240d91906134bb565b5090949350505050565b6000806000612425846115f2565b90925090508115612512576002546040516331a9108f60e11b8152600481018690526000916001600160a01b031690636352211e90602401602060405180830381865afa15801561247a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061249e9190613559565b600254604051631daa479b60e21b81529192506001600160a01b0316906376a91e6c906124d390849084908890600401613576565b600060405180830381600087803b1580156124ed57600080fd5b505af1158015612501573d6000803e3d6000fd5b5050505061251085828561251a565b505b159392505050565b60025460405163e7d6fbbf60e01b81526000916001600160a01b03169063e7d6fbbf9061254c90600190600401613486565b602060405180830381865afa158015612569573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061258d91906134e9565b9050600061271061259e838561383c565b6125a8919061352e565b90506000806000600260009054906101000a90046001600160a01b03166001600160a01b0316634d7c7dc76040518163ffffffff1660e01b8152600401606060405180830381865afa158015612602573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061262691906134bb565b60025492955090935091506001600160a01b031663583d42486126498689613542565b612653908661380d565b61265d878661380d565b6040516001600160e01b031960e085901b1681526004810192909252602482015260448101849052606401600060405180830381600087803b1580156126a257600080fd5b505af11580156126b6573d6000803e3d6000fd5b5050600254604051631751d10160e21b8152600481018c9052600093508392506001600160a01b0390911690635d47440490602401606060405180830381865afa158015612708573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061272c91906134bb565b6002546040516359f2771160e11b8152600481018f905260248101859052436044820152606481018390529395509093506001600160a01b03169163b3e4ee229150608401600060405180830381600087803b15801561278b57600080fd5b505af115801561279f573d6000803e3d6000fd5b5050600254604051632b2163b360e01b8152600481018e90526001600160a01b038d81166024830152604482018d90529091169250632b2163b39150606401600060405180830381600087803b1580156127f857600080fd5b505af115801561280c573d6000803e3d6000fd5b5050505050505050505050505050565b6060816000036128435750506040805180820190915260018152600360fc1b602082015290565b8160005b811561286d5780612857816137f4565b91506128669050600a8361352e565b9150612847565b60008167ffffffffffffffff81111561288857612888613075565b6040519080825280601f01601f1916602001820160405280156128b2576020820181803683370190505b5090505b84156107b4576128c7600183613542565b91506128d4600a8661385b565b6128df90603061380d565b60f81b8183815181106128f4576128f4613790565b60200101906001600160f81b031916908160001a905350612916600a8661352e565b94506128b6565b6060815160000361293c57505060408051602081019091526000815290565b60006040518060600160405280604081526020016138c7604091399050600060038451600261296b919061380d565b612975919061352e565b61298090600461383c565b67ffffffffffffffff81111561299857612998613075565b6040519080825280601f01601f1916602001820160405280156129c2576020820181803683370190505b509050600182016020820185865187015b80821015612a2e576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f81168501518453506001830192506129d3565b5050600386510660018114612a4a5760028114612a5d57612a65565b603d6001830353603d6002830353612a65565b603d60018303535b509195945050505050565b6060611188838360405180606001604052806027815260200161390760279139612e17565b612a9d612fb1565b600254604051631751d10160e21b8152600481018490526000916001600160a01b031690635d47440490602401606060405180830381865afa158015612ae7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b0b91906134bb565b509150506040518060c00160405280848152602001612b2985611892565b8152602001828152602001612b3d85610635565b8152602001612b4b8561150c565b6001600160a01b0390811682526002546040516303b1a1e960e31b815260048101889052602090930192911690631d8d0f4890602401602060405180830381865afa158015612b9e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bc291906134e9565b90529392505050565b6002546040805163e5a6b10f60e01b815290516000926001600160a01b03169163e5a6b10f9160048083019260209291908290030181865afa158015612c15573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c399190613559565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9a91906134e9565b905080831115612cc057604051630c3db3e760e01b8152600481018290526024016104b4565b600254604051631751d10160e21b8152600481018690526000916001600160a01b031690635d47440490602401606060405180830381865afa158015612d0a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d2e91906134bb565b6002546040516359f2771160e11b8152600481018a905260248101899052436044820152606481018390529194506001600160a01b0316925063b3e4ee229150608401600060405180830381600087803b158015612d8b57600080fd5b505af1158015612d9f573d6000803e3d6000fd5b505060025460405163d17d14c560e01b815260048101899052602481018890526001600160a01b038781166044830152909116925063d17d14c59150606401600060405180830381600087803b158015612df857600080fd5b505af1158015612e0c573d6000803e3d6000fd5b505050505050505050565b60606001600160a01b0384163b612e7f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016104b4565b600080856001600160a01b031685604051612e9a919061386f565b600060405180830381855af49150503d8060008114612ed5576040519150601f19603f3d011682016040523d82523d6000602084013e612eda565b606091505b5091509150612eea828286612ef4565b9695505050505050565b60608315612f03575081611188565b825115612f135782518084602001fd5b8160405162461bcd60e51b81526004016104b49190613221565b828054612f39906135ca565b90600052602060002090601f016020900481019282612f5b5760008555612fa1565b82601f10612f7457805160ff1916838001178555612fa1565b82800160010185558215612fa1579182015b82811115612fa1578251825591602001919060010190612f86565b50612fad929150612ff0565b5090565b6040518060c001604052806000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081525090565b5b80821115612fad5760008155600101612ff1565b60006020828403121561301757600080fd5b81356001600160e01b03198116811461118857600080fd5b6003811061303c57600080fd5b50565b60006020828403121561305157600080fd5b81356111888161302f565b60006020828403121561306e57600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561309d57600080fd5b813567ffffffffffffffff808211156130b557600080fd5b818401915084601f8301126130c957600080fd5b8135818111156130db576130db613075565b604051601f8201601f19908116603f0116810190838211818310171561310357613103613075565b8160405282815287602084870101111561311c57600080fd5b826020860160208301376000928101602001929092525095945050505050565b6001600160a01b038116811461303c57600080fd5b6000806040838503121561316457600080fd5b823561316f8161302f565b9150602083013561317f8161313c565b809150509250929050565b6000806040838503121561319d57600080fd5b50508035926020909101359150565b6000602082840312156131be57600080fd5b81356111888161313c565b60005b838110156131e45781810151838201526020016131cc565b838111156120005750506000910152565b6000815180845261320d8160208601602086016131c9565b601f01601f19169290920160200192915050565b60208152600061118860208301846131f5565b6000806020838503121561324757600080fd5b823567ffffffffffffffff8082111561325f57600080fd5b818501915085601f83011261327357600080fd5b81358181111561328257600080fd5b8660208260051b850101111561329757600080fd5b60209290920196919550909350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156132fe57603f198886030184526132ec8583516131f5565b945092850192908501906001016132d0565b5092979650505050505050565b805182526020808201519083015260408082015190830152606080820151908301526080808201516001600160a01b03169083015260a090810151910152565b60c08101610591828461330b565b60008060006060848603121561336e57600080fd5b83356133798161313c565b95602085013595506040909401359392505050565b600060808201868352602086818501528560408501526080606085015281855180845260a086019150828701935060005b818110156133e5576133d283865161330b565b9383019360c092909201916001016133bf565b50909998505050505050505050565b6000806040838503121561340757600080fd5b82356134128161302f565b946020939093013593505050565b6000806000806080858703121561343657600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052602160045260246000fd5b6003811061303c57634e487b7160e01b600052602160045260246000fd5b6020810161349383613468565b91905290565b6000602082840312156134ab57600080fd5b8151801515811461118857600080fd5b6000806000606084860312156134d057600080fd5b8351925060208401519150604084015190509250925092565b6000602082840312156134fb57600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60008261353d5761353d613502565b500490565b60008282101561355457613554613518565b500390565b60006020828403121561356b57600080fd5b81516111888161313c565b6001600160a01b039384168152919092166020820152604081019190915260600190565b67506c616e636b202360c01b8152600082516135bd8160088501602087016131c9565b9190910160080192915050565b600181811c908216806135de57607f821691505b6020821081036135fe57634e487b7160e01b600052602260045260246000fd5b50919050565b693d913730b6b2911d101160b11b81528351600090602061362b82600a8601838a016131c9565b72111610113232b9b1b934b83a34b7b7111d101160691b600a92850192830152855161365d81601d8501848a016131c9565b71222c202261747472696275746573223a205b60701b601d93909101928301526c2e96101134b6b0b3b2911d101160991b602f8301528454603c90600090600181811c90808316806136b057607f831692505b86831081036136cd57634e487b7160e01b85526022600452602485fd5b8080156136e157600181146136f657613727565b60ff1985168988015283890187019550613727565b60008c81526020902060005b8581101561371d5781548b82018a0152908401908901613702565b505086848a010195505b505050505061373e8161227d60f01b815260020190565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161378381601d8501602087016131c9565b91909101601d0192915050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e198436030181126137bd57600080fd5b83018035915067ffffffffffffffff8211156137d857600080fd5b6020019150368190038213156137ed57600080fd5b9250929050565b60006001820161380657613806613518565b5060010190565b6000821982111561382057613820613518565b500190565b6040810161383284613468565b9281526020015290565b600081600019048311821515161561385657613856613518565b500290565b60008261386a5761386a613502565b500690565b600082516138818184602087016131c9565b919091019291505056fe4f6e65206f662031206d696c6c696f6e20706978656c732074726164656420756e646572204861726265726765722054617820616e64205542492e4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a27b5328127473b4ebb1ea9b846a915174b67d56836996d96f2f53932f1a7aec64736f6c634300080d003360a06040523480156200001157600080fd5b506040516200299438038062002994833981016040819052620000349162000365565b8651879087906200004d906000906020850190620001f2565b50805162000063906001906020840190620001f2565b505050620000806200007a6200019c60201b60201c565b620001a0565b600b8590556001600160a01b0381166080526000808052600e60209081527fe710864318d4a32f37d6ce54cb3fadbef648dd12d8dbdf53973564d56b7f881c86905560408051878152905160008051602062002974833981519152929181900390910190a260016000819052600e60209081527fa7c5ba7114a813b50159add3a36832908dc83db71d0b9a24c2ad0f83be95820785905560408051868152905160008051602062002974833981519152929181900390910190a260026000819052600e60209081527f9adb202b1492743bc00c81d33cdc6423fa8c79109027eb6a845391e8fc1f048184905560408051858152905160008051602062002974833981519152929181900390910190a25050505050505062000452565b3390565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b828054620002009062000416565b90600052602060002090601f0160209004810192826200022457600085556200026f565b82601f106200023f57805160ff19168380011785556200026f565b828001600101855582156200026f579182015b828111156200026f57825182559160200191906001019062000252565b506200027d92915062000281565b5090565b5b808211156200027d576000815560010162000282565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620002c057600080fd5b81516001600160401b0380821115620002dd57620002dd62000298565b604051601f8301601f19908116603f0116810190828211818310171562000308576200030862000298565b816040528381526020925086838588010111156200032557600080fd5b600091505b838210156200034957858201830151818301840152908201906200032a565b838211156200035b5760008385830101525b9695505050505050565b600080600080600080600060e0888a0312156200038157600080fd5b87516001600160401b03808211156200039957600080fd5b620003a78b838c01620002ae565b985060208a0151915080821115620003be57600080fd5b50620003cd8a828b01620002ae565b96505060408801519450606088015193506080880151925060a0880151915060c088015160018060a01b03811681146200040657600080fd5b8091505092959891949750929550565b600181811c908216806200042b57607f821691505b6020821081036200044c57634e487b7160e01b600052602260045260246000fd5b50919050565b6080516124f86200047c6000396000818161053e01528181610dec015261121d01526124f86000f3fe608060405234801561001057600080fd5b50600436106102535760003560e01c80635d47440411610146578063b3e4ee22116100c3578063e5a6b10f11610087578063e5a6b10f14610539578063e7d6fbbf14610560578063e985e9c514610580578063ecaf822a146105bc578063f2fde38b146105cf578063f7ea7a3d146105e257600080fd5b8063b3e4ee22146104da578063b88d4fde146104ed578063c87b56dd14610500578063d17d14c514610513578063e3759abd1461052657600080fd5b8063864370071161010a57806386437007146104885780638da5cb5b1461049b57806395d89b41146104ac578063a22cb465146104b4578063a5e59fb2146104c757600080fd5b80635d474404146104185780636352211e1461044757806370a082311461045a578063715018a61461046d57806376a91e6c1461047557600080fd5b806340c10f19116101d45780634f558e79116101985780634f558e79146103b95780634f6ccce7146103cc5780635701e25d146103df578063583d4248146103f2578063585008841461040557600080fd5b806340c10f191461035357806342842e0e1461031a57806342966c6814610366578063430c2081146103795780634d7c7dc71461038c57600080fd5b806318160ddd1161021b57806318160ddd146102e85780631d8d0f48146102fa57806323b872dd1461031a5780632b2163b31461032d5780632f745c591461034057600080fd5b806301ffc9a71461025857806306fdde0314610280578063081812fc14610295578063095ea7b3146102c05780631164da76146102d5575b600080fd5b61026b610266366004611e7a565b6105f5565b60405190151581526020015b60405180910390f35b610288610620565b6040516102779190611eef565b6102a86102a3366004611f02565b6106b2565b6040516001600160a01b039091168152602001610277565b6102d36102ce366004611f37565b61074c565b005b6102d36102e3366004611f61565b610861565b600b545b604051908152602001610277565b6102ec610308366004611f02565b600d6020526000908152604090205481565b6102d3610328366004611f96565b6108d4565b6102d361033b366004611f61565b6108ef565b6102ec61034e366004611f37565b610955565b6102d3610361366004611f37565b6109eb565b6102d3610374366004611f02565b610a5f565b61026b610387366004611f37565b610a95565b600f5460105460115461039e92919083565b60408051938452602084019290925290820152606001610277565b61026b6103c7366004611f02565b610aa8565b6102ec6103da366004611f02565b610ac7565b6102d36103ed366004611f37565b610b5a565b6102d3610400366004611fc2565b610bcb565b6102d3610413366004611f96565b610c1b565b61039e610426366004611f02565b600c6020526000908152604090208054600182015460029092015490919083565b6102a8610455366004611f02565b610c60565b6102ec610468366004611fee565b610cd7565b6102d3610d5e565b6102d3610483366004611f96565b610d94565b6102d3610496366004612009565b610e5f565b600a546001600160a01b03166102a8565b610288610edd565b6102d36104c236600461205b565b610eec565b6102d36104d5366004612092565b610ef7565b6102d36104e83660046120c7565b610f6b565b6102d36104fb366004612168565b610fd0565b61028861050e366004611f02565b6110e1565b6102d3610521366004612092565b611167565b6102d3610534366004611f37565b6111cd565b6102a87f000000000000000000000000000000000000000000000000000000000000000081565b6102ec61056e366004612222565b600e6020526000908152604090205481565b61026b61058e36600461223d565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6102d36105ca366004612270565b61128a565b6102d36105dd366004611fee565b61132f565b6102d36105f0366004611f02565b6113c7565b60006001600160e01b0319821663780e9d6360e01b148061061a575061061a82611432565b92915050565b60606000805461062f9061228c565b80601f016020809104026020016040519081016040528092919081815260200182805461065b9061228c565b80156106a85780601f1061067d576101008083540402835291602001916106a8565b820191906000526020600020905b81548152906001019060200180831161068b57829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b03166107305760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061075782610c60565b9050806001600160a01b0316836001600160a01b0316036107c45760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610727565b336001600160a01b03821614806107e057506107e0813361058e565b6108525760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610727565b61085c8383611482565b505050565b600a546001600160a01b0316331461088b5760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b0316837fa760fe80056c46d089c37a35d9dbe762141a463ae0eb8235522d27ab9595286d836040516108c791815260200190565b60405180910390a3505050565b61085c83838360405180602001604052806000815250610fd0565b600a546001600160a01b031633146109195760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b0316837fc5790222911f43ca7d78c4f5ef5cb5a21d7fda4d923d433b80e7db9c295de88a836040516108c791815260200190565b600061096083610cd7565b82106109c25760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610727565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b600a546001600160a01b03163314610a155760405162461bcd60e51b8152600401610727906122c6565b600b54811180610a255750600181105b15610a5157600b5460405163168a450960e21b8152600160048201526024810191909152604401610727565b610a5b82826114f0565b5050565b600a546001600160a01b03163314610a895760405162461bcd60e51b8152600401610727906122c6565b610a928161150a565b50565b6000610aa183836115b1565b9392505050565b6000818152600260205260408120546001600160a01b0316151561061a565b6000610ad260085490565b8210610b355760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610727565b60088281548110610b4857610b486122fb565b90600052602060002001549050919050565b600a546001600160a01b03163314610b845760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b03167f782743bed566521eb169ba5186430a0e29079bfd1bdf4fc061bd63b48729846682604051610bbf91815260200190565b60405180910390a25050565b600a546001600160a01b03163314610bf55760405162461bcd60e51b8152600401610727906122c6565b604080516060810182528481526020810184905201819052600f92909255601055601155565b600a546001600160a01b03163314610c455760405162461bcd60e51b8152600401610727906122c6565b61085c838383604051806020016040528060008152506116a8565b6000818152600260205260408120546001600160a01b03168061061a5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610727565b60006001600160a01b038216610d425760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610727565b506001600160a01b031660009081526003602052604090205490565b600a546001600160a01b03163314610d885760405162461bcd60e51b8152600401610727906122c6565b610d9260006116db565b565b600a546001600160a01b03163314610dbe5760405162461bcd60e51b8152600401610727906122c6565b6040516323b872dd60e01b81526001600160a01b0384811660048301528381166024830152604482018390527f000000000000000000000000000000000000000000000000000000000000000016906323b872dd906064016020604051808303816000875af1158015610e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e599190612311565b50505050565b600a546001600160a01b03163314610e895760405162461bcd60e51b8152600401610727906122c6565b816001600160a01b0316836001600160a01b0316857fc12a40285e912bef139dd458d6bb29f54ba3b7bb9513d442a8c16a3f0a649eed84604051610ecf91815260200190565b60405180910390a450505050565b60606001805461062f9061228c565b610a5b33838361172d565b600a546001600160a01b03163314610f215760405162461bcd60e51b8152600401610727906122c6565b6000838152600d6020526040808220849055516001600160a01b03831691849186917f8da7074ffa2c919782faaf9705c7edfe7f814551a91b91aed83ee2ef5ac6af2791a4505050565b600a546001600160a01b03163314610f955760405162461bcd60e51b8152600401610727906122c6565b6040805160608101825293845260208085019384528482019283526000958652600c9052909320915182555160018201559051600290910155565b610fda33836115b1565b6110405760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610727565b6000611054600a546001600160a01b031690565b604051633f8c2b5b60e01b8152600481018590529091506000906001600160a01b03831690633f8c2b5b906024016020604051808303816000875af11580156110a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110c59190612311565b905080156110d9576110d9868686866116a8565b505050505050565b606060006110f7600a546001600160a01b031690565b60405163468bf38960e11b8152600481018590529091506001600160a01b03821690638d17e71290602401600060405180830381865afa15801561113f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610aa1919081019061232e565b600a546001600160a01b031633146111915760405162461bcd60e51b8152600401610727906122c6565b806001600160a01b0316837f75a0543aefc16d03b25751bdf0b5a2fbbec05c6436fd60b038d40f5b7d1def83846040516108c791815260200190565b600a546001600160a01b031633146111f75760405162461bcd60e51b8152600401610727906122c6565b60405163a9059cbb60e01b81526001600160a01b038381166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063a9059cbb906044016020604051808303816000875af1158015611266573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061085c9190612311565b600a546001600160a01b031633146112b45760405162461bcd60e51b8152600401610727906122c6565b80600e60008460028111156112cb576112cb6123a5565b60028111156112dc576112dc6123a5565b81526020810191909152604001600020558160028111156112ff576112ff6123a5565b6040518281527f90e64b63a2c952a97e60fcb9bdb464e5e76d2920683504331028687f0cd6643b90602001610bbf565b600a546001600160a01b031633146113595760405162461bcd60e51b8152600401610727906122c6565b6001600160a01b0381166113be5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610727565b610a92816116db565b600a546001600160a01b031633146113f15760405162461bcd60e51b8152600401610727906122c6565b600b5460408051918252602082018390527fce065be89501ad8aef77e0eb0160264c2d1eb1732a004bcb98735bb0b8102205910160405180910390a1600b55565b60006001600160e01b031982166380ac58cd60e01b148061146357506001600160e01b03198216635b5e139f60e01b145b8061061a57506301ffc9a760e01b6001600160e01b031983161461061a565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906114b782610c60565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610a5b8282604051806020016040528060008152506117f3565b600061151582610c60565b905061152381600084611826565b61152e600083611482565b6001600160a01b03811660009081526003602052604081208054600192906115579084906123d1565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000818152600260205260408120546001600160a01b031661162a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610727565b600061163583610c60565b9050806001600160a01b0316846001600160a01b031614806116705750836001600160a01b0316611665846106b2565b6001600160a01b0316145b806116a057506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b6116b38484846118de565b6116bf84848484611a85565b610e595760405162461bcd60e51b8152600401610727906123e8565b600a80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b03160361178e5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610727565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3191016108c7565b6117fd8383611b86565b61180a6000848484611a85565b61085c5760405162461bcd60e51b8152600401610727906123e8565b6001600160a01b0383166118815761187c81600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b6118a4565b816001600160a01b0316836001600160a01b0316146118a4576118a48382611cd4565b6001600160a01b0382166118bb5761085c81611d71565b826001600160a01b0316826001600160a01b03161461085c5761085c8282611e20565b826001600160a01b03166118f182610c60565b6001600160a01b0316146119555760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610727565b6001600160a01b0382166119b75760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610727565b6119c2838383611826565b6119cd600082611482565b6001600160a01b03831660009081526003602052604081208054600192906119f69084906123d1565b90915550506001600160a01b0382166000908152600360205260408120805460019290611a2490849061243a565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60006001600160a01b0384163b15611b7b57604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611ac9903390899088908890600401612452565b6020604051808303816000875af1925050508015611b04575060408051601f3d908101601f19168201909252611b019181019061248f565b60015b611b61573d808015611b32576040519150601f19603f3d011682016040523d82523d6000602084013e611b37565b606091505b508051600003611b595760405162461bcd60e51b8152600401610727906123e8565b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490506116a0565b506001949350505050565b6001600160a01b038216611bdc5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610727565b6000818152600260205260409020546001600160a01b031615611c415760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610727565b611c4d60008383611826565b6001600160a01b0382166000908152600360205260408120805460019290611c7690849061243a565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001611ce184610cd7565b611ceb91906123d1565b600083815260076020526040902054909150808214611d3e576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090611d83906001906123d1565b60008381526009602052604081205460088054939450909284908110611dab57611dab6122fb565b906000526020600020015490508060088381548110611dcc57611dcc6122fb565b6000918252602080832090910192909255828152600990915260408082208490558582528120556008805480611e0457611e046124ac565b6001900381819060005260206000200160009055905550505050565b6000611e2b83610cd7565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160e01b031981168114610a9257600080fd5b600060208284031215611e8c57600080fd5b8135610aa181611e64565b60005b83811015611eb2578181015183820152602001611e9a565b83811115610e595750506000910152565b60008151808452611edb816020860160208601611e97565b601f01601f19169290920160200192915050565b602081526000610aa16020830184611ec3565b600060208284031215611f1457600080fd5b5035919050565b80356001600160a01b0381168114611f3257600080fd5b919050565b60008060408385031215611f4a57600080fd5b611f5383611f1b565b946020939093013593505050565b600080600060608486031215611f7657600080fd5b83359250611f8660208501611f1b565b9150604084013590509250925092565b600080600060608486031215611fab57600080fd5b611fb484611f1b565b9250611f8660208501611f1b565b600080600060608486031215611fd757600080fd5b505081359360208301359350604090920135919050565b60006020828403121561200057600080fd5b610aa182611f1b565b6000806000806080858703121561201f57600080fd5b8435935061202f60208601611f1b565b925061203d60408601611f1b565b9396929550929360600135925050565b8015158114610a9257600080fd5b6000806040838503121561206e57600080fd5b61207783611f1b565b915060208301356120878161204d565b809150509250929050565b6000806000606084860312156120a757600080fd5b83359250602084013591506120be60408501611f1b565b90509250925092565b600080600080608085870312156120dd57600080fd5b5050823594602084013594506040840135936060013592509050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715612138576121386120f9565b604052919050565b600067ffffffffffffffff82111561215a5761215a6120f9565b50601f01601f191660200190565b6000806000806080858703121561217e57600080fd5b61218785611f1b565b935061219560208601611f1b565b925060408501359150606085013567ffffffffffffffff8111156121b857600080fd5b8501601f810187136121c957600080fd5b80356121dc6121d782612140565b61210f565b8181528860208385010111156121f157600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b803560038110611f3257600080fd5b60006020828403121561223457600080fd5b610aa182612213565b6000806040838503121561225057600080fd5b61225983611f1b565b915061226760208401611f1b565b90509250929050565b6000806040838503121561228357600080fd5b611f5383612213565b600181811c908216806122a057607f821691505b6020821081036122c057634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561232357600080fd5b8151610aa18161204d565b60006020828403121561234057600080fd5b815167ffffffffffffffff81111561235757600080fd5b8201601f8101841361236857600080fd5b80516123766121d782612140565b81815285602083850101111561238b57600080fd5b61239c826020830160208601611e97565b95945050505050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000828210156123e3576123e36123bb565b500390565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6000821982111561244d5761244d6123bb565b500190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061248590830184611ec3565b9695505050505050565b6000602082840312156124a157600080fd5b8151610aa181611e64565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220a4486a95fb302039e97091d89901e50103de8ad02f52ad032b2dd5f1a436dae864736f6c634300080d003390e64b63a2c952a97e60fcb9bdb464e5e76d2920683504331028687f0cd6643b000000000000000000000000264808855b0a6a5a318d238c6ee9f299179f27fc0000000000000000000000008da7a7a48ebbd870358f2fd824e52e5142f4425700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000edc934329433f7d151bb38c56e91fe5a8d4a2c600000000000000000000000001d52e2b5b74420d3633d8690a60bb3ea0345b58600000000000000000000000011c37333c6204ae05e5450d8a304d22ee4ba8de80000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d5645514a3257675a556b574b7a666b486d4576377638444654526878775a47444868776f69323348766e70620000000000000000000000

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

000000000000000000000000264808855b0a6a5a318d238c6ee9f299179f27fc0000000000000000000000008da7a7a48ebbd870358f2fd824e52e5142f4425700000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000edc934329433f7d151bb38c56e91fe5a8d4a2c600000000000000000000000001d52e2b5b74420d3633d8690a60bb3ea0345b58600000000000000000000000011c37333c6204ae05e5450d8a304d22ee4ba8de80000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d5645514a3257675a556b574b7a666b486d4576377638444654526878775a47444868776f69323348766e70620000000000000000000000

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

-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 000000000000000000000000264808855b0a6a5a318d238c6ee9f299179f27fc
Arg [1] : 0000000000000000000000008da7a7a48ebbd870358f2fd824e52e5142f44257
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000c0
Arg [3] : 000000000000000000000000edc934329433f7d151bb38c56e91fe5a8d4a2c60
Arg [4] : 0000000000000000000000001d52e2b5b74420d3633d8690a60bb3ea0345b586
Arg [5] : 00000000000000000000000011c37333c6204ae05e5450d8a304d22ee4ba8de8
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000035
Arg [7] : 697066733a2f2f516d5645514a3257675a556b574b7a666b486d457637763844
Arg [8] : 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.