Address Details
contract

0x1eC70826AfE92F6fa8441B513CDF9EDA59575faF

Contract Name
KolorLandToken
Creator
0xf600c2–fea2f2 at 0xb55c65–07b665
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
15 Transactions
Transfers
0 Transfers
Gas Used
1,855,681
Last Balance Update
11245989
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
KolorLandToken




Optimization enabled
true
Compiler version
v0.8.0+commit.c7dfd78e




Optimization runs
50
EVM Version
istanbul




Verified at
2022-04-30T17:31:40.087691Z

project:/contracts/KolorLandToken.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

import "./KolorLandNFT.sol";

struct LandTokensInfo {
    uint256 initialAmount;
    uint256 currentAmount;
    uint256 available;
    uint256 sold;
    uint256 creationDate;
    uint256 lastUpdate;
}

struct Investment {
    uint256 tokenId;
    address account;
    uint256 amount;
    uint256 tokenPrice;
    uint256 creationDate;
}

contract KolorLandToken is Ownable {
    // address of kolorLandNFT
    address public kolorLandNFT;
    address public marketplaceAddress;

    address private devAddress;

    // authorized addresses
    mapping(address => bool) public isAuthorized;

    // Investments by address
    mapping(address => mapping(uint256 => Investment))
        public investmentsByAddress;
    mapping(address => uint256) public totalInvestmentsByAddress;

    //Investments by land
    mapping(uint256 => mapping(uint256 => Investment)) public investmentsByLand;
    mapping(uint256 => uint256) public totalInvestmentsByLand;

    // total investments in this platform
    uint256 public totalInvestments;

    // info of each land
    mapping(uint256 => LandTokensInfo) public landTokensInfo;

    // checks if address owns a certain token
    mapping(uint256 => mapping(address => uint256)) public balances;

    // total holders of a given land token
    mapping(uint256 => uint256) public holders;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private operatorApprovals;

    constructor(address kolorNFTAddress, address _marketplaceAddress) {
        isAuthorized[msg.sender] = true;
        devAddress = msg.sender;
        kolorLandNFT = kolorNFTAddress;
        marketplaceAddress = _marketplaceAddress;

        setApprovalForAll(address(this), msg.sender, true);
    }

    modifier onlyAuthorized() {
        require(
            isAuthorized[msg.sender],
            "Kolor Land NFT: You're not allowed to do that!"
        );
        _;
    }

    modifier isOwnerOrApproved(address from) {
        require(
            from == msg.sender || operatorApprovals[from][msg.sender],
            "KolorLandToken: caller is not owner nor approved"
        );
        _;
    }

    function authorize(address operator) external onlyAuthorized {
        isAuthorized[operator] = true;
    }

    function setLandTokenInfo(uint256 tokenId, uint256 initialAmount)
        external
        onlyAuthorized
    {
        require(exists(tokenId), "KolorLandToken: land must exists!");

        landTokensInfo[tokenId].initialAmount = initialAmount;
        landTokensInfo[tokenId].currentAmount = initialAmount;
        landTokensInfo[tokenId].available = initialAmount;
        landTokensInfo[tokenId].sold = 0;
        landTokensInfo[tokenId].creationDate = block.timestamp;

        mint(address(this), tokenId, initialAmount);
    }

    function addNewTokens(uint256 tokenId, uint256 amount)
        external
        onlyAuthorized
    {
        require(exists(tokenId), "KolorLandToken: land must exists!");
        landTokensInfo[tokenId].currentAmount += amount;
        landTokensInfo[tokenId].available += amount;

        mint(address(this), tokenId, amount);
    }

    function mint(
        address to,
        uint256 tokenId,
        uint256 amount
    ) internal onlyAuthorized {
        require(exists(tokenId), "KolorLandToken: land must exists!");
        require(to != address(0), "KolorLandToken: mint to the zero address");

        balances[tokenId][to] += amount;
        landTokensInfo[tokenId].currentAmount += amount;
    }

    function newInvestment(
        address investor,
        uint256 tokenId,
        uint256 amount,
        uint256 tokenPrice
    ) public onlyAuthorized {
        require(exists(tokenId), "KolorLandToken: land must exists!");
        require(
            availableTokensOf(tokenId) - amount >= 0,
            "KolorLandToken: exceeds max amount"
        );

        require(isPublished(tokenId), "KolorLandToken: land not published yet");

        addInvestment(investor, tokenId, amount, tokenPrice);
        addInvestment(tokenId, investor, amount, tokenPrice);

        // increase number of holders
        if (balances[tokenId][investor] == 0) {
            holders[tokenId]++;
        }

        // set approval for dev or other operator
        if (!operatorApprovals[investor][devAddress]) {
            setApprovalForAll(investor, devAddress, true);
            setApprovalForAll(investor, address(this), true);
        }

        // updates balances and investments
        safeTransferFrom(address(this), investor, tokenId, amount);
        totalInvestmentsByAddress[investor]++;
        totalInvestmentsByLand[tokenId]++;
        totalInvestments++;

        landTokensInfo[tokenId].available -= amount;
        landTokensInfo[tokenId].sold += amount;
    }

    /* add investment on given account */
    function addInvestment(
        address investor,
        uint256 tokenId,
        uint256 amount,
        uint256 tokenPrice
    ) internal {
        uint256 _totalInvestmentsOf = totalInvestmentsOf(investor);

        // create a new investment object
        investmentsByAddress[investor][_totalInvestmentsOf].tokenId = tokenId;
        investmentsByAddress[investor][_totalInvestmentsOf].amount = amount;
        investmentsByAddress[investor][_totalInvestmentsOf]
            .tokenPrice = tokenPrice;
        investmentsByAddress[investor][_totalInvestmentsOf].creationDate = block
            .timestamp;
        investmentsByAddress[investor][_totalInvestmentsOf].account = investor;
    }

    /* add investment on given land */
    function addInvestment(
        uint256 tokenId,
        address investor,
        uint256 amount,
        uint256 tokenPrice
    ) internal {
        uint256 _totalInvestmentsOf = totalInvestmentsOf(tokenId);
        // create a new investment object
        investmentsByLand[tokenId][_totalInvestmentsOf].tokenId = tokenId;
        investmentsByLand[tokenId][_totalInvestmentsOf].amount = amount;
        investmentsByLand[tokenId][_totalInvestmentsOf].tokenPrice = tokenPrice;
        investmentsByLand[tokenId][_totalInvestmentsOf].creationDate = block
            .timestamp;
        investmentsByLand[tokenId][_totalInvestmentsOf].account = investor;
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        uint256 amount
    ) public isOwnerOrApproved(from) {
        require(
            to != address(0),
            "KolorLandToken: transfer to the zero address"
        );

        uint256 fromBalance = balances[tokenId][from];
        require(
            fromBalance >= amount,
            "ERC1155: insufficient balance for transfer"
        );
        unchecked {
            balances[tokenId][from] = fromBalance - amount;
            if (balances[tokenId][from] == 0) {
                holders[tokenId]--;
            }
        }

        balances[tokenId][to] += amount;

        //emit TransferSingle(operator, from, to, id, amount);
    }

    function setKolorLandAddress(address newAddress) public onlyAuthorized {
        kolorLandNFT = newAddress;
    }

    function setMarketplaceAddress(address newAddress) public onlyAuthorized {
        marketplaceAddress = newAddress;
    }

    function totalInvestmentsOf(address account) public view returns (uint256) {
        return totalInvestmentsByAddress[account];
    }

    function totalInvestmentsOf(uint256 tokenId) public view returns (uint256) {
        return totalInvestmentsByLand[tokenId];
    }

    function availableTokensOf(uint256 tokenId) public view returns (uint256) {
        return landTokensInfo[tokenId].available;
    }

    function soldTokensOf(uint256 tokenId) public view returns (uint256) {
        return landTokensInfo[tokenId].sold;
    }

    function balanceOf(address account, uint256 tokenId)
        public
        view
        returns (uint256)
    {
        require(
            account != address(0),
            "KolorLandToken: balance query for the zero address"
        );

        return balances[tokenId][account];
    }

    function balancesOf(address account, uint256[] memory tokenIds)
        public
        view
        returns (uint256[] memory)
    {
        require(
            account != address(0),
            "KolorLandToken: balance query for the zero address"
        );

        uint256[] memory _balances = new uint256[](tokenIds.length);

        for (uint256 i = 0; i < tokenIds.length; i++) {
            _balances[i] = balanceOf(account, tokenIds[i]);
        }

        return _balances;
    }

    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        returns (uint256[] memory)
    {
        require(
            accounts.length == ids.length,
            "KolorLandToken: accounts and ids length mismatch"
        );

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /* Return all investments made by an address */
    function investmentsOf(address account)
        public
        view
        returns (Investment[] memory)
    {
        uint256 _totalInvestmentsOf = totalInvestmentsOf(account);

        Investment[] memory investments = new Investment[](_totalInvestmentsOf);

        for (uint256 i = 0; i < _totalInvestmentsOf; i++) {
            investments[i] = investmentOf(account, i);
        }

        return investments;
    }

    /* Return all investments made on a certain land */
    function investmentsOf(uint256 tokenId)
        public
        view
        returns (Investment[] memory)
    {
        uint256 _totalInvestmentsOf = totalInvestmentsOf(tokenId);

        Investment[] memory investments = new Investment[](_totalInvestmentsOf);

        for (uint256 i = 0; i < _totalInvestmentsOf; i++) {
            investments[i] = investmentOf(tokenId, i);
        }

        return investments;
    }

    function investmentOf(address account, uint256 index)
        public
        view
        returns (Investment memory)
    {
        return investmentsByAddress[account][index];
    }

    function investmentOf(uint256 tokenId, uint256 index)
        public
        view
        returns (Investment memory)
    {
        return investmentsByLand[tokenId][index];
    }

    function exists(uint256 tokenId) internal view returns (bool) {
        ERC721 kolorNFT = ERC721(kolorLandNFT);

        return kolorNFT.ownerOf(tokenId) != address(0);
    }

    function isPublished(uint256 tokenId) internal view returns (bool) {
        KolorLandNFT kolorLand = KolorLandNFT(kolorLandNFT);

        return kolorLand.isPublished(tokenId);
    }

    function getLandTokenBalance(uint256 tokenId)
        public
        view
        returns (uint256)
    {
        return balanceOf(address(this), tokenId);
    }

    function getLandTokenBalances(uint256[] memory tokenIds)
        public
        view
        returns (uint256[] memory)
    {
        return balancesOf(address(this), tokenIds);
    }

    /**
     * @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, "ERC1155: setting approval status for self");
        operatorApprovals[owner][operator] = approved;
        //emit ApprovalForAll(owner, operator, approved);
    }

    function setDevAddress(address operator) public onlyAuthorized {
        devAddress = operator;
    }
}
        

/_openzeppelin/contracts/access/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);
    }
}
          

/_openzeppelin/contracts/security/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;
    }
}
          

/_openzeppelin/contracts/token/ERC721/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);
    }

    /**
     * @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);
    }

    /**
     * @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 of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

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

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

        emit Transfer(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 {}
}
          

/_openzeppelin/contracts/token/ERC721/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;
}
          

/_openzeppelin/contracts/token/ERC721/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);
}
          

/_openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Burnable.sol)

pragma solidity ^0.8.0;

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

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

/_openzeppelin/contracts/token/ERC721/extensions/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();
    }
}
          

/_openzeppelin/contracts/token/ERC721/extensions/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 tokenId);

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

/_openzeppelin/contracts/token/ERC721/extensions/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);
}
          

/_openzeppelin/contracts/utils/Address.sol

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

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

/_openzeppelin/contracts/utils/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;
    }
}
          

/_openzeppelin/contracts/utils/Counters.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

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

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}
          

/_openzeppelin/contracts/utils/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);
    }
}
          

/_openzeppelin/contracts/utils/introspection/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;
    }
}
          

/_openzeppelin/contracts/utils/introspection/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);
}
          

/project_/contracts/IKolorLandNFT.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

enum State {
    Created,
    Paused,
    Removed,
    Published
}

interface IKolorLandNFT {
    /**
        @dev Updates the availibility of tokenized land to be
        purchased in a marketplace
    
     */
    function updateLandState(uint256 tokenId, State state) external;

    function updateLandOwner(
        uint256 tokenId,
        address newLandOwner,
        string memory name
    ) external;

    function addBuyer(uint256 tokenId, address newBuyer) external;

    function updateName(uint256 tokenId, string memory name) external;

    function landOwnerOf(uint256 tokenId)
        external
        view
        returns (address landOwner);

    function isBuyerOf(uint256 tokenId, address buyer)
        external
        view
        returns (bool);

    function initialTCO2Of(uint256 tokenId)
        external
        view
        returns (uint256 initialTCO2);

    function stateOf(uint256 tokenId) external view returns (State state);

    function safeTransferToMarketplace(address from, uint256 tokenId) external;

    function getVCUSLeft(uint256 tokenId) external view returns (uint256 vcus);
}
          

/project_/contracts/KolorLandNFT.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "./IKolorLandNFT.sol";

struct GeoSpatialPoint {
    int256 latitude;
    int256 longitude;
    uint256 decimals;
    uint256 creationDate;
    uint256 updateDate;
}

struct Species {
    string speciesAlias;
    string scientificName;
    uint256 density;
    uint256 size;
    uint256 decimals;
    uint256 TCO2perSecond;
    uint256 TCO2perYear;
    uint256 landId;
    uint256 creationDate;
    uint256 updateDate;
}

struct NFTInfo {
    string name;
    string identifier;
    address landOwner;
    string landOwnerAlias;
    uint256 decimals;
    uint256 size;
    string country;
    string stateOrRegion;
    string city;
    State state;
    uint256 initialTCO2perYear;
    uint256 soldTCO2;
    uint256 creationDate;
}

contract KolorLandNFT is
    ERC721,
    ERC721Enumerable,
    ERC721Burnable,
    Ownable,
    IKolorLandNFT
{
    using Counters for Counters.Counter;

    Counters.Counter private _tokenIdCounter;
    address public marketplace;

    constructor() ERC721("Kolor Land NFT", "KLand") {
        isAuthorized[msg.sender] = true;
    }

    string public baseURI;

    // NFT info
    mapping(uint256 => NFTInfo) private mintedNFTSInfo;

    // Owned lands to use in enumeration
    mapping(address => mapping(uint256 => uint256)) private ownedLands;
    mapping(uint256 => uint256) private landIndex;
    mapping(address => uint256) private _totalLandOwned;

    // mapping to get buyers of a land
    mapping(uint256 => mapping(address => bool)) public buyers;
    mapping(uint256 => uint256) public totalBuyers;

    // mappings of conflictive data such as species and location
    mapping(uint256 => mapping(uint256 => Species)) public species;
    mapping(uint256 => uint256) public totalSpecies;

    mapping(uint256 => mapping(uint256 => GeoSpatialPoint)) public points;
    mapping(uint256 => uint256) public totalPoints;

    mapping(address => bool) public isAuthorized;

    function safeMint(
        address to,
        string memory name,
        string memory identifier,
        address landOwner,
        string memory landOwnerAlias,
        uint256 decimals,
        uint256 size,
        string memory country,
        string memory stateOrRegion,
        string memory city,
        uint256 initialTCO2
    ) public onlyAuthorized {
        uint256 currentTokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, currentTokenId);

        // Set all NFT information
        mintedNFTSInfo[currentTokenId].name = name;
        mintedNFTSInfo[currentTokenId].identifier = identifier;
        mintedNFTSInfo[currentTokenId].landOwner = landOwner;
        mintedNFTSInfo[currentTokenId].landOwnerAlias = landOwnerAlias;
        mintedNFTSInfo[currentTokenId].decimals = decimals;
        mintedNFTSInfo[currentTokenId].size = size;
        mintedNFTSInfo[currentTokenId].country = country;
        mintedNFTSInfo[currentTokenId].stateOrRegion = stateOrRegion;
        mintedNFTSInfo[currentTokenId].city = city;
        mintedNFTSInfo[currentTokenId].initialTCO2perYear = initialTCO2;
        mintedNFTSInfo[currentTokenId].creationDate = block.timestamp;
        mintedNFTSInfo[currentTokenId].state = State.Created;

        uint256 _landsOwned = _totalLandOwned[landOwner];
        // set the tokenId to current landowner collection index
        ownedLands[to][_landsOwned] = currentTokenId;

        // update the tokenId index in landowner collection
        landIndex[currentTokenId] = _landsOwned;

        // increase total lands owned by address
        _totalLandOwned[to]++;
    }

    function authorize(address manager) public onlyOwner {
        isAuthorized[manager] = !isAuthorized[manager];
    }

    function setMarketplace(address _marketplace) public onlyAuthorized {
        marketplace = _marketplace;
        isAuthorized[marketplace] = true;
    }

    modifier onlyMarketplace() {
        require(
            marketplace == msg.sender,
            "Kolor Land NFT: You're not allowed to do that!"
        );
        _;
    }

    modifier onlyAuthorized() {
        require(
            isAuthorized[msg.sender],
            "Kolor Land NFT: You're not allowed to do that!"
        );
        _;
    }

    modifier notBurned(uint256 tokenId) {
        require(_exists(tokenId), "ERC721Metadata: operation on burned token!");
        _;
    }

    modifier notPublishedNorRemoved(uint256 tokenId) {
        require(
            !isRemoved(tokenId) && !isPublished(tokenId),
            "Kolor Land NFT:  This land can't be transfered to Marketplace"
        );
        _;
    }

    function isLandOwner(address landOwner, uint256 tokenId)
        internal
        view
        returns (bool)
    {
        return mintedNFTSInfo[tokenId].landOwner == landOwner;
    }

    function isRemoved(uint256 tokenId) public view returns (bool) {
        return mintedNFTSInfo[tokenId].state == State.Removed;
    }

    function isPublished(uint256 tokenId) public view returns (bool) {
        return mintedNFTSInfo[tokenId].state == State.Published;
    }

    /**
        @dev Override of functions defined on interface ILandNFT
    
     */
    function updateLandState(uint256 tokenId, State _state)
        public
        override
        notBurned(tokenId)
        onlyAuthorized
    {
        require(_state != State.Created, "Kolor Land NFT: Invalid State");
        mintedNFTSInfo[tokenId].state = _state;
    }

    function updateLandOwner(
        uint256 tokenId,
        address newLandOwner,
        string memory name
    ) public override onlyAuthorized notBurned(tokenId) {
        mintedNFTSInfo[tokenId].landOwner = newLandOwner;
        mintedNFTSInfo[tokenId].landOwnerAlias = name;
    }

    /**  
        @dev adds a new buyer to this land 
    */
    function addBuyer(uint256 tokenId, address newBuyer)
        public
        override
        onlyMarketplace
        notBurned(tokenId)
    {
        buyers[tokenId][newBuyer] = true;
        totalBuyers[tokenId]++;
    }

    function updateName(uint256 tokenId, string memory newName)
        public
        override
        onlyAuthorized
        notBurned(tokenId)
    {
        mintedNFTSInfo[tokenId].name = newName;
    }

    function landOwnerOf(uint256 tokenId)
        public
        view
        override
        returns (address)
    {
        address landOwner = mintedNFTSInfo[tokenId].landOwner;

        return landOwner;
    }

    function isBuyerOf(uint256 tokenId, address buyer)
        public
        view
        override
        returns (bool)
    {
        return buyers[tokenId][buyer];
    }

    function initialTCO2Of(uint256 tokenId)
        public
        view
        override
        returns (uint256)
    {
        return mintedNFTSInfo[tokenId].initialTCO2perYear;
    }

    function stateOf(uint256 tokenId) public view override returns (State) {
        return mintedNFTSInfo[tokenId].state;
    }

    /**
        @dev transfers the token to the marketplace and marks it
        as published for buyers to invest

     */
    function safeTransferToMarketplace(address from, uint256 tokenId)
        public
        override
        notBurned(tokenId)
        onlyAuthorized
        notPublishedNorRemoved(tokenId)
    {
        // Transfer to the marketplace
        updateLandState(tokenId, State.Published);
        safeTransferFrom(from, marketplace, tokenId);
    }

    function getNFTInfo(uint256 tokenId) public view returns (NFTInfo memory) {
        return mintedNFTSInfo[tokenId];
    }

    function landOfOwnerByIndex(address landOwner, uint256 index)
        public
        view
        returns (uint256)
    {
        require(
            index < balanceOf(landOwner) + 1,
            "landowner index out of bounds"
        );

        return ownedLands[landOwner][index];
    }

    function totalLandOwnedOf(address landOwner) public view returns (uint256) {
        return _totalLandOwned[landOwner];
    }

    function totalSpeciesOf(uint256 tokenId) public view returns (uint256) {
        return totalSpecies[tokenId];
    }

    function totalPointsOf(uint256 tokenId) public view returns (uint256) {
        return totalPoints[tokenId];
    }

    /** @dev set all species of a certain land */
    function setSpecies(uint256 tokenId, Species[] memory _species)
        public
        onlyAuthorized
        notBurned(tokenId)
    {
        require(
            totalSpeciesOf(tokenId) == 0,
            "Kolor Land NFT: Species of this land already been set"
        );
        uint256 _totalSpecies = _species.length;
        for (uint256 i = 0; i < _totalSpecies; i++) {
            species[tokenId][i].speciesAlias = _species[i].speciesAlias;
            species[tokenId][i].scientificName = _species[i].scientificName;
            species[tokenId][i].density = _species[i].density;
            species[tokenId][i].size = _species[i].size;
            species[tokenId][i].decimals = _species[i].decimals;
            species[tokenId][i].TCO2perSecond = _species[i].TCO2perSecond;
            species[tokenId][i].TCO2perYear = _species[i].TCO2perYear;
            species[tokenId][i].landId = tokenId;
            species[tokenId][i].creationDate = block.timestamp;
        }

        totalSpecies[tokenId] = _totalSpecies;
    }

    function addSpecies(uint256 tokenId, Species memory _species)
        public
        onlyAuthorized
        notBurned(tokenId)
    {
        uint256 _totalSpecies = totalSpeciesOf(tokenId);
        species[tokenId][_totalSpecies].speciesAlias = _species.speciesAlias;
        species[tokenId][_totalSpecies].scientificName = _species
            .scientificName;
        species[tokenId][_totalSpecies].density = _species.density;
        species[tokenId][_totalSpecies].size = _species.size;
        species[tokenId][_totalSpecies].decimals = _species.decimals;
        species[tokenId][_totalSpecies].TCO2perYear = _species.TCO2perYear;
        species[tokenId][_totalSpecies].landId = tokenId;
        species[tokenId][_totalSpecies].creationDate = block.timestamp;
        species[tokenId][_totalSpecies].TCO2perSecond = _species.TCO2perSecond;

        totalSpecies[tokenId]++;
    }

    function updateSpecies(
        uint256 tokenId,
        uint256 speciesIndex,
        Species memory _species
    ) public onlyAuthorized notBurned(tokenId) {
        require(
            validSpecie(speciesIndex, tokenId),
            "Kolor Land NFT: Invalid specie to update"
        );

        species[tokenId][speciesIndex].speciesAlias = _species.speciesAlias;
        species[tokenId][speciesIndex].scientificName = _species.scientificName;
        species[tokenId][speciesIndex].density = _species.density;
        species[tokenId][speciesIndex].size = _species.size;
        species[tokenId][speciesIndex].TCO2perYear = _species.TCO2perYear;
        species[tokenId][speciesIndex].landId = tokenId;
        species[tokenId][speciesIndex].updateDate = block.timestamp;
        species[tokenId][speciesIndex].TCO2perSecond = _species.TCO2perSecond;
    }

    function setPoints(uint256 tokenId, GeoSpatialPoint[] memory _points)
        public
        onlyAuthorized
        notBurned(tokenId)
    {
        require(
            totalPointsOf(tokenId) == 0,
            "Kolor Land NFT: Geospatial points of this land already been set"
        );
        uint256 _totalPoints = _points.length;

        for (uint256 i = 0; i < _totalPoints; i++) {
            points[tokenId][i].latitude = _points[i].latitude;
            points[tokenId][i].longitude = _points[i].longitude;
            points[tokenId][i].decimals = _points[i].decimals;
            points[tokenId][i].creationDate = block.timestamp;

            totalPoints[tokenId]++;
        }
    }

    function addPoint(uint256 tokenId, GeoSpatialPoint memory point)
        public
        onlyAuthorized
        notBurned(tokenId)
    {
        uint256 _totalPoints = totalPoints[tokenId];

        points[tokenId][_totalPoints].latitude = point.latitude;
        points[tokenId][_totalPoints].longitude = point.longitude;
        points[tokenId][_totalPoints].decimals = point.decimals;

        totalPoints[tokenId]++;
    }

    function updatePoint(
        uint256 tokenId,
        uint256 pointIndex,
        GeoSpatialPoint memory point
    ) public onlyAuthorized notBurned(tokenId) {
        require(
            validPoint(pointIndex, tokenId),
            "Kolor Land NFT: Invalid point to update"
        );

        points[tokenId][pointIndex].latitude = point.latitude;
        points[tokenId][pointIndex].longitude = point.longitude;
        points[tokenId][pointIndex].decimals = point.decimals;
    }

    function validSpecie(uint256 specieIndex, uint256 tokenId)
        internal
        view
        returns (bool)
    {
        if (specieIndex >= 0 && specieIndex < totalSpeciesOf(tokenId)) {
            return true;
        }

        return false;
    }

    function validPoint(uint256 pointIndex, uint256 tokenId)
        internal
        view
        returns (bool)
    {
        if (pointIndex >= 0 && pointIndex < totalPointsOf(tokenId)) {
            return true;
        }

        return false;
    }

    function offsetEmissions(uint256 tokenId, uint256 amount)
        public
        onlyMarketplace
        notBurned(tokenId)
    {
        mintedNFTSInfo[tokenId].soldTCO2 += amount;
    }

    function totalVCUBySpecies(uint256 tokenId, uint256 index)
        public
        view
        returns (uint256)
    {
        // Get the seconds elapsed until now
        uint256 speciesCreationDate = species[tokenId][index].creationDate;

        uint256 secondsElapsed = timestampDifference(
            speciesCreationDate,
            block.timestamp
        );

        // now we get the total vcus emitted until now
        return secondsElapsed * species[tokenId][index].TCO2perSecond;
    }

    function totalVCUSEmitedBy(uint256 tokenId) public view returns (uint256) {
        // Get total species of a land
        uint256 _totalSpecies = totalSpeciesOf(tokenId);

        uint256 totalVCUSEmitted = 0;
        // Iterate over all species and calculate its total vcu
        for (uint256 i = 0; i < _totalSpecies; i++) {
            uint256 currentVCUSEmitted = totalVCUBySpecies(tokenId, i);
            totalVCUSEmitted += currentVCUSEmitted;
        }

        return totalVCUSEmitted;
    }

    /**
        @dev returns vcus emitted from this land that are available
        for sale
    
     */
    function getVCUSLeft(uint256 tokenId)
        public
        view
        override
        returns (uint256)
    {
        // Get the ideal vcutokens from creation date until now
        uint256 totalVCUSEmited = totalVCUSEmitedBy(tokenId);

        // get the difference between the ideal minus the sold TCO2
        return totalVCUSEmited - mintedNFTSInfo[tokenId].soldTCO2;
    }

    function timestampDifference(uint256 timestamp1, uint256 timestamp2)
        public
        pure
        returns (uint256)
    {
        return timestamp2 - timestamp1;
    }

    function setBaseURI(string memory _baseURI) public onlyOwner {
        baseURI = _baseURI;
    }

    function tokenURI(uint256 tokenId)
        public
        view
        override
        returns (string memory)
    {
        require(
            _exists(tokenId),
            "ERC721Metadata: URI query for nonexistent token"
        );

        return
            string(
                abi.encodePacked(baseURI, mintedNFTSInfo[tokenId].identifier)
            );
    }

    // The following functions are overrides required by Solidity.
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal override(ERC721, ERC721Enumerable) {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721, ERC721Enumerable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"kolorNFTAddress","internalType":"address"},{"type":"address","name":"_marketplaceAddress","internalType":"address"}]},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addNewTokens","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"authorize","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"availableTokensOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"balanceOfBatch","inputs":[{"type":"address[]","name":"accounts","internalType":"address[]"},{"type":"uint256[]","name":"ids","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balances","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"balancesOf","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getLandTokenBalance","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getLandTokenBalances","inputs":[{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"holders","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Investment","components":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenPrice","internalType":"uint256"},{"type":"uint256","name":"creationDate","internalType":"uint256"}]}],"name":"investmentOf","inputs":[{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"","internalType":"struct Investment","components":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenPrice","internalType":"uint256"},{"type":"uint256","name":"creationDate","internalType":"uint256"}]}],"name":"investmentOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenPrice","internalType":"uint256"},{"type":"uint256","name":"creationDate","internalType":"uint256"}],"name":"investmentsByAddress","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenPrice","internalType":"uint256"},{"type":"uint256","name":"creationDate","internalType":"uint256"}],"name":"investmentsByLand","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct Investment[]","components":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenPrice","internalType":"uint256"},{"type":"uint256","name":"creationDate","internalType":"uint256"}]}],"name":"investmentsOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct Investment[]","components":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"account","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenPrice","internalType":"uint256"},{"type":"uint256","name":"creationDate","internalType":"uint256"}]}],"name":"investmentsOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isAuthorized","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"kolorLandNFT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"initialAmount","internalType":"uint256"},{"type":"uint256","name":"currentAmount","internalType":"uint256"},{"type":"uint256","name":"available","internalType":"uint256"},{"type":"uint256","name":"sold","internalType":"uint256"},{"type":"uint256","name":"creationDate","internalType":"uint256"},{"type":"uint256","name":"lastUpdate","internalType":"uint256"}],"name":"landTokensInfo","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"marketplaceAddress","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"newInvestment","inputs":[{"type":"address","name":"investor","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"tokenPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setDevAddress","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setKolorLandAddress","inputs":[{"type":"address","name":"newAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setLandTokenInfo","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"initialAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMarketplaceAddress","inputs":[{"type":"address","name":"newAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"soldTokensOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalInvestments","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalInvestmentsByAddress","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalInvestmentsByLand","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalInvestmentsOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalInvestmentsOf","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b50604051620020c9380380620020c983398101604081905262000034916200019b565b6200004862000042620000b2565b620000b6565b3360008181526004602052604090208054600160ff199091168117909155600380546001600160a01b03199081168417909155815481166001600160a01b0386811691909117835560028054909216908516179055620000aa91309162000106565b50506200021b565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b816001600160a01b0316836001600160a01b03161415620001445760405162461bcd60e51b81526004016200013b90620001d2565b60405180910390fd5b6001600160a01b039283166000908152600d6020908152604080832094909516825292909252919020805460ff1916911515919091179055565b80516001600160a01b03811681146200019657600080fd5b919050565b60008060408385031215620001ae578182fd5b620001b9836200017e565b9150620001c9602084016200017e565b90509250929050565b60208082526029908201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604082015268103337b91039b2b63360b91b606082015260800190565b611e9e806200022b6000396000f3fe608060405234801561001057600080fd5b50600436106101d05760003560e01c80637a93f79111610105578063c17630c71161009d578063c17630c7146103f4578063d0d41fe114610407578063d42532e71461041a578063da9bcb121461043f578063daa17f4914610452578063efddc7621461045a578063f2fde38b1461046d578063fb0f63df14610480578063fe9fbb8014610493576101d0565b80637a93f791146103545780638da5cb5b146103675780638e5a3c901461036f578063905dfba31461038257806398dc34e4146103955780639c35ea0a146103a8578063b47cc556146103bb578063b6a5d7de146103ce578063bd795914146103e1576101d0565b806333cd33831161017857806333cd3383146102965780633e0d7ac3146102b65780634dff48e5146102d65780634e1273f4146102e95780634faf5aac146102fc57806360e743dc1461031c57806370fd37cf1461032f578063715018a61461033757806375fa950a1461033f576101d0565b8062fdd58e146101d557806301aff5b0146101fe5780630570677c146102115780630febdd49146102355780631f3203311461024a57806323a241911461025d57806325f64d7c146102705780632a11ced014610283575b600080fd5b6101e86101e33660046116c4565b6104b3565b6040516101f59190611d34565b60405180910390f35b6101e861020c366004611838565b61050f565b61022461021f36600461187f565b610521565b6040516101f5959493929190611d3d565b610248610243366004611632565b610565565b005b6101e8610258366004611850565b6106a8565b61024861026b36600461187f565b6106c5565b61024861027e36600461187f565b610756565b6101e8610291366004611838565b610802565b6102a96102a43660046115fa565b610814565b6040516101f591906118ea565b6102c96102c4366004611677565b6108e2565b6040516101f59190611938565b6101e86102e4366004611838565b6109d9565b6102c96102f7366004611729565b6109e5565b61030f61030a3660046116c4565b610aef565b6040516101f59190611d26565b6101e861032a366004611838565b610b5b565b6101e8610b6d565b610248610b73565b610347610bbe565b6040516101f591906118d6565b6101e8610362366004611838565b610bcd565b610347610be2565b6102a961037d366004611838565b610bf1565b6102246103903660046116c4565b610cb7565b6101e86103a33660046115fa565b610cfb565b6102c96103b63660046117de565b610d0d565b6102486103c93660046115fa565b610d19565b6102486103dc3660046115fa565b610d6a565b6101e86103ef3660046115fa565b610dbd565b6101e8610402366004611838565b610dd8565b6102486104153660046115fa565b610ded565b61042d610428366004611838565b610e3e565b6040516101f596959493929190611d69565b61024861044d3660046115fa565b610e73565b610347610ec4565b6102486104683660046116ef565b610ed3565b61024861047b3660046115fa565b6110ef565b61030f61048e36600461187f565b611160565b6104a66104a13660046115fa565b6111c7565b6040516101f59190611970565b60006001600160a01b0383166104e45760405162461bcd60e51b81526004016104db90611bf5565b60405180910390fd5b506000818152600b602090815260408083206001600160a01b03861684529091529020545b92915050565b60009081526008602052604090205490565b60076020908152600092835260408084209091529082529020805460018201546002830154600384015460049094015492936001600160a01b039092169290919085565b836001600160a01b0381163314806105a057506001600160a01b0381166000908152600d6020908152604080832033845290915290205460ff165b6105bc5760405162461bcd60e51b81526004016104db90611c90565b6001600160a01b0384166105e25760405162461bcd60e51b81526004016104db90611ae9565b6000838152600b602090815260408083206001600160a01b0389168452909152902054828110156106255760405162461bcd60e51b81526004016104db90611b35565b6000848152600b602090815260408083206001600160a01b038a168452909152902083820390819055610669576000848152600c6020526040902080546000190190555b6000848152600b602090815260408083206001600160a01b03891684529091528120805485929061069b908490611ddd565b9091555050505050505050565b600b60209081526000928352604080842090915290825290205481565b3360009081526004602052604090205460ff166106f45760405162461bcd60e51b81526004016104db906119bd565b6106fd826111dc565b6107195760405162461bcd60e51b81526004016104db90611bb4565b6000828152600a602052604081208281556001810183905560028101839055600381019190915542600490910155610752308383611273565b5050565b3360009081526004602052604090205460ff166107855760405162461bcd60e51b81526004016104db906119bd565b61078e826111dc565b6107aa5760405162461bcd60e51b81526004016104db90611bb4565b6000828152600a6020526040812060010180548392906107cb908490611ddd565b90915550506000828152600a6020526040812060020180548392906107f1908490611ddd565b909155506107529050308383611273565b600c6020526000908152604090205481565b6060600061082183610dbd565b90506000816001600160401b0381111561084b57634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561088457816020015b610871611556565b8152602001906001900390816108695790505b50905060005b828110156108da5761089c8582610aef565b8282815181106108bc57634e487b7160e01b600052603260045260246000fd5b602002602001018190525080806108d290611e0c565b91505061088a565b509392505050565b60606001600160a01b03831661090a5760405162461bcd60e51b81526004016104db90611bf5565b600082516001600160401b0381111561093357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561095c578160200160208202803683370190505b50905060005b83518110156108da5761099c8585838151811061098f57634e487b7160e01b600052603260045260246000fd5b60200260200101516104b3565b8282815181106109bc57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806109d181611e0c565b915050610962565b600061050930836104b3565b60608151835114610a085760405162461bcd60e51b81526004016104db90611a51565b600083516001600160401b03811115610a3157634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610a5a578160200160208202803683370190505b50905060005b84518110156108da57610ab4858281518110610a8c57634e487b7160e01b600052603260045260246000fd5b602002602001015185838151811061098f57634e487b7160e01b600052603260045260246000fd5b828281518110610ad457634e487b7160e01b600052603260045260246000fd5b6020908102919091010152610ae881611e0c565b9050610a60565b610af7611556565b506001600160a01b03918216600090815260056020908152604080832093835292815290829020825160a081018452815481526001820154909416918401919091526002810154918301919091526003810154606083015260040154608082015290565b60086020526000908152604090205481565b60095481565b610b7b61134f565b6001600160a01b0316610b8c610be2565b6001600160a01b031614610bb25760405162461bcd60e51b81526004016104db90611b7f565b610bbc6000611353565b565b6001546001600160a01b031681565b6000908152600a602052604090206003015490565b6000546001600160a01b031690565b60606000610bfe8361050f565b90506000816001600160401b03811115610c2857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610c6157816020015b610c4e611556565b815260200190600190039081610c465790505b50905060005b828110156108da57610c798582611160565b828281518110610c9957634e487b7160e01b600052603260045260246000fd5b60200260200101819052508080610caf90611e0c565b915050610c67565b60056020908152600092835260408084209091529082529020805460018201546002830154600384015460049094015492936001600160a01b039092169290919085565b60066020526000908152604090205481565b606061050930836108e2565b3360009081526004602052604090205460ff16610d485760405162461bcd60e51b81526004016104db906119bd565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526004602052604090205460ff16610d995760405162461bcd60e51b81526004016104db906119bd565b6001600160a01b03166000908152600460205260409020805460ff19166001179055565b6001600160a01b031660009081526006602052604090205490565b6000908152600a602052604090206002015490565b3360009081526004602052604090205460ff16610e1c5760405162461bcd60e51b81526004016104db906119bd565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600a60205260009081526040902080546001820154600283015460038401546004850154600590950154939492939192909186565b3360009081526004602052604090205460ff16610ea25760405162461bcd60e51b81526004016104db906119bd565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b031681565b3360009081526004602052604090205460ff16610f025760405162461bcd60e51b81526004016104db906119bd565b610f0b836111dc565b610f275760405162461bcd60e51b81526004016104db90611bb4565b600082610f3385610dd8565b610f3d9190611df5565b1015610f5b5760405162461bcd60e51b81526004016104db9061197b565b610f64836113a3565b610f805760405162461bcd60e51b81526004016104db90611ce0565b610f8c8484848461142d565b610f988385848461148c565b6000838152600b602090815260408083206001600160a01b0388168452909152902054610fdf576000838152600c60205260408120805491610fd983611e0c565b91905055505b6001600160a01b038085166000908152600d602090815260408083206003549094168352929052205460ff16611034576003546110289085906001600160a01b031660016114ea565b611034843060016114ea565b61104030858585610565565b6001600160a01b038416600090815260066020526040812080549161106483611e0c565b9091555050600083815260086020526040812080549161108383611e0c565b90915550506009805490600061109883611e0c565b90915550506000838152600a6020526040812060020180548492906110be908490611df5565b90915550506000838152600a6020526040812060030180548492906110e4908490611ddd565b909155505050505050565b6110f761134f565b6001600160a01b0316611108610be2565b6001600160a01b03161461112e5760405162461bcd60e51b81526004016104db90611b7f565b6001600160a01b0381166111545760405162461bcd60e51b81526004016104db90611a0b565b61115d81611353565b50565b611168611556565b50600091825260076020908152604080842092845291815291819020815160a0810183528154815260018201546001600160a01b0316938101939093526002810154918301919091526003810154606083015260040154608082015290565b60046020526000908152604090205460ff1681565b6001546040516331a9108f60e11b81526000916001600160a01b03169082908290636352211e90611211908790600401611d34565b60206040518083038186803b15801561122957600080fd5b505afa15801561123d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112619190611616565b6001600160a01b031614159392505050565b3360009081526004602052604090205460ff166112a25760405162461bcd60e51b81526004016104db906119bd565b6112ab826111dc565b6112c75760405162461bcd60e51b81526004016104db90611bb4565b6001600160a01b0383166112ed5760405162461bcd60e51b81526004016104db90611aa1565b6000828152600b602090815260408083206001600160a01b03871684529091528120805483929061131f908490611ddd565b90915550506000828152600a602052604081206001018054839290611345908490611ddd565b9091555050505050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600154604051637b156fb560e01b81526000916001600160a01b0316908190637b156fb5906113d6908690600401611d34565b60206040518083038186803b1580156113ee57600080fd5b505afa158015611402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114269190611818565b9392505050565b600061143885610dbd565b6001600160a01b0395909516600081815260056020908152604080832098835297905295909520938455506002830191909155600382015542600482015560010180546001600160a01b0319169091179055565b60006114978561050f565b6000868152600760209081526040808320938352929052209485555060028401919091556003830155426004830155600190910180546001600160a01b0319166001600160a01b03909216919091179055565b816001600160a01b0316836001600160a01b0316141561151c5760405162461bcd60e51b81526004016104db90611c47565b6001600160a01b039283166000908152600d6020908152604080832094909516825292909252919020805460ff1916911515919091179055565b6040518060a001604052806000815260200160006001600160a01b031681526020016000815260200160008152602001600081525090565b600082601f83011261159e578081fd5b813560206115b36115ae83611dba565b611d91565b82815281810190858301838502870184018810156115cf578586fd5b855b858110156115ed578135845292840192908401906001016115d1565b5090979650505050505050565b60006020828403121561160b578081fd5b813561142681611e53565b600060208284031215611627578081fd5b815161142681611e53565b60008060008060808587031215611647578283fd5b843561165281611e53565b9350602085013561166281611e53565b93969395505050506040820135916060013590565b60008060408385031215611689578182fd5b823561169481611e53565b915060208301356001600160401b038111156116ae578182fd5b6116ba8582860161158e565b9150509250929050565b600080604083850312156116d6578182fd5b82356116e181611e53565b946020939093013593505050565b60008060008060808587031215611704578384fd5b843561170f81611e53565b966020860135965060408601359560600135945092505050565b6000806040838503121561173b578182fd5b82356001600160401b0380821115611751578384fd5b818501915085601f830112611764578384fd5b813560206117746115ae83611dba565b82815281810190858301838502870184018b1015611790578889fd5b8896505b848710156117bb5780356117a781611e53565b835260019690960195918301918301611794565b50965050860135925050808211156117d1578283fd5b506116ba8582860161158e565b6000602082840312156117ef578081fd5b81356001600160401b03811115611804578182fd5b6118108482850161158e565b949350505050565b600060208284031215611829578081fd5b81518015158114611426578182fd5b600060208284031215611849578081fd5b5035919050565b60008060408385031215611862578182fd5b82359150602083013561187481611e53565b809150509250929050565b60008060408385031215611891578182fd5b50508035926020909101359150565b805182526020808201516001600160a01b0316908301526040808201519083015260608082015190830152608090810151910152565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b8181101561192c576119198385516118a0565b9284019260a09290920191600101611906565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561192c57835183529284019291840191600101611954565b901515815260200190565b60208082526022908201527f4b6f6c6f724c616e64546f6b656e3a2065786365656473206d617820616d6f756040820152611b9d60f21b606082015260800190565b6020808252602e908201527f4b6f6c6f72204c616e64204e46543a20596f75277265206e6f7420616c6c6f7760408201526d656420746f20646f20746861742160901b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526030908201527f4b6f6c6f724c616e64546f6b656e3a206163636f756e747320616e642069647360408201526f040d8cadccee8d040dad2e6dac2e8c6d60831b606082015260800190565b60208082526028908201527f4b6f6c6f724c616e64546f6b656e3a206d696e7420746f20746865207a65726f604082015267206164647265737360c01b606082015260800190565b6020808252602c908201527f4b6f6c6f724c616e64546f6b656e3a207472616e7366657220746f207468652060408201526b7a65726f206164647265737360a01b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526021908201527f4b6f6c6f724c616e64546f6b656e3a206c616e64206d757374206578697374736040820152602160f81b606082015260800190565b60208082526032908201527f4b6f6c6f724c616e64546f6b656e3a2062616c616e636520717565727920666f6040820152717220746865207a65726f206164647265737360701b606082015260800190565b60208082526029908201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604082015268103337b91039b2b63360b91b606082015260800190565b60208082526030908201527f4b6f6c6f724c616e64546f6b656e3a2063616c6c6572206973206e6f74206f7760408201526f1b995c881b9bdc88185c1c1c9bdd995960821b606082015260800190565b60208082526026908201527f4b6f6c6f724c616e64546f6b656e3a206c616e64206e6f74207075626c6973686040820152651959081e595d60d21b606082015260800190565b60a0810161050982846118a0565b90815260200190565b9485526001600160a01b0393909316602085015260408401919091526060830152608082015260a00190565b958652602086019490945260408501929092526060840152608083015260a082015260c00190565b6040518181016001600160401b0381118282101715611db257611db2611e3d565b604052919050565b60006001600160401b03821115611dd357611dd3611e3d565b5060209081020190565b60008219821115611df057611df0611e27565b500190565b600082821015611e0757611e07611e27565b500390565b6000600019821415611e2057611e20611e27565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461115d57600080fdfea2646970667358221220b93530de8b739c80172b609fe572e7c9ae536c69bb087218e05308773165944164736f6c63430008000033000000000000000000000000b70b639f29c45882b4c39e7611d2ba8e171dc5610000000000000000000000006600c5c3e729d1fd9a367d5b614fa7df403cace2

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106101d05760003560e01c80637a93f79111610105578063c17630c71161009d578063c17630c7146103f4578063d0d41fe114610407578063d42532e71461041a578063da9bcb121461043f578063daa17f4914610452578063efddc7621461045a578063f2fde38b1461046d578063fb0f63df14610480578063fe9fbb8014610493576101d0565b80637a93f791146103545780638da5cb5b146103675780638e5a3c901461036f578063905dfba31461038257806398dc34e4146103955780639c35ea0a146103a8578063b47cc556146103bb578063b6a5d7de146103ce578063bd795914146103e1576101d0565b806333cd33831161017857806333cd3383146102965780633e0d7ac3146102b65780634dff48e5146102d65780634e1273f4146102e95780634faf5aac146102fc57806360e743dc1461031c57806370fd37cf1461032f578063715018a61461033757806375fa950a1461033f576101d0565b8062fdd58e146101d557806301aff5b0146101fe5780630570677c146102115780630febdd49146102355780631f3203311461024a57806323a241911461025d57806325f64d7c146102705780632a11ced014610283575b600080fd5b6101e86101e33660046116c4565b6104b3565b6040516101f59190611d34565b60405180910390f35b6101e861020c366004611838565b61050f565b61022461021f36600461187f565b610521565b6040516101f5959493929190611d3d565b610248610243366004611632565b610565565b005b6101e8610258366004611850565b6106a8565b61024861026b36600461187f565b6106c5565b61024861027e36600461187f565b610756565b6101e8610291366004611838565b610802565b6102a96102a43660046115fa565b610814565b6040516101f591906118ea565b6102c96102c4366004611677565b6108e2565b6040516101f59190611938565b6101e86102e4366004611838565b6109d9565b6102c96102f7366004611729565b6109e5565b61030f61030a3660046116c4565b610aef565b6040516101f59190611d26565b6101e861032a366004611838565b610b5b565b6101e8610b6d565b610248610b73565b610347610bbe565b6040516101f591906118d6565b6101e8610362366004611838565b610bcd565b610347610be2565b6102a961037d366004611838565b610bf1565b6102246103903660046116c4565b610cb7565b6101e86103a33660046115fa565b610cfb565b6102c96103b63660046117de565b610d0d565b6102486103c93660046115fa565b610d19565b6102486103dc3660046115fa565b610d6a565b6101e86103ef3660046115fa565b610dbd565b6101e8610402366004611838565b610dd8565b6102486104153660046115fa565b610ded565b61042d610428366004611838565b610e3e565b6040516101f596959493929190611d69565b61024861044d3660046115fa565b610e73565b610347610ec4565b6102486104683660046116ef565b610ed3565b61024861047b3660046115fa565b6110ef565b61030f61048e36600461187f565b611160565b6104a66104a13660046115fa565b6111c7565b6040516101f59190611970565b60006001600160a01b0383166104e45760405162461bcd60e51b81526004016104db90611bf5565b60405180910390fd5b506000818152600b602090815260408083206001600160a01b03861684529091529020545b92915050565b60009081526008602052604090205490565b60076020908152600092835260408084209091529082529020805460018201546002830154600384015460049094015492936001600160a01b039092169290919085565b836001600160a01b0381163314806105a057506001600160a01b0381166000908152600d6020908152604080832033845290915290205460ff165b6105bc5760405162461bcd60e51b81526004016104db90611c90565b6001600160a01b0384166105e25760405162461bcd60e51b81526004016104db90611ae9565b6000838152600b602090815260408083206001600160a01b0389168452909152902054828110156106255760405162461bcd60e51b81526004016104db90611b35565b6000848152600b602090815260408083206001600160a01b038a168452909152902083820390819055610669576000848152600c6020526040902080546000190190555b6000848152600b602090815260408083206001600160a01b03891684529091528120805485929061069b908490611ddd565b9091555050505050505050565b600b60209081526000928352604080842090915290825290205481565b3360009081526004602052604090205460ff166106f45760405162461bcd60e51b81526004016104db906119bd565b6106fd826111dc565b6107195760405162461bcd60e51b81526004016104db90611bb4565b6000828152600a602052604081208281556001810183905560028101839055600381019190915542600490910155610752308383611273565b5050565b3360009081526004602052604090205460ff166107855760405162461bcd60e51b81526004016104db906119bd565b61078e826111dc565b6107aa5760405162461bcd60e51b81526004016104db90611bb4565b6000828152600a6020526040812060010180548392906107cb908490611ddd565b90915550506000828152600a6020526040812060020180548392906107f1908490611ddd565b909155506107529050308383611273565b600c6020526000908152604090205481565b6060600061082183610dbd565b90506000816001600160401b0381111561084b57634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561088457816020015b610871611556565b8152602001906001900390816108695790505b50905060005b828110156108da5761089c8582610aef565b8282815181106108bc57634e487b7160e01b600052603260045260246000fd5b602002602001018190525080806108d290611e0c565b91505061088a565b509392505050565b60606001600160a01b03831661090a5760405162461bcd60e51b81526004016104db90611bf5565b600082516001600160401b0381111561093357634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561095c578160200160208202803683370190505b50905060005b83518110156108da5761099c8585838151811061098f57634e487b7160e01b600052603260045260246000fd5b60200260200101516104b3565b8282815181106109bc57634e487b7160e01b600052603260045260246000fd5b6020908102919091010152806109d181611e0c565b915050610962565b600061050930836104b3565b60608151835114610a085760405162461bcd60e51b81526004016104db90611a51565b600083516001600160401b03811115610a3157634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610a5a578160200160208202803683370190505b50905060005b84518110156108da57610ab4858281518110610a8c57634e487b7160e01b600052603260045260246000fd5b602002602001015185838151811061098f57634e487b7160e01b600052603260045260246000fd5b828281518110610ad457634e487b7160e01b600052603260045260246000fd5b6020908102919091010152610ae881611e0c565b9050610a60565b610af7611556565b506001600160a01b03918216600090815260056020908152604080832093835292815290829020825160a081018452815481526001820154909416918401919091526002810154918301919091526003810154606083015260040154608082015290565b60086020526000908152604090205481565b60095481565b610b7b61134f565b6001600160a01b0316610b8c610be2565b6001600160a01b031614610bb25760405162461bcd60e51b81526004016104db90611b7f565b610bbc6000611353565b565b6001546001600160a01b031681565b6000908152600a602052604090206003015490565b6000546001600160a01b031690565b60606000610bfe8361050f565b90506000816001600160401b03811115610c2857634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015610c6157816020015b610c4e611556565b815260200190600190039081610c465790505b50905060005b828110156108da57610c798582611160565b828281518110610c9957634e487b7160e01b600052603260045260246000fd5b60200260200101819052508080610caf90611e0c565b915050610c67565b60056020908152600092835260408084209091529082529020805460018201546002830154600384015460049094015492936001600160a01b039092169290919085565b60066020526000908152604090205481565b606061050930836108e2565b3360009081526004602052604090205460ff16610d485760405162461bcd60e51b81526004016104db906119bd565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b3360009081526004602052604090205460ff16610d995760405162461bcd60e51b81526004016104db906119bd565b6001600160a01b03166000908152600460205260409020805460ff19166001179055565b6001600160a01b031660009081526006602052604090205490565b6000908152600a602052604090206002015490565b3360009081526004602052604090205460ff16610e1c5760405162461bcd60e51b81526004016104db906119bd565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b600a60205260009081526040902080546001820154600283015460038401546004850154600590950154939492939192909186565b3360009081526004602052604090205460ff16610ea25760405162461bcd60e51b81526004016104db906119bd565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6002546001600160a01b031681565b3360009081526004602052604090205460ff16610f025760405162461bcd60e51b81526004016104db906119bd565b610f0b836111dc565b610f275760405162461bcd60e51b81526004016104db90611bb4565b600082610f3385610dd8565b610f3d9190611df5565b1015610f5b5760405162461bcd60e51b81526004016104db9061197b565b610f64836113a3565b610f805760405162461bcd60e51b81526004016104db90611ce0565b610f8c8484848461142d565b610f988385848461148c565b6000838152600b602090815260408083206001600160a01b0388168452909152902054610fdf576000838152600c60205260408120805491610fd983611e0c565b91905055505b6001600160a01b038085166000908152600d602090815260408083206003549094168352929052205460ff16611034576003546110289085906001600160a01b031660016114ea565b611034843060016114ea565b61104030858585610565565b6001600160a01b038416600090815260066020526040812080549161106483611e0c565b9091555050600083815260086020526040812080549161108383611e0c565b90915550506009805490600061109883611e0c565b90915550506000838152600a6020526040812060020180548492906110be908490611df5565b90915550506000838152600a6020526040812060030180548492906110e4908490611ddd565b909155505050505050565b6110f761134f565b6001600160a01b0316611108610be2565b6001600160a01b03161461112e5760405162461bcd60e51b81526004016104db90611b7f565b6001600160a01b0381166111545760405162461bcd60e51b81526004016104db90611a0b565b61115d81611353565b50565b611168611556565b50600091825260076020908152604080842092845291815291819020815160a0810183528154815260018201546001600160a01b0316938101939093526002810154918301919091526003810154606083015260040154608082015290565b60046020526000908152604090205460ff1681565b6001546040516331a9108f60e11b81526000916001600160a01b03169082908290636352211e90611211908790600401611d34565b60206040518083038186803b15801561122957600080fd5b505afa15801561123d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112619190611616565b6001600160a01b031614159392505050565b3360009081526004602052604090205460ff166112a25760405162461bcd60e51b81526004016104db906119bd565b6112ab826111dc565b6112c75760405162461bcd60e51b81526004016104db90611bb4565b6001600160a01b0383166112ed5760405162461bcd60e51b81526004016104db90611aa1565b6000828152600b602090815260408083206001600160a01b03871684529091528120805483929061131f908490611ddd565b90915550506000828152600a602052604081206001018054839290611345908490611ddd565b9091555050505050565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600154604051637b156fb560e01b81526000916001600160a01b0316908190637b156fb5906113d6908690600401611d34565b60206040518083038186803b1580156113ee57600080fd5b505afa158015611402573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114269190611818565b9392505050565b600061143885610dbd565b6001600160a01b0395909516600081815260056020908152604080832098835297905295909520938455506002830191909155600382015542600482015560010180546001600160a01b0319169091179055565b60006114978561050f565b6000868152600760209081526040808320938352929052209485555060028401919091556003830155426004830155600190910180546001600160a01b0319166001600160a01b03909216919091179055565b816001600160a01b0316836001600160a01b0316141561151c5760405162461bcd60e51b81526004016104db90611c47565b6001600160a01b039283166000908152600d6020908152604080832094909516825292909252919020805460ff1916911515919091179055565b6040518060a001604052806000815260200160006001600160a01b031681526020016000815260200160008152602001600081525090565b600082601f83011261159e578081fd5b813560206115b36115ae83611dba565b611d91565b82815281810190858301838502870184018810156115cf578586fd5b855b858110156115ed578135845292840192908401906001016115d1565b5090979650505050505050565b60006020828403121561160b578081fd5b813561142681611e53565b600060208284031215611627578081fd5b815161142681611e53565b60008060008060808587031215611647578283fd5b843561165281611e53565b9350602085013561166281611e53565b93969395505050506040820135916060013590565b60008060408385031215611689578182fd5b823561169481611e53565b915060208301356001600160401b038111156116ae578182fd5b6116ba8582860161158e565b9150509250929050565b600080604083850312156116d6578182fd5b82356116e181611e53565b946020939093013593505050565b60008060008060808587031215611704578384fd5b843561170f81611e53565b966020860135965060408601359560600135945092505050565b6000806040838503121561173b578182fd5b82356001600160401b0380821115611751578384fd5b818501915085601f830112611764578384fd5b813560206117746115ae83611dba565b82815281810190858301838502870184018b1015611790578889fd5b8896505b848710156117bb5780356117a781611e53565b835260019690960195918301918301611794565b50965050860135925050808211156117d1578283fd5b506116ba8582860161158e565b6000602082840312156117ef578081fd5b81356001600160401b03811115611804578182fd5b6118108482850161158e565b949350505050565b600060208284031215611829578081fd5b81518015158114611426578182fd5b600060208284031215611849578081fd5b5035919050565b60008060408385031215611862578182fd5b82359150602083013561187481611e53565b809150509250929050565b60008060408385031215611891578182fd5b50508035926020909101359150565b805182526020808201516001600160a01b0316908301526040808201519083015260608082015190830152608090810151910152565b6001600160a01b0391909116815260200190565b6020808252825182820181905260009190848201906040850190845b8181101561192c576119198385516118a0565b9284019260a09290920191600101611906565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b8181101561192c57835183529284019291840191600101611954565b901515815260200190565b60208082526022908201527f4b6f6c6f724c616e64546f6b656e3a2065786365656473206d617820616d6f756040820152611b9d60f21b606082015260800190565b6020808252602e908201527f4b6f6c6f72204c616e64204e46543a20596f75277265206e6f7420616c6c6f7760408201526d656420746f20646f20746861742160901b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526030908201527f4b6f6c6f724c616e64546f6b656e3a206163636f756e747320616e642069647360408201526f040d8cadccee8d040dad2e6dac2e8c6d60831b606082015260800190565b60208082526028908201527f4b6f6c6f724c616e64546f6b656e3a206d696e7420746f20746865207a65726f604082015267206164647265737360c01b606082015260800190565b6020808252602c908201527f4b6f6c6f724c616e64546f6b656e3a207472616e7366657220746f207468652060408201526b7a65726f206164647265737360a01b606082015260800190565b6020808252602a908201527f455243313135353a20696e73756666696369656e742062616c616e636520666f60408201526939103a3930b739b332b960b11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526021908201527f4b6f6c6f724c616e64546f6b656e3a206c616e64206d757374206578697374736040820152602160f81b606082015260800190565b60208082526032908201527f4b6f6c6f724c616e64546f6b656e3a2062616c616e636520717565727920666f6040820152717220746865207a65726f206164647265737360701b606082015260800190565b60208082526029908201527f455243313135353a2073657474696e6720617070726f76616c20737461747573604082015268103337b91039b2b63360b91b606082015260800190565b60208082526030908201527f4b6f6c6f724c616e64546f6b656e3a2063616c6c6572206973206e6f74206f7760408201526f1b995c881b9bdc88185c1c1c9bdd995960821b606082015260800190565b60208082526026908201527f4b6f6c6f724c616e64546f6b656e3a206c616e64206e6f74207075626c6973686040820152651959081e595d60d21b606082015260800190565b60a0810161050982846118a0565b90815260200190565b9485526001600160a01b0393909316602085015260408401919091526060830152608082015260a00190565b958652602086019490945260408501929092526060840152608083015260a082015260c00190565b6040518181016001600160401b0381118282101715611db257611db2611e3d565b604052919050565b60006001600160401b03821115611dd357611dd3611e3d565b5060209081020190565b60008219821115611df057611df0611e27565b500190565b600082821015611e0757611e07611e27565b500390565b6000600019821415611e2057611e20611e27565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461115d57600080fdfea2646970667358221220b93530de8b739c80172b609fe572e7c9ae536c69bb087218e05308773165944164736f6c63430008000033