ETH Price: $2,513.15 (+0.59%)

Token

The Narrator's Hut (HUT)
 

Overview

Max Total Supply

2,958 HUT

Holders

880

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Filtered by Token Holder
4484.eth
Balance
2 HUT
0x089FCE8bE711CABc806d69B1d0d5aebd52A06455
Loading...
Loading
Loading...
Loading
Loading...
Loading

OVERVIEW

step into the not-so-humble home of our all-seeing NARRATOR, hoarder of trinkets and totems, teapots and terrors, from her travels through the wilds. a curious visitor will stumble upon particular objects of power—ARTIFACTS carrying whispers of the WITCHES who once owned them. perhaps she will conjure such a treasure for you...

# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
NarratorsHut

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion
File 1 of 25 : NarratorsHut.sol
//SPDX-License-Identifier: MIT
//Contract based on [https://docs.openzeppelin.com/contracts/3.x/erc721](https://docs.openzeppelin.com/contracts/3.x/erc721)

pragma solidity ^0.8.17;

/*
.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。

                                                 ▄┐
                                   ▓▌        ▓▓╓██▌
                                   ████▓██████████`
                                  ▄████████████████µ
                                ▄█████████████╬█████▄Γ
                             ╓▓█████████████▓╬╬██████▓▄
                          ,▄████████████▓▓▓▒╬╠╬████████▓,.......
                      ,▄▄██████████████▓▓█▒╬▒╠╣╬▓▓╬╠▓▓▓██▓▄░░░░░.┌
                   ..'╙╙│▀▀██████▓████████▓▓▓▓▓▓▓▓▓╣▓▓▓█▀╙╙▀░░░░░│.
                  .¡░░░░╬╣▒███╬▓╫▓╫▓╫████▓██▓▓▓▓████████▒ε░░╓▓▓▓▓▀⌐
                 ┌.¡░░░░╟╫╣██████████████▓██████▓▓▓▓▓█████████▓████▌─
                '.│░░░Q▄▓█████████████████████▓▓█▓▓██████████▓▓████▓▄▄
                 ,▄▓▓████████████████████▓█▓█▓▓▓▓█▓▒╚╚█▓▓██▓▓▓▓██████▓▓═
               "╠╠▀████████████████████▓▓█▓█▓▓▓█▓▓▓░░▒╣╬▓╣██▓▓▓█████▌   φε
                └╠░████╣██╬██▓█████████▓▓▓▓▓▓███▓▓▓╬╬╬╣▓▓╣█▓████████▓████▒
              ▐▌╓╠▄╣████████▓▓██████████████████▓▓▓╬▓▓▓╬▓╣▓██████▓██▓▀▀▀▀░╛
              ║█████████████████████████████████▓▓╣██▓█╣▓╣▓▓▓╣╬╣╬╬╬╬▒╠│░'"
              ╚████████████████████████████████▓▓╣╬▓▀▓█▓▓╣▓▓▓▓▓▓▓▓╬╬╠▒░.
            ,Q ╓▄░░╬╚███████████████████████████▓╫▓▓▓███▓▓╬▓█▓▓╬▓▓╬╬▒░░
           ]██▌ └ⁿ"░╚╚░╚╚▀▀▀██▀█████████████████▓▓▓█▓█▓▓███▓▓▓▓╬╣▓╬╬▀Γ=
             ¬       '''"░""Γ"░Γ░░Γ╙╙▀▀▀▀█████████████╬███▓╬▓▓██╬╬▓░░░'
                                     ' `"""""░╚╙╟╚╚╚╠╣╬╬╬╬╬▓▓▀╬╩▒▓▓▓∩'
                                                    ` "└└╙"╙╙Γ""`

                                                       s                                            _                                 
                         ..                           :8                                           u                                  
             .u    .    @L           .d``            .88           u.                       u.    88Nu.   u.                u.    u.  
      .    .d88B :@8c  9888i   .dL   @8Ne.   .u     :888ooo  ...ue888b           .    ...ue888b  '88888.o888c      .u     x@88k u@88c.
 .udR88N  ="8888f8888r `Y888k:*888.  %8888:u@88N  -*8888888  888R Y888r     .udR88N   888R Y888r  ^8888  8888   ud8888.  ^"8888""8888"
<888'888k   4888>'88"    888E  888I   `888I  888.   8888     888R I888>    <888'888k  888R I888>   8888  8888 :888'8888.   8888  888R 
9888 'Y"    4888> '      888E  888I    888I  888I   8888     888R I888>    9888 'Y"   888R I888>   8888  8888 d888 '88%"   8888  888R 
9888        4888>        888E  888I    888I  888I   8888     888R I888>    9888       888R I888>   8888  8888 8888.+"      8888  888R 
9888       .d888L .+     888E  888I  uW888L  888'  .8888Lu= u8888cJ888     9888      u8888cJ888   .8888b.888P 8888L        8888  888R 
?8888u../  ^"8888*"     x888N><888' '*88888Nu88P   ^%888*    "*888*P"      ?8888u../  "*888*P"     ^Y8888*""  '8888c. .+  "*88*" 8888"
 "8888P'      "Y"        "88"  888  ~ '88888F`       'Y"       'Y"          "8888P'     'Y"          `Y"       "88888%      ""   'Y"  
   "P'                         88F     888 ^                                  "P'                                "YP'                 
                              98"      *8E                                                                                            
                            ./"        '8>                                                                                            
                           ~`           "                                                                                             

.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。
*/

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

import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/interfaces/IERC20.sol";

import "@openzeppelin/contracts/access/Ownable.sol";

import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "./utils/Signatures.sol";

import "./ERC721Hut.sol";
import "./interfaces/INarratorsHut.sol";

contract NarratorsHut is INarratorsHut, ERC721Hut, IERC2981, Ownable {
    uint256 private tokenCounter;
    string private baseURI;

    bool public isSaleActive = false;

    // Mapping to keep track of whether a combination of
    // address, artifactId, and witchId have minted an artifact.
    mapping(bytes32 => uint256) private _tokenIdsByMintKey;

    address public metadataContractAddress;
    address public narratorAddress;

    bool private isOpenSeaConduitActive = true;

    // Domain Separator is the EIP-712 defined structure that defines what contract
    // and chain these signatures can be used for. This ensures people can't take
    // a signature used to mint on one contract and use it for another, or a signature
    // from testnet to replay on mainnet.
    // It has to be created in the constructor so we can dynamically grab the chainId.
    bytes32 private immutable domainSeparator;

    constructor(
        address _metadataContractAddress,
        address _narratorAddress,
        string memory _baseURI
    ) ERC721Hut("The Narrator's Hut", "HUT") {
        // This should match what's in the client side signing code
        domainSeparator = keccak256(
            abi.encode(
                Signatures.DOMAIN_TYPEHASH,
                keccak256(bytes("MintToken")),
                keccak256(bytes("1")),
                block.chainid,
                address(this)
            )
        );

        metadataContractAddress = _metadataContractAddress;
        narratorAddress = _narratorAddress;
        baseURI = _baseURI;
    }

    // ============ ACCESS CONTROL/SANITY MODIFIERS ============

    modifier saleIsActive() {
        if (!isSaleActive) revert SaleIsNotActive();
        _;
    }

    modifier isCorrectPayment(uint256 totalCost) {
        if (totalCost != msg.value) revert IncorrectPaymentReceived();
        _;
    }

    modifier isValidMintSignature(
        bytes calldata mintSignature,
        uint256 totalCost,
        uint256 expiresAt,
        TokenData[] calldata tokenDataArray
    ) {
        if (narratorAddress == address(0)) {
            revert InvalidNarratorAddress();
        }
        if (block.timestamp >= expiresAt) {
            revert MintSignatureHasExpired();
        }
        // NOTE: we don't use an explicit nonce for the signature
        // since we are enforcing on-chain that a combination of
        // address, witchId, and artifactId can only ever mint once.
        // This implicitly doubles as our nonce for the signature,
        // since it also ensures a signature can only be used once
        // and prevents any replay attacks.
        bytes32 recreatedHash = Signatures.recreateMintHash(
            domainSeparator,
            msg.sender,
            totalCost,
            expiresAt,
            tokenDataArray
        );

        if (
            !SignatureChecker.isValidSignatureNow(
                narratorAddress,
                recreatedHash,
                mintSignature
            )
        ) {
            revert InvalidMintSignature();
        }
        _;
    }

    modifier canMintArtifact(TokenData calldata tokenData) {
        if (
            getTokenIdForArtifact(
                msg.sender,
                tokenData.artifactId,
                tokenData.witchId
            ) > 0
        ) {
            revert ArtifactCapReached();
        }

        INarratorsHutMetadata metadataContract = INarratorsHutMetadata(
            metadataContractAddress
        );
        if (!metadataContract.canMintArtifact(tokenData.artifactId)) {
            revert ArtifactIsNotMintable();
        }
        _;
    }

    // ============ PUBLIC FUNCTIONS FOR MINTING ============

    function mint(MintInput calldata mintInput)
        external
        payable
        saleIsActive
        isValidMintSignature(
            mintInput.mintSignature,
            mintInput.totalCost,
            mintInput.expiresAt,
            mintInput.tokenDataArray
        )
        isCorrectPayment(mintInput.totalCost)
    {
        for (uint256 i; i < mintInput.tokenDataArray.length; ) {
            mintArtifact(mintInput.tokenDataArray[i]);
            unchecked {
                ++i;
            }
        }
    }

    // ============ PUBLIC READ-ONLY FUNCTIONS ============

    function getArtifactForToken(uint256 tokenId)
        external
        view
        returns (ArtifactManifestation memory)
    {
        (uint256 artifactId, uint256 witchId) = _getDataForToken(tokenId);
        return
            INarratorsHutMetadata(metadataContractAddress).getArtifactForToken(
                artifactId,
                tokenId,
                witchId
            );
    }

    function getTokenIdForArtifact(
        address addr,
        uint48 artifactId,
        uint48 witchId
    ) public view returns (uint256) {
        bytes32 mintKey = getMintKey(addr, artifactId, witchId);
        return _tokenIdsByMintKey[mintKey];
    }

    function getBaseURI() external view returns (string memory) {
        return baseURI;
    }

    function totalSupply() external view returns (uint256) {
        return tokenCounter;
    }

    // ============ OWNER-ONLY ADMIN FUNCTIONS ============

    function setIsSaleActive(bool _status) external onlyOwner {
        isSaleActive = _status;
    }

    // enables us to disable gasless listings for security in case
    // opensea ever shuts down or is compromised
    function setIsOpenSeaConduitActive(bool _isOpenSeaConduitActive)
        external
        onlyOwner
    {
        isOpenSeaConduitActive = _isOpenSeaConduitActive;
    }

    function setMetadataContractAddress(address _metadataContractAddress)
        external
        onlyOwner
    {
        metadataContractAddress = _metadataContractAddress;
    }

    function setNarratorAddress(address _narratorAddress) external onlyOwner {
        narratorAddress = _narratorAddress;
    }

    function setBaseURI(string calldata _baseURI) external onlyOwner {
        baseURI = _baseURI;
    }

    function withdraw() external onlyOwner {
        uint256 balance = address(this).balance;
        if (balance == 0) {
            revert PaymentBalanceZero();
        }

        (bool success, bytes memory result) = owner().call{value: balance}("");
        if (!success) {
            revert PaymentUnsuccessful(result);
        }
    }

    function withdrawToken(IERC20 token) external onlyOwner {
        uint256 balance = token.balanceOf(address(this));
        if (balance == 0) {
            revert PaymentBalanceZero();
        }
        token.transfer(msg.sender, balance);
    }

    // ============ SUPPORTING FUNCTIONS ============

    function nextTokenId() private returns (uint256) {
        unchecked {
            ++tokenCounter;
        }
        return tokenCounter;
    }

    function getMintKey(
        address addr,
        uint48 artifactId,
        uint48 witchId
    ) private pure returns (bytes32) {
        // We keep track of whether a witch or an address have minted
        // artifacts of a specific type in order to enforce a mint
        // cap of one artifact type per witch, or per address if
        // not a witch owner.
        if (witchId != 0) {
            // If minting with a witch, record that the witch has
            // minted the specified artifact type
            return bytes32(abi.encodePacked(witchId, artifactId));
        } else {
            // If minting without a witch, record that the address has
            // minted the specified artifact type
            return bytes32(abi.encodePacked(addr, artifactId));
        }
    }

    function mintArtifact(TokenData calldata tokenData)
        private
        canMintArtifact(tokenData)
    {
        uint256 tokenId = nextTokenId();

        // Record that the witch, or address, has minted the
        // given artifact type
        bytes32 mintKey = getMintKey(
            msg.sender,
            tokenData.artifactId,
            tokenData.witchId
        );
        _tokenIdsByMintKey[mintKey] = tokenId;

        _mint(msg.sender, tokenId, tokenData.artifactId, tokenData.witchId);
    }

    // ============ FUNCTION OVERRIDES ============

    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ERC721Hut, IERC165)
        returns (bool)
    {
        return
            interfaceId == type(IERC2981).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev Override isApprovedForAll to allowlist user's OpenSea proxy accounts to enable gas-less listings.
     */
    function isApprovedForAll(address owner, address operator)
        public
        view
        override
        returns (bool)
    {
        if (
            isOpenSeaConduitActive &&
            // NOTE: Now that OpenSea has migrated to Seaport, we can check if
            // the operator is OpenSea's conduit.
            // The address is the same across all networks thanks to CREATE2.
            operator == 0x1E0049783F008A0085193E00003D00cd54003c71
        ) {
            return true;
        }

        return super.isApprovedForAll(owner, operator);
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId)
        public
        view
        virtual
        override
        returns (string memory)
    {
        if (!_exists(tokenId)) revert TokenURIQueryForNonexistentToken();

        string memory url = string.concat(
            baseURI,
            "/",
            Strings.toString(tokenId)
        );
        return url;
    }

    /**
     * @dev See {IERC165-royaltyInfo}.
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        override
        returns (address receiver, uint256 royaltyAmount)
    {
        if (!_exists(tokenId)) revert RoyaltiesQueryForNonexistentToken();

        return (owner(), (salePrice * 5) / 100);
    }

    // ============ ERRORS ============

    error SaleIsNotActive();
    error IncorrectPaymentReceived();
    error ArtifactCapReached();
    error ArtifactIsNotMintable();
    error RoyaltiesQueryForNonexistentToken();
    error TokenURIQueryForNonexistentToken();
    error MintSignatureHasExpired();
    error InvalidNarratorAddress();
    error InvalidMintSignature();
    error PaymentBalanceZero();
    error PaymentUnsuccessful(bytes result);
}

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

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 {
        require(operator != _msgSender(), "ERC721: approve to caller");

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

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view 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 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 {}
}

File 3 of 25 : IERC2981.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Interface for the NFT Royalty Standard
 */
interface IERC2981 is IERC165 {
    /**
     * @dev Called with the sale price to determine how much royalty is owed and to whom.
     * @param tokenId - the NFT asset queried for royalty information
     * @param salePrice - the sale price of the NFT asset specified by `tokenId`
     * @return receiver - address of who should be sent the royalty payment
     * @return royaltyAmount - the royalty payment amount for `salePrice`
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}

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

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20.sol";

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

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() {
        _setOwner(_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 {
        _setOwner(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");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 6 of 25 : MerkleProof.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        bytes32 computedHash = leaf;

        for (uint256 i = 0; i < proof.length; i++) {
            bytes32 proofElement = proof[i];

            if (computedHash <= proofElement) {
                // Hash(current computed hash + current element of the proof)
                computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
            } else {
                // Hash(current element of the proof + current computed hash)
                computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
            }
        }

        // Check if the computed hash (root) is equal to the provided root
        return computedHash == root;
    }
}

File 7 of 25 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

File 8 of 25 : SignatureChecker.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./ECDSA.sol";
import "../Address.sol";
import "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper: Provide a single mechanism to verify both private-key (EOA) ECDSA signature and
 * ERC1271 contract sigantures. Using this instead of ECDSA.recover in your contract will make them compatible with
 * smart contract wallets such as Argent and Gnosis.
 *
 * Note: unlike ECDSA signatures, contract signature's are revocable, and the outcome of this function can thus change
 * through time. It could return true at block N and false at block N+1 (or the opposite).
 *
 * _Available since v4.1._
 */
library SignatureChecker {
    function isValidSignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
        if (error == ECDSA.RecoverError.NoError && recovered == signer) {
            return true;
        }

        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
        );
        return (success && result.length == 32 && abi.decode(result, (bytes4)) == IERC1271.isValidSignature.selector);
    }
}

File 9 of 25 : Signatures.sol
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "../interfaces/INarratorsHut.sol";

library Signatures {
    // Typehashes for the data types specified in the structured data
    // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#rationale-for-typehash
    // This should match whats in the client side signing code
    bytes32 constant DOMAIN_TYPEHASH =
        keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );

    bytes constant TOKEN_DATA_TYPE_DEF =
        "TokenData(uint32 artifactId,uint32 witchId)";
    bytes32 constant MINT_TYPEHASH =
        keccak256(
            abi.encodePacked(
                "Mint(address minterAddress,uint256 totalCost,uint256 expiresAt,TokenData[] tokenDataArray)",
                TOKEN_DATA_TYPE_DEF
            )
        );
    bytes32 constant TOKEN_DATA_TYPEHASH = keccak256(TOKEN_DATA_TYPE_DEF);

    // Verify signature by recreating the hash that we signed on
    // the client side, and then using that to recover
    // the address that signed the signature for this data.
    function recreateMintHash(
        bytes32 domainSeparator,
        address minterAddress,
        uint256 totalCost,
        uint256 expiresAt,
        TokenData[] calldata tokenDataArray
    ) internal pure returns (bytes32) {
        bytes32 mintHash = _hashMint(
            minterAddress,
            totalCost,
            expiresAt,
            tokenDataArray
        );

        return _eip712Message(domainSeparator, mintHash);
    }

    function _hashMint(
        address minterAddress,
        uint256 totalCost,
        uint256 expiresAt,
        TokenData[] calldata tokenDataArray
    ) private pure returns (bytes32) {
        bytes32[] memory tokenDataHashes = new bytes32[](tokenDataArray.length);
        for (uint256 i; i < tokenDataArray.length; ) {
            tokenDataHashes[i] = _hashTokenData(tokenDataArray[i]);
            unchecked {
                ++i;
            }
        }

        return
            keccak256(
                abi.encode(
                    MINT_TYPEHASH,
                    minterAddress,
                    totalCost,
                    expiresAt,
                    keccak256(abi.encodePacked(tokenDataHashes))
                )
            );
    }

    function _hashTokenData(TokenData calldata tokenData)
        private
        pure
        returns (bytes32)
    {
        return
            keccak256(
                abi.encode(
                    TOKEN_DATA_TYPEHASH,
                    tokenData.artifactId,
                    tokenData.witchId
                )
            );
    }

    function _eip712Message(bytes32 domainSeparator, bytes32 dataHash)
        private
        pure
        returns (bytes32)
    {
        return
            keccak256(
                abi.encodePacked(uint16(0x1901), domainSeparator, dataHash)
            );
    }
}

File 10 of 25 : ERC721Hut.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

/*
.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。

                                                 ▄┐
                                   ▓▌        ▓▓╓██▌
                                   ████▓██████████`
                                  ▄████████████████µ
                                ▄█████████████╬█████▄Γ
                             ╓▓█████████████▓╬╬██████▓▄
                          ,▄████████████▓▓▓▒╬╠╬████████▓,.......
                      ,▄▄██████████████▓▓█▒╬▒╠╣╬▓▓╬╠▓▓▓██▓▄░░░░░.┌
                   ..'╙╙│▀▀██████▓████████▓▓▓▓▓▓▓▓▓╣▓▓▓█▀╙╙▀░░░░░│.
                  .¡░░░░╬╣▒███╬▓╫▓╫▓╫████▓██▓▓▓▓████████▒ε░░╓▓▓▓▓▀⌐
                 ┌.¡░░░░╟╫╣██████████████▓██████▓▓▓▓▓█████████▓████▌─
                '.│░░░Q▄▓█████████████████████▓▓█▓▓██████████▓▓████▓▄▄
                 ,▄▓▓████████████████████▓█▓█▓▓▓▓█▓▒╚╚█▓▓██▓▓▓▓██████▓▓═
               "╠╠▀████████████████████▓▓█▓█▓▓▓█▓▓▓░░▒╣╬▓╣██▓▓▓█████▌   φε
                └╠░████╣██╬██▓█████████▓▓▓▓▓▓███▓▓▓╬╬╬╣▓▓╣█▓████████▓████▒
              ▐▌╓╠▄╣████████▓▓██████████████████▓▓▓╬▓▓▓╬▓╣▓██████▓██▓▀▀▀▀░╛
              ║█████████████████████████████████▓▓╣██▓█╣▓╣▓▓▓╣╬╣╬╬╬╬▒╠│░'"
              ╚████████████████████████████████▓▓╣╬▓▀▓█▓▓╣▓▓▓▓▓▓▓▓╬╬╠▒░.
            ,Q ╓▄░░╬╚███████████████████████████▓╫▓▓▓███▓▓╬▓█▓▓╬▓▓╬╬▒░░
           ]██▌ └ⁿ"░╚╚░╚╚▀▀▀██▀█████████████████▓▓▓█▓█▓▓███▓▓▓▓╬╣▓╬╬▀Γ=
             ¬       '''"░""Γ"░Γ░░Γ╙╙▀▀▀▀█████████████╬███▓╬▓▓██╬╬▓░░░'
                                     ' `"""""░╚╙╟╚╚╚╠╣╬╬╬╬╬▓▓▀╬╩▒▓▓▓∩'
                                                    ` "└└╙"╙╙Γ""`

                                                       s                                            _                                 
                         ..                           :8                                           u                                  
             .u    .    @L           .d``            .88           u.                       u.    88Nu.   u.                u.    u.  
      .    .d88B :@8c  9888i   .dL   @8Ne.   .u     :888ooo  ...ue888b           .    ...ue888b  '88888.o888c      .u     x@88k u@88c.
 .udR88N  ="8888f8888r `Y888k:*888.  %8888:u@88N  -*8888888  888R Y888r     .udR88N   888R Y888r  ^8888  8888   ud8888.  ^"8888""8888"
<888'888k   4888>'88"    888E  888I   `888I  888.   8888     888R I888>    <888'888k  888R I888>   8888  8888 :888'8888.   8888  888R 
9888 'Y"    4888> '      888E  888I    888I  888I   8888     888R I888>    9888 'Y"   888R I888>   8888  8888 d888 '88%"   8888  888R 
9888        4888>        888E  888I    888I  888I   8888     888R I888>    9888       888R I888>   8888  8888 8888.+"      8888  888R 
9888       .d888L .+     888E  888I  uW888L  888'  .8888Lu= u8888cJ888     9888      u8888cJ888   .8888b.888P 8888L        8888  888R 
?8888u../  ^"8888*"     x888N><888' '*88888Nu88P   ^%888*    "*888*P"      ?8888u../  "*888*P"     ^Y8888*""  '8888c. .+  "*88*" 8888"
 "8888P'      "Y"        "88"  888  ~ '88888F`       'Y"       'Y"          "8888P'     'Y"          `Y"       "88888%      ""   'Y"  
   "P'                         88F     888 ^                                  "P'                                "YP'                 
                              98"      *8E                                                                                            
                            ./"        '8>                                                                                            
                           ~`           "                                                                                             

.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。.・。.・゜✭・.・✫・゜・。..・。.・゜✭・.・✫・゜・。.✭・.・✫・゜・。..・✫・゜・。
*/

import "@openzeppelin/contracts/interfaces/IERC721.sol";
import "@openzeppelin/contracts/interfaces/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";

// Packed into a single 256-bit slot
struct TokenDataStorage {
    uint48 artifactId;
    uint48 witchId;
    address owner; // 160 bits
}

/**
 * @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 ERC721Hut 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 token data
    mapping(uint256 => TokenDataStorage) private _tokenDataStorage;

    // Mapping owner address to token counnts
    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 = _tokenDataStorage[tokenId].owner;
        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 = ERC721Hut.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
    {
        require(operator != _msgSender(), "ERC721: approve to caller");

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

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator)
        public
        view
        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 _tokenDataStorage[tokenId].owner != 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)
    {
        address owner = ERC721Hut.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,
        uint48 artifactId,
        uint48 witchId
    ) internal virtual {
        _safeMint(to, tokenId, artifactId, witchId, "");
    }

    /**
     * @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,
        uint48 artifactId,
        uint48 witchId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId, artifactId, witchId);
        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,
        uint48 artifactId,
        uint48 witchId
    ) 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;
        _tokenDataStorage[tokenId].owner = to;
        _tokenDataStorage[tokenId].artifactId = artifactId;
        _tokenDataStorage[tokenId].witchId = witchId;

        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 = ERC721Hut.ownerOf(tokenId);

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

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

        _balances[owner] -= 1;
        delete _tokenDataStorage[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(
            ERC721Hut.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;
        _tokenDataStorage[tokenId].owner = 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(ERC721Hut.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @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 Extracts the artifactId and counter
     * that are packed into the uint256 tokenId.
     * @return (uint48 artifactId, uint48 witchId)
     */
    function _getDataForToken(uint256 tokenId)
        internal
        view
        returns (uint48, uint48)
    {
        uint48 artifactId = _tokenDataStorage[tokenId].artifactId;
        uint48 witchId = _tokenDataStorage[tokenId].witchId;
        return (artifactId, witchId);
    }

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

File 11 of 25 : INarratorsHut.sol
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "@openzeppelin/contracts/interfaces/IERC20.sol";

import "./INarratorsHutMetadata.sol";

struct MintInput {
    uint256 totalCost;
    uint256 expiresAt;
    TokenData[] tokenDataArray;
    bytes mintSignature;
}

struct TokenData {
    // Can safely use uint48 for these values since they can
    // comfortably fit within 2^48
    uint48 witchId;
    uint48 artifactId;
}

interface INarratorsHut {
    function mint(MintInput calldata mintInput) external payable;

    function getArtifactForToken(uint256 tokenId)
        external
        view
        returns (ArtifactManifestation memory);

    function getTokenIdForArtifact(
        address addr,
        uint48 artifactId,
        uint48 witchId
    ) external view returns (uint256);

    function totalSupply() external view returns (uint256);

    function setIsSaleActive(bool _status) external;

    function setIsOpenSeaConduitActive(bool _isOpenSeaConduitActive) external;

    function setMetadataContractAddress(address _metadataContractAddress)
        external;

    function setNarratorAddress(address _narratorAddress) external;

    function setBaseURI(string calldata _baseURI) external;

    function withdraw() external;

    function withdrawToken(IERC20 token) external;
}

File 12 of 25 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 13 of 25 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

File 14 of 25 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

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

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

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

File 16 of 25 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

File 17 of 25 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

File 18 of 25 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

File 19 of 25 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

File 20 of 25 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 21 of 25 : ECDSA.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 22 of 25 : IERC1271.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

File 23 of 25 : INarratorsHutMetadata.sol
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

struct CraftArtifactData {
    uint256 id;
    string name;
    string description;
    string[] attunements;
}

struct Artifact {
    bool mintable;
    string name;
    string description;
    string[] attunements;
}

struct ArtifactManifestation {
    string name;
    string description;
    uint256 witchId;
    uint256 artifactId;
    AttunementManifestation[] attunements;
}

struct AttunementManifestation {
    string name;
    int256 value;
}

interface INarratorsHutMetadata {
    function getArtifactForToken(
        uint256 artifactId,
        uint256 tokenId,
        uint256 witchId
    ) external view returns (ArtifactManifestation memory);

    function canMintArtifact(uint256 artifactId) external view returns (bool);

    function craftArtifact(CraftArtifactData calldata data) external;

    function getArtifact(uint256 artifactId)
        external
        view
        returns (Artifact memory);

    function lockArtifacts(uint256[] calldata artifactIds) external;
}

File 24 of 25 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../token/ERC721/IERC721.sol";

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

pragma solidity ^0.8.0;

import "../token/ERC721/IERC721Receiver.sol";

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_metadataContractAddress","type":"address"},{"internalType":"address","name":"_narratorAddress","type":"address"},{"internalType":"string","name":"_baseURI","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ArtifactCapReached","type":"error"},{"inputs":[],"name":"ArtifactIsNotMintable","type":"error"},{"inputs":[],"name":"IncorrectPaymentReceived","type":"error"},{"inputs":[],"name":"InvalidMintSignature","type":"error"},{"inputs":[],"name":"InvalidNarratorAddress","type":"error"},{"inputs":[],"name":"MintSignatureHasExpired","type":"error"},{"inputs":[],"name":"PaymentBalanceZero","type":"error"},{"inputs":[{"internalType":"bytes","name":"result","type":"bytes"}],"name":"PaymentUnsuccessful","type":"error"},{"inputs":[],"name":"RoyaltiesQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"SaleIsNotActive","type":"error"},{"inputs":[],"name":"TokenURIQueryForNonexistentToken","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getArtifactForToken","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"description","type":"string"},{"internalType":"uint256","name":"witchId","type":"uint256"},{"internalType":"uint256","name":"artifactId","type":"uint256"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"int256","name":"value","type":"int256"}],"internalType":"struct AttunementManifestation[]","name":"attunements","type":"tuple[]"}],"internalType":"struct ArtifactManifestation","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBaseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint48","name":"artifactId","type":"uint48"},{"internalType":"uint48","name":"witchId","type":"uint48"}],"name":"getTokenIdForArtifact","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metadataContractAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"totalCost","type":"uint256"},{"internalType":"uint256","name":"expiresAt","type":"uint256"},{"components":[{"internalType":"uint48","name":"witchId","type":"uint48"},{"internalType":"uint48","name":"artifactId","type":"uint48"}],"internalType":"struct TokenData[]","name":"tokenDataArray","type":"tuple[]"},{"internalType":"bytes","name":"mintSignature","type":"bytes"}],"internalType":"struct MintInput","name":"mintInput","type":"tuple"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"narratorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isOpenSeaConduitActive","type":"bool"}],"name":"setIsOpenSeaConduitActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"setIsSaleActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_metadataContractAddress","type":"address"}],"name":"setMetadataContractAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_narratorAddress","type":"address"}],"name":"setNarratorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040526009805460ff19169055600c805460ff60a01b1916600160a01b1790553480156200002e57600080fd5b50604051620043693803806200436983398101604081905262000051916200027c565b60405180604001604052806012815260200171151a194813985c9c985d1bdc89dcc8121d5d60721b8152506040518060400160405280600381526020016212155560ea1b8152508160009081620000a9919062000405565b506001620000b8828262000405565b505050620000d5620000cf620001f360201b60201c565b620001f7565b604080518082018252600981526826b4b73a2a37b5b2b760b91b6020918201528151808301835260018152603160f81b9082015281517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f918101919091527fc6c8917320cd69932f25620f24981dfb55c857d5d2e7474895d5d69db1b22445918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260c00160408051601f198184030181529190528051602090910120608052600b80546001600160a01b038086166001600160a01b031992831617909255600c8054928516929091169190911790556008620001e9828262000405565b50505050620004d1565b3390565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516001600160a01b03811681146200026157600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156200029257600080fd5b6200029d8462000249565b92506020620002ae81860162000249565b60408601519093506001600160401b0380821115620002cc57600080fd5b818701915087601f830112620002e157600080fd5b815181811115620002f657620002f662000266565b604051601f8201601f19908116603f0116810190838211818310171562000321576200032162000266565b816040528281528a868487010111156200033a57600080fd5b600093505b828410156200035e57848401860151818501870152928501926200033f565b60008684830101528096505050505050509250925092565b600181811c908216806200038b57607f821691505b602082108103620003ac57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200040057600081815260208120601f850160051c81016020861015620003db5750805b601f850160051c820191505b81811015620003fc57828155600101620003e7565b5050505b505050565b81516001600160401b0381111562000421576200042162000266565b620004398162000432845462000376565b84620003b2565b602080601f831160018114620004715760008415620004585750858301515b600019600386901b1c1916600185901b178555620003fc565b600085815260208120601f198616915b82811015620004a25788860151825594840194600190910190840162000481565b5085821015620004c15787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b608051613e7c620004ed600039600061128b0152613e7c6000f3fe6080604052600436106101e35760003560e01c806370a0823111610102578063a22cb46511610095578063d2d65ff511610064578063d2d65ff5146105b7578063e74772d8146105d7578063e985e9c514610604578063f2fde38b1461062457600080fd5b8063a22cb4651461052a578063a758e1d31461054a578063b88d4fde14610577578063c87b56dd1461059757600080fd5b80637afe2b3b116100d15780637afe2b3b146104aa57806389476069146104ca5780638da5cb5b146104ea57806395d89b411461051557600080fd5b806370a082311461044d578063714c53981461046d578063715018a614610482578063744b59921461049757600080fd5b806337a78ff31161017a5780635232ac35116101495780635232ac35146103d357806355f804b3146103f3578063564566a8146104135780636352211e1461042d57600080fd5b806337a78ff3146103515780633ccfd60b1461037e57806342842e0e146103935780634d74d3b4146103b357600080fd5b806318160ddd116101b657806318160ddd146102a6578063210cd92d146102c557806323b872dd146102e55780632a55205a1461030557600080fd5b806301ffc9a7146101e857806306fdde031461021d578063081812fc1461023f578063095ea7b314610284575b600080fd5b3480156101f457600080fd5b50610208610203366004612fb3565b610644565b60405190151581526020015b60405180910390f35b34801561022957600080fd5b506102326106a0565b604051610214919061303e565b34801561024b57600080fd5b5061025f61025a366004613051565b610732565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610214565b34801561029057600080fd5b506102a461029f36600461308c565b610821565b005b3480156102b257600080fd5b506007545b604051908152602001610214565b3480156102d157600080fd5b506102a46102e03660046130b8565b6109ad565b3480156102f157600080fd5b506102a46103003660046130d5565b610a75565b34801561031157600080fd5b50610325610320366004613116565b610b16565b6040805173ffffffffffffffffffffffffffffffffffffffff9093168352602083019190915201610214565b34801561035d57600080fd5b50600c5461025f9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561038a57600080fd5b506102a4610bbf565b34801561039f57600080fd5b506102a46103ae3660046130d5565b610d38565b3480156103bf57600080fd5b506102a46103ce3660046130b8565b610d53565b3480156103df57600080fd5b506102a46103ee366004613146565b610e1b565b3480156103ff57600080fd5b506102a461040e366004613163565b610ee6565b34801561041f57600080fd5b506009546102089060ff1681565b34801561043957600080fd5b5061025f610448366004613051565b610f74565b34801561045957600080fd5b506102b76104683660046130b8565b611036565b34801561047957600080fd5b50610232611104565b34801561048e57600080fd5b506102a4611113565b6102a46104a53660046131d5565b6111a0565b3480156104b657600080fd5b506102b76104c536600461322b565b6113db565b3480156104d657600080fd5b506102a46104e53660046130b8565b611403565b3480156104f657600080fd5b5060065473ffffffffffffffffffffffffffffffffffffffff1661025f565b34801561052157600080fd5b506102326115e8565b34801561053657600080fd5b506102a4610545366004613270565b6115f7565b34801561055657600080fd5b5061056a610565366004613051565b61170d565b60405161021491906132a9565b34801561058357600080fd5b506102a46105923660046134a0565b611835565b3480156105a357600080fd5b506102326105b2366004613051565b6118dd565b3480156105c357600080fd5b506102a46105d2366004613146565b6119a6565b3480156105e357600080fd5b50600b5461025f9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561061057600080fd5b5061020861061f36600461354f565b611a58565b34801561063057600080fd5b506102a461063f3660046130b8565b611af7565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a00000000000000000000000000000000000000000000000000000000148061069a575061069a82611c27565b92915050565b6060600080546106af9061357d565b80601f01602080910402602001604051908101604052809291908181526020018280546106db9061357d565b80156107285780601f106106fd57610100808354040283529160200191610728565b820191906000526020600020905b81548152906001019060200180831161070b57829003601f168201915b5050505050905090565b6000818152600260205260408120546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff166107f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060009081526004602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600061082c82610f74565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016107ef565b3373ffffffffffffffffffffffffffffffffffffffff8216148061091257506109128133611a58565b61099e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107ef565b6109a88383611d0a565b505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314610a2e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b610a7f3382611daa565b610b0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107ef565b6109a8838383611e35565b60008281526002602052604081205481906c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff16610b83576040517fbce35a4700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065473ffffffffffffffffffffffffffffffffffffffff166064610ba98560056135ff565b610bb39190613645565b915091505b9250929050565b60065473ffffffffffffffffffffffffffffffffffffffff163314610c40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b476000819003610c7c576040517f5e6202b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610c9e60065473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff168360405160006040518083038185875af1925050503d8060008114610cf5576040519150601f19603f3d011682016040523d82523d6000602084013e610cfa565b606091505b5091509150816109a857806040517fdf76ce9f0000000000000000000000000000000000000000000000000000000081526004016107ef919061303e565b6109a883838360405180602001604052806000815250611835565b60065473ffffffffffffffffffffffffffffffffffffffff163314610dd4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60065473ffffffffffffffffffffffffffffffffffffffff163314610e9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600c805491151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60065473ffffffffffffffffffffffffffffffffffffffff163314610f67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b60086109a88284836136a7565b6000818152600260205260408120546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff168061069a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016107ef565b600073ffffffffffffffffffffffffffffffffffffffff82166110db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016107ef565b5073ffffffffffffffffffffffffffffffffffffffff1660009081526003602052604090205490565b6060600880546106af9061357d565b60065473ffffffffffffffffffffffffffffffffffffffff163314611194576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b61119e600061209b565b565b60095460ff166111db576040517eecac0100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111e860608201826137c1565b823560208401356111fc6040860186613826565b600c5473ffffffffffffffffffffffffffffffffffffffff1661124b576040517f7223845600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b824210611284576040517f4c746c9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006112b47f00000000000000000000000000000000000000000000000000000000000000003387878787612112565b600c54604080516020601f8b018190048102820181019092528981529293506113129273ffffffffffffffffffffffffffffffffffffffff9092169184918b908b908190840183828082843760009201919091525061218692505050565b611348576040517f9a69144c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8735348114611383576040517fd6ff0e4500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b61139360408b018b613826565b90508110156113cf576113c76113ac60408c018c613826565b838181106113bc576113bc61388e565b905060400201612374565b600101611386565b50505050505050505050565b6000806113e9858585612538565b6000908152600a60205260409020549150505b9392505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314611484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156114f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151591906138bd565b905080600003611551576040517f5e6202b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201526024810182905273ffffffffffffffffffffffffffffffffffffffff83169063a9059cbb906044016020604051808303816000875af11580156115c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a891906138d6565b6060600180546106af9061357d565b3373ffffffffffffffffffffffffffffffffffffffff831603611676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107ef565b33600081815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61173f6040518060a0016040528060608152602001606081526020016000815260200160008152602001606081525090565b60008281526002602052604080822054600b5482517f7465ce5c00000000000000000000000000000000000000000000000000000000815265ffffffffffff8084166004830181905260248301899052660100000000000090940416604482018190529351929473ffffffffffffffffffffffffffffffffffffffff90921692637465ce5c926064808401939192918290030181865afa1580156117e7573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261182d9190810190613a24565b949350505050565b61183f3383611daa565b6118cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107ef565b6118d784848484612607565b50505050565b606061191d826000908152600260205260409020546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff16151590565b611953576040517fdf11708f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006008611960846126aa565b604051602001611971929190613aed565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190529392505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314611a27576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b600c5460009074010000000000000000000000000000000000000000900460ff168015611aae5750731e0049783f008a0085193e00003d00cd54003c7173ffffffffffffffffffffffffffffffffffffffff8316145b15611abb5750600161069a565b5073ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093909416825291909152205460ff1690565b60065473ffffffffffffffffffffffffffffffffffffffff163314611b78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b73ffffffffffffffffffffffffffffffffffffffff8116611c1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107ef565b611c248161209b565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480611cba57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061069a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461069a565b600081815260046020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091558190611d6482610f74565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611db683610f74565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611e2557508373ffffffffffffffffffffffffffffffffffffffff16611e0d84610732565b73ffffffffffffffffffffffffffffffffffffffff16145b8061182d575061182d8185611a58565b8273ffffffffffffffffffffffffffffffffffffffff16611e5582610f74565b73ffffffffffffffffffffffffffffffffffffffff1614611ef8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016107ef565b73ffffffffffffffffffffffffffffffffffffffff8216611f9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016107ef565b611fa5600082611d0a565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260408120805460019290611fdb908490613bbb565b909155505073ffffffffffffffffffffffffffffffffffffffff82166000908152600360205260408120805460019290612016908490613bce565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff8087166c0100000000000000000000000081026bffffffffffffffffffffffff9093169290921790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6006805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008061212287878787876127df565b604080517f1901000000000000000000000000000000000000000000000000000000000000602080830191909152602282018c9052604280830185905283518084039091018152606290920190925280519101209091505b98975050505050505050565b6000806000612195858561294b565b909250905060008160048111156121ae576121ae613be1565b1480156121e657508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b156121f6576001925050506113fc565b6000808773ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b888860405160240161222b929190613c10565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516122b49190613c29565b600060405180830381855afa9150503d80600081146122ef576040519150601f19603f3d011682016040523d82523d6000602084013e6122f4565b606091505b5091509150818015612307575080516020145b801561217a575080517f1626ba7e00000000000000000000000000000000000000000000000000000000906123459083016020908101908401613c45565b7fffffffff00000000000000000000000000000000000000000000000000000000161498975050505050505050565b8060006123983361238b6040850160208601613c62565b6104c56020860186613c62565b11156123d0576040517f181ede8900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600b5473ffffffffffffffffffffffffffffffffffffffff168063db9eee7d6123ff6040850160208601613c62565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815265ffffffffffff9091166004820152602401602060405180830381865afa15801561245a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247e91906138d6565b6124b4576040517f7c66445400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006124c7600780546001019081905590565b905060006124f1336124df6040880160208901613c62565b6124ec6020890189613c62565b612538565b6000818152600a6020908152604091829020859055919250612531913391859161251f918a01908a01613c62565b61252c60208a018a613c62565b6129b6565b5050505050565b600065ffffffffffff8216156125a4576040517fffffffffffff000000000000000000000000000000000000000000000000000060d084811b8216602084015285901b166026820152602c015b60405160208183030381529060405261259d90613c7d565b90506113fc565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606086901b1660208201527fffffffffffff000000000000000000000000000000000000000000000000000060d085901b166034820152603a01612585565b612612848484611e35565b61261e84848484612bb0565b6118d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016107ef565b6060816000036126ed57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612717578061270181613cbf565b91506127109050600a83613645565b91506126f1565b60008167ffffffffffffffff81111561273257612732613390565b6040519080825280601f01601f19166020018201604052801561275c576020820181803683370190505b5090505b841561182d57612771600183613bbb565b915061277e600a86613cf7565b612789906030613bce565b60f81b81838151811061279e5761279e61388e565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506127d8600a86613645565b9450612760565b6000808267ffffffffffffffff8111156127fb576127fb613390565b604051908082528060200260200182016040528015612824578160200160208202803683370190505b50905060005b83811015612877576128528585838181106128475761284761388e565b905060400201612da3565b8282815181106128645761286461388e565b602090810291909101015260010161282a565b506040518060600160405280602b8152602001613e1c602b91396040516020016128a19190613d0b565b60405160208183030381529060405280519060200120878787846040516020016128cb9190613d9c565b6040516020818303038152906040528051906020012060405160200161292995949392919094855273ffffffffffffffffffffffffffffffffffffffff93909316602085015260408401919091526060830152608082015260a00190565b6040516020818303038152906040528051906020012091505095945050505050565b60008082516041036129815760208301516040840151606085015160001a61297587828585612e25565b94509450505050610bb8565b82516040036129aa576020830151604084015161299f868383612f3d565b935093505050610bb8565b50600090506002610bb8565b73ffffffffffffffffffffffffffffffffffffffff8416612a33576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107ef565b6000838152600260205260409020546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1615612acf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107ef565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600360205260408120805460019290612b05908490613bce565b909155505060008381526002602052604080822065ffffffffffff84811666010000000000000273ffffffffffffffffffffffffffffffffffffffff89166c0100000000000000000000000081027fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016928816929092171790915590518592907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a450505050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15612d98576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290612c27903390899088908890600401613dd2565b6020604051808303816000875af1925050508015612c80575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612c7d91810190613c45565b60015b612d4d573d808015612cae576040519150601f19603f3d011682016040523d82523d6000602084013e612cb3565b606091505b508051600003612d45576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016107ef565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a020000000000000000000000000000000000000000000000000000000014905061182d565b506001949350505050565b60006040518060600160405280602b8152602001613e1c602b913980519060200120826020016020810190612dd89190613c62565b612de56020850185613c62565b60408051602081019490945265ffffffffffff92831690840152166060820152608001604051602081830303815290604052805190602001209050919050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612e5c5750600090506003612f34565b8460ff16601b14158015612e7457508460ff16601c14155b15612e855750600090506004612f34565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612ed9573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116612f2d57600060019250925050612f34565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831660ff84901c601b01612f7787828885612e25565b935093505050935093915050565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611c2457600080fd5b600060208284031215612fc557600080fd5b81356113fc81612f85565b60005b83811015612feb578181015183820152602001612fd3565b50506000910152565b6000815180845261300c816020860160208601612fd0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006113fc6020830184612ff4565b60006020828403121561306357600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114611c2457600080fd5b6000806040838503121561309f57600080fd5b82356130aa8161306a565b946020939093013593505050565b6000602082840312156130ca57600080fd5b81356113fc8161306a565b6000806000606084860312156130ea57600080fd5b83356130f58161306a565b925060208401356131058161306a565b929592945050506040919091013590565b6000806040838503121561312957600080fd5b50508035926020909101359150565b8015158114611c2457600080fd5b60006020828403121561315857600080fd5b81356113fc81613138565b6000806020838503121561317657600080fd5b823567ffffffffffffffff8082111561318e57600080fd5b818501915085601f8301126131a257600080fd5b8135818111156131b157600080fd5b8660208285010111156131c357600080fd5b60209290920196919550909350505050565b6000602082840312156131e757600080fd5b813567ffffffffffffffff8111156131fe57600080fd5b8201608081850312156113fc57600080fd5b803565ffffffffffff8116811461322657600080fd5b919050565b60008060006060848603121561324057600080fd5b833561324b8161306a565b925061325960208501613210565b915061326760408501613210565b90509250925092565b6000806040838503121561328357600080fd5b823561328e8161306a565b9150602083013561329e81613138565b809150509250929050565b60006020808352835160a0828501526132c560c0850182612ff4565b9050818501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe060408187850301818801526133018484612ff4565b93508088015160608801526060880151608088015260808801519250818785030160a08801528383518086528686019150868160051b870101878601955060005b8281101561338157858883030184528651805186845261336487850182612ff4565b918b0151938b019390935296890196938901939150600101613342565b509a9950505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156133e2576133e2613390565b60405290565b60405160a0810167ffffffffffffffff811182821017156133e2576133e2613390565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561345257613452613390565b604052919050565b600067ffffffffffffffff82111561347457613474613390565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600080600080608085870312156134b657600080fd5b84356134c18161306a565b935060208501356134d18161306a565b925060408501359150606085013567ffffffffffffffff8111156134f457600080fd5b8501601f8101871361350557600080fd5b80356135186135138261345a565b61340b565b81815288602083850101111561352d57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000806040838503121561356257600080fd5b823561356d8161306a565b9150602083013561329e8161306a565b600181811c9082168061359157607f821691505b6020821081036135ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808202811582820484141761069a5761069a6135d0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261365457613654613616565b500490565b601f8211156109a857600081815260208120601f850160051c810160208610156136805750805b601f850160051c820191505b8181101561369f5782815560010161368c565b505050505050565b67ffffffffffffffff8311156136bf576136bf613390565b6136d3836136cd835461357d565b83613659565b6000601f84116001811461372557600085156136ef5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612531565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b828110156137745786850135825560209485019460019092019101613754565b50868210156137af577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126137f657600080fd5b83018035915067ffffffffffffffff82111561381157600080fd5b602001915036819003821315610bb857600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261385b57600080fd5b83018035915067ffffffffffffffff82111561387657600080fd5b6020019150600681901b3603821315610bb857600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000602082840312156138cf57600080fd5b5051919050565b6000602082840312156138e857600080fd5b81516113fc81613138565b600082601f83011261390457600080fd5b81516139126135138261345a565b81815284602083860101111561392757600080fd5b61182d826020830160208701612fd0565b600082601f83011261394957600080fd5b8151602067ffffffffffffffff8083111561396657613966613390565b8260051b61397583820161340b565b938452858101830193838101908886111561398f57600080fd5b84880192505b8583101561217a578251848111156139ad5760008081fd5b88016040818b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018113156139e35760008081fd5b6139eb6133bf565b87830151878111156139fd5760008081fd5b613a0b8d8a838701016138f3565b8252509101518682015282529184019190840190613995565b600060208284031215613a3657600080fd5b815167ffffffffffffffff80821115613a4e57600080fd5b9083019060a08286031215613a6257600080fd5b613a6a6133e8565b825182811115613a7957600080fd5b613a85878286016138f3565b825250602083015182811115613a9a57600080fd5b613aa6878286016138f3565b6020830152506040830151604082015260608301516060820152608083015182811115613ad257600080fd5b613ade87828601613938565b60808301525095945050505050565b6000808454613afb8161357d565b60018281168015613b135760018114613b4657613b75565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450613b75565b8860005260208060002060005b85811015613b6c5781548a820152908401908201613b53565b50505082870194505b507f2f00000000000000000000000000000000000000000000000000000000000000845286519250613bad8382860160208a01612fd0565b919092010195945050505050565b8181038181111561069a5761069a6135d0565b8082018082111561069a5761069a6135d0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b82815260406020820152600061182d6040830184612ff4565b60008251613c3b818460208701612fd0565b9190910192915050565b600060208284031215613c5757600080fd5b81516113fc81612f85565b600060208284031215613c7457600080fd5b6113fc82613210565b805160208083015191908110156135ca577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60209190910360031b1b16919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613cf057613cf06135d0565b5060010190565b600082613d0657613d06613616565b500690565b7f4d696e742861646472657373206d696e746572416464726573732c75696e743281527f353620746f74616c436f73742c75696e74323536206578706972657341742c5460208201527f6f6b656e446174615b5d20746f6b656e44617461417272617929000000000000604082015260008251613d8f81605a850160208701612fd0565b91909101605a0192915050565b815160009082906020808601845b83811015613dc657815185529382019390820190600101613daa565b50929695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152613e116080830184612ff4565b969550505050505056fe546f6b656e446174612875696e74333220617274696661637449642c75696e743332207769746368496429a2646970667358221220022fdd079c4c3ff68a5df771106ee8b05645682a9d43881d3e9ff11a196f2e3064736f6c634300081100330000000000000000000000005b25c96ab32ea30504494c0b812f93d6d2d5ce000000000000000000000000001cca4e4dd174750dff60670da08f410665d49a1f0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000003268747470733a2f2f63727970746f636f76656e2e78797a2f6170692f6875742f6172746966616374732f6d657461646174610000000000000000000000000000

Deployed Bytecode

0x6080604052600436106101e35760003560e01c806370a0823111610102578063a22cb46511610095578063d2d65ff511610064578063d2d65ff5146105b7578063e74772d8146105d7578063e985e9c514610604578063f2fde38b1461062457600080fd5b8063a22cb4651461052a578063a758e1d31461054a578063b88d4fde14610577578063c87b56dd1461059757600080fd5b80637afe2b3b116100d15780637afe2b3b146104aa57806389476069146104ca5780638da5cb5b146104ea57806395d89b411461051557600080fd5b806370a082311461044d578063714c53981461046d578063715018a614610482578063744b59921461049757600080fd5b806337a78ff31161017a5780635232ac35116101495780635232ac35146103d357806355f804b3146103f3578063564566a8146104135780636352211e1461042d57600080fd5b806337a78ff3146103515780633ccfd60b1461037e57806342842e0e146103935780634d74d3b4146103b357600080fd5b806318160ddd116101b657806318160ddd146102a6578063210cd92d146102c557806323b872dd146102e55780632a55205a1461030557600080fd5b806301ffc9a7146101e857806306fdde031461021d578063081812fc1461023f578063095ea7b314610284575b600080fd5b3480156101f457600080fd5b50610208610203366004612fb3565b610644565b60405190151581526020015b60405180910390f35b34801561022957600080fd5b506102326106a0565b604051610214919061303e565b34801561024b57600080fd5b5061025f61025a366004613051565b610732565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610214565b34801561029057600080fd5b506102a461029f36600461308c565b610821565b005b3480156102b257600080fd5b506007545b604051908152602001610214565b3480156102d157600080fd5b506102a46102e03660046130b8565b6109ad565b3480156102f157600080fd5b506102a46103003660046130d5565b610a75565b34801561031157600080fd5b50610325610320366004613116565b610b16565b6040805173ffffffffffffffffffffffffffffffffffffffff9093168352602083019190915201610214565b34801561035d57600080fd5b50600c5461025f9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561038a57600080fd5b506102a4610bbf565b34801561039f57600080fd5b506102a46103ae3660046130d5565b610d38565b3480156103bf57600080fd5b506102a46103ce3660046130b8565b610d53565b3480156103df57600080fd5b506102a46103ee366004613146565b610e1b565b3480156103ff57600080fd5b506102a461040e366004613163565b610ee6565b34801561041f57600080fd5b506009546102089060ff1681565b34801561043957600080fd5b5061025f610448366004613051565b610f74565b34801561045957600080fd5b506102b76104683660046130b8565b611036565b34801561047957600080fd5b50610232611104565b34801561048e57600080fd5b506102a4611113565b6102a46104a53660046131d5565b6111a0565b3480156104b657600080fd5b506102b76104c536600461322b565b6113db565b3480156104d657600080fd5b506102a46104e53660046130b8565b611403565b3480156104f657600080fd5b5060065473ffffffffffffffffffffffffffffffffffffffff1661025f565b34801561052157600080fd5b506102326115e8565b34801561053657600080fd5b506102a4610545366004613270565b6115f7565b34801561055657600080fd5b5061056a610565366004613051565b61170d565b60405161021491906132a9565b34801561058357600080fd5b506102a46105923660046134a0565b611835565b3480156105a357600080fd5b506102326105b2366004613051565b6118dd565b3480156105c357600080fd5b506102a46105d2366004613146565b6119a6565b3480156105e357600080fd5b50600b5461025f9073ffffffffffffffffffffffffffffffffffffffff1681565b34801561061057600080fd5b5061020861061f36600461354f565b611a58565b34801561063057600080fd5b506102a461063f3660046130b8565b611af7565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a00000000000000000000000000000000000000000000000000000000148061069a575061069a82611c27565b92915050565b6060600080546106af9061357d565b80601f01602080910402602001604051908101604052809291908181526020018280546106db9061357d565b80156107285780601f106106fd57610100808354040283529160200191610728565b820191906000526020600020905b81548152906001019060200180831161070b57829003601f168201915b5050505050905090565b6000818152600260205260408120546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff166107f8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201527f697374656e7420746f6b656e000000000000000000000000000000000000000060648201526084015b60405180910390fd5b5060009081526004602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600061082c82610f74565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108e9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084016107ef565b3373ffffffffffffffffffffffffffffffffffffffff8216148061091257506109128133611a58565b61099e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c000000000000000060648201526084016107ef565b6109a88383611d0a565b505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314610a2e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600c80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b610a7f3382611daa565b610b0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107ef565b6109a8838383611e35565b60008281526002602052604081205481906c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff16610b83576040517fbce35a4700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60065473ffffffffffffffffffffffffffffffffffffffff166064610ba98560056135ff565b610bb39190613645565b915091505b9250929050565b60065473ffffffffffffffffffffffffffffffffffffffff163314610c40576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b476000819003610c7c576040517f5e6202b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080610c9e60065473ffffffffffffffffffffffffffffffffffffffff1690565b73ffffffffffffffffffffffffffffffffffffffff168360405160006040518083038185875af1925050503d8060008114610cf5576040519150601f19603f3d011682016040523d82523d6000602084013e610cfa565b606091505b5091509150816109a857806040517fdf76ce9f0000000000000000000000000000000000000000000000000000000081526004016107ef919061303e565b6109a883838360405180602001604052806000815250611835565b60065473ffffffffffffffffffffffffffffffffffffffff163314610dd4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600b80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b60065473ffffffffffffffffffffffffffffffffffffffff163314610e9c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600c805491151574010000000000000000000000000000000000000000027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60065473ffffffffffffffffffffffffffffffffffffffff163314610f67576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b60086109a88284836136a7565b6000818152600260205260408120546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff168061069a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201527f656e7420746f6b656e000000000000000000000000000000000000000000000060648201526084016107ef565b600073ffffffffffffffffffffffffffffffffffffffff82166110db576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560448201527f726f20616464726573730000000000000000000000000000000000000000000060648201526084016107ef565b5073ffffffffffffffffffffffffffffffffffffffff1660009081526003602052604090205490565b6060600880546106af9061357d565b60065473ffffffffffffffffffffffffffffffffffffffff163314611194576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b61119e600061209b565b565b60095460ff166111db576040517eecac0100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111e860608201826137c1565b823560208401356111fc6040860186613826565b600c5473ffffffffffffffffffffffffffffffffffffffff1661124b576040517f7223845600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b824210611284576040517f4c746c9200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006112b47fa5d81b40d1f9f923129d42342f185faadbefce113096acb435f5a27afb1289893387878787612112565b600c54604080516020601f8b018190048102820181019092528981529293506113129273ffffffffffffffffffffffffffffffffffffffff9092169184918b908b908190840183828082843760009201919091525061218692505050565b611348576040517f9a69144c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8735348114611383576040517fd6ff0e4500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b61139360408b018b613826565b90508110156113cf576113c76113ac60408c018c613826565b838181106113bc576113bc61388e565b905060400201612374565b600101611386565b50505050505050505050565b6000806113e9858585612538565b6000908152600a60205260409020549150505b9392505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314611484576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009073ffffffffffffffffffffffffffffffffffffffff8316906370a0823190602401602060405180830381865afa1580156114f1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151591906138bd565b905080600003611551576040517f5e6202b600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000081523360048201526024810182905273ffffffffffffffffffffffffffffffffffffffff83169063a9059cbb906044016020604051808303816000875af11580156115c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a891906138d6565b6060600180546106af9061357d565b3373ffffffffffffffffffffffffffffffffffffffff831603611676576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016107ef565b33600081815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61173f6040518060a0016040528060608152602001606081526020016000815260200160008152602001606081525090565b60008281526002602052604080822054600b5482517f7465ce5c00000000000000000000000000000000000000000000000000000000815265ffffffffffff8084166004830181905260248301899052660100000000000090940416604482018190529351929473ffffffffffffffffffffffffffffffffffffffff90921692637465ce5c926064808401939192918290030181865afa1580156117e7573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016820160405261182d9190810190613a24565b949350505050565b61183f3383611daa565b6118cb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656400000000000000000000000000000060648201526084016107ef565b6118d784848484612607565b50505050565b606061191d826000908152600260205260409020546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff16151590565b611953576040517fdf11708f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006008611960846126aa565b604051602001611971929190613aed565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190529392505050565b60065473ffffffffffffffffffffffffffffffffffffffff163314611a27576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b600c5460009074010000000000000000000000000000000000000000900460ff168015611aae5750731e0049783f008a0085193e00003d00cd54003c7173ffffffffffffffffffffffffffffffffffffffff8316145b15611abb5750600161069a565b5073ffffffffffffffffffffffffffffffffffffffff918216600090815260056020908152604080832093909416825291909152205460ff1690565b60065473ffffffffffffffffffffffffffffffffffffffff163314611b78576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107ef565b73ffffffffffffffffffffffffffffffffffffffff8116611c1b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107ef565b611c248161209b565b50565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd000000000000000000000000000000000000000000000000000000001480611cba57507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061069a57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461069a565b600081815260046020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff84169081179091558190611d6482610f74565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080611db683610f74565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611e2557508373ffffffffffffffffffffffffffffffffffffffff16611e0d84610732565b73ffffffffffffffffffffffffffffffffffffffff16145b8061182d575061182d8185611a58565b8273ffffffffffffffffffffffffffffffffffffffff16611e5582610f74565b73ffffffffffffffffffffffffffffffffffffffff1614611ef8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201527f73206e6f74206f776e000000000000000000000000000000000000000000000060648201526084016107ef565b73ffffffffffffffffffffffffffffffffffffffff8216611f9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f726573730000000000000000000000000000000000000000000000000000000060648201526084016107ef565b611fa5600082611d0a565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600360205260408120805460019290611fdb908490613bbb565b909155505073ffffffffffffffffffffffffffffffffffffffff82166000908152600360205260408120805460019290612016908490613bce565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff8087166c0100000000000000000000000081026bffffffffffffffffffffffff9093169290921790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6006805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008061212287878787876127df565b604080517f1901000000000000000000000000000000000000000000000000000000000000602080830191909152602282018c9052604280830185905283518084039091018152606290920190925280519101209091505b98975050505050505050565b6000806000612195858561294b565b909250905060008160048111156121ae576121ae613be1565b1480156121e657508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b156121f6576001925050506113fc565b6000808773ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b888860405160240161222b929190613c10565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516122b49190613c29565b600060405180830381855afa9150503d80600081146122ef576040519150601f19603f3d011682016040523d82523d6000602084013e6122f4565b606091505b5091509150818015612307575080516020145b801561217a575080517f1626ba7e00000000000000000000000000000000000000000000000000000000906123459083016020908101908401613c45565b7fffffffff00000000000000000000000000000000000000000000000000000000161498975050505050505050565b8060006123983361238b6040850160208601613c62565b6104c56020860186613c62565b11156123d0576040517f181ede8900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600b5473ffffffffffffffffffffffffffffffffffffffff168063db9eee7d6123ff6040850160208601613c62565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e084901b16815265ffffffffffff9091166004820152602401602060405180830381865afa15801561245a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061247e91906138d6565b6124b4576040517f7c66445400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006124c7600780546001019081905590565b905060006124f1336124df6040880160208901613c62565b6124ec6020890189613c62565b612538565b6000818152600a6020908152604091829020859055919250612531913391859161251f918a01908a01613c62565b61252c60208a018a613c62565b6129b6565b5050505050565b600065ffffffffffff8216156125a4576040517fffffffffffff000000000000000000000000000000000000000000000000000060d084811b8216602084015285901b166026820152602c015b60405160208183030381529060405261259d90613c7d565b90506113fc565b6040517fffffffffffffffffffffffffffffffffffffffff000000000000000000000000606086901b1660208201527fffffffffffff000000000000000000000000000000000000000000000000000060d085901b166034820152603a01612585565b612612848484611e35565b61261e84848484612bb0565b6118d7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016107ef565b6060816000036126ed57505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612717578061270181613cbf565b91506127109050600a83613645565b91506126f1565b60008167ffffffffffffffff81111561273257612732613390565b6040519080825280601f01601f19166020018201604052801561275c576020820181803683370190505b5090505b841561182d57612771600183613bbb565b915061277e600a86613cf7565b612789906030613bce565b60f81b81838151811061279e5761279e61388e565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506127d8600a86613645565b9450612760565b6000808267ffffffffffffffff8111156127fb576127fb613390565b604051908082528060200260200182016040528015612824578160200160208202803683370190505b50905060005b83811015612877576128528585838181106128475761284761388e565b905060400201612da3565b8282815181106128645761286461388e565b602090810291909101015260010161282a565b506040518060600160405280602b8152602001613e1c602b91396040516020016128a19190613d0b565b60405160208183030381529060405280519060200120878787846040516020016128cb9190613d9c565b6040516020818303038152906040528051906020012060405160200161292995949392919094855273ffffffffffffffffffffffffffffffffffffffff93909316602085015260408401919091526060830152608082015260a00190565b6040516020818303038152906040528051906020012091505095945050505050565b60008082516041036129815760208301516040840151606085015160001a61297587828585612e25565b94509450505050610bb8565b82516040036129aa576020830151604084015161299f868383612f3d565b935093505050610bb8565b50600090506002610bb8565b73ffffffffffffffffffffffffffffffffffffffff8416612a33576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107ef565b6000838152600260205260409020546c01000000000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1615612acf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016107ef565b73ffffffffffffffffffffffffffffffffffffffff84166000908152600360205260408120805460019290612b05908490613bce565b909155505060008381526002602052604080822065ffffffffffff84811666010000000000000273ffffffffffffffffffffffffffffffffffffffff89166c0100000000000000000000000081027fffffffffffffffffffffffffffffffffffffffff00000000000000000000000016928816929092171790915590518592907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a450505050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15612d98576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290612c27903390899088908890600401613dd2565b6020604051808303816000875af1925050508015612c80575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612c7d91810190613c45565b60015b612d4d573d808015612cae576040519150601f19603f3d011682016040523d82523d6000602084013e612cb3565b606091505b508051600003612d45576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e746572000000000000000000000000000060648201526084016107ef565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a020000000000000000000000000000000000000000000000000000000014905061182d565b506001949350505050565b60006040518060600160405280602b8152602001613e1c602b913980519060200120826020016020810190612dd89190613c62565b612de56020850185613c62565b60408051602081019490945265ffffffffffff92831690840152166060820152608001604051602081830303815290604052805190602001209050919050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612e5c5750600090506003612f34565b8460ff16601b14158015612e7457508460ff16601c14155b15612e855750600090506004612f34565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612ed9573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116612f2d57600060019250925050612f34565b9150600090505b94509492505050565b6000807f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff831660ff84901c601b01612f7787828885612e25565b935093505050935093915050565b7fffffffff0000000000000000000000000000000000000000000000000000000081168114611c2457600080fd5b600060208284031215612fc557600080fd5b81356113fc81612f85565b60005b83811015612feb578181015183820152602001612fd3565b50506000910152565b6000815180845261300c816020860160208601612fd0565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006113fc6020830184612ff4565b60006020828403121561306357600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff81168114611c2457600080fd5b6000806040838503121561309f57600080fd5b82356130aa8161306a565b946020939093013593505050565b6000602082840312156130ca57600080fd5b81356113fc8161306a565b6000806000606084860312156130ea57600080fd5b83356130f58161306a565b925060208401356131058161306a565b929592945050506040919091013590565b6000806040838503121561312957600080fd5b50508035926020909101359150565b8015158114611c2457600080fd5b60006020828403121561315857600080fd5b81356113fc81613138565b6000806020838503121561317657600080fd5b823567ffffffffffffffff8082111561318e57600080fd5b818501915085601f8301126131a257600080fd5b8135818111156131b157600080fd5b8660208285010111156131c357600080fd5b60209290920196919550909350505050565b6000602082840312156131e757600080fd5b813567ffffffffffffffff8111156131fe57600080fd5b8201608081850312156113fc57600080fd5b803565ffffffffffff8116811461322657600080fd5b919050565b60008060006060848603121561324057600080fd5b833561324b8161306a565b925061325960208501613210565b915061326760408501613210565b90509250925092565b6000806040838503121561328357600080fd5b823561328e8161306a565b9150602083013561329e81613138565b809150509250929050565b60006020808352835160a0828501526132c560c0850182612ff4565b9050818501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe060408187850301818801526133018484612ff4565b93508088015160608801526060880151608088015260808801519250818785030160a08801528383518086528686019150868160051b870101878601955060005b8281101561338157858883030184528651805186845261336487850182612ff4565b918b0151938b019390935296890196938901939150600101613342565b509a9950505050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156133e2576133e2613390565b60405290565b60405160a0810167ffffffffffffffff811182821017156133e2576133e2613390565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561345257613452613390565b604052919050565b600067ffffffffffffffff82111561347457613474613390565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600080600080608085870312156134b657600080fd5b84356134c18161306a565b935060208501356134d18161306a565b925060408501359150606085013567ffffffffffffffff8111156134f457600080fd5b8501601f8101871361350557600080fd5b80356135186135138261345a565b61340b565b81815288602083850101111561352d57600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6000806040838503121561356257600080fd5b823561356d8161306a565b9150602083013561329e8161306a565b600181811c9082168061359157607f821691505b6020821081036135ca577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b808202811582820484141761069a5761069a6135d0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60008261365457613654613616565b500490565b601f8211156109a857600081815260208120601f850160051c810160208610156136805750805b601f850160051c820191505b8181101561369f5782815560010161368c565b505050505050565b67ffffffffffffffff8311156136bf576136bf613390565b6136d3836136cd835461357d565b83613659565b6000601f84116001811461372557600085156136ef5750838201355b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600387901b1c1916600186901b178355612531565b6000838152602090207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0861690835b828110156137745786850135825560209485019460019092019101613754565b50868210156137af577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88860031b161c19848701351681555b505060018560011b0183555050505050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126137f657600080fd5b83018035915067ffffffffffffffff82111561381157600080fd5b602001915036819003821315610bb857600080fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261385b57600080fd5b83018035915067ffffffffffffffff82111561387657600080fd5b6020019150600681901b3603821315610bb857600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000602082840312156138cf57600080fd5b5051919050565b6000602082840312156138e857600080fd5b81516113fc81613138565b600082601f83011261390457600080fd5b81516139126135138261345a565b81815284602083860101111561392757600080fd5b61182d826020830160208701612fd0565b600082601f83011261394957600080fd5b8151602067ffffffffffffffff8083111561396657613966613390565b8260051b61397583820161340b565b938452858101830193838101908886111561398f57600080fd5b84880192505b8583101561217a578251848111156139ad5760008081fd5b88016040818b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018113156139e35760008081fd5b6139eb6133bf565b87830151878111156139fd5760008081fd5b613a0b8d8a838701016138f3565b8252509101518682015282529184019190840190613995565b600060208284031215613a3657600080fd5b815167ffffffffffffffff80821115613a4e57600080fd5b9083019060a08286031215613a6257600080fd5b613a6a6133e8565b825182811115613a7957600080fd5b613a85878286016138f3565b825250602083015182811115613a9a57600080fd5b613aa6878286016138f3565b6020830152506040830151604082015260608301516060820152608083015182811115613ad257600080fd5b613ade87828601613938565b60808301525095945050505050565b6000808454613afb8161357d565b60018281168015613b135760018114613b4657613b75565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0084168752821515830287019450613b75565b8860005260208060002060005b85811015613b6c5781548a820152908401908201613b53565b50505082870194505b507f2f00000000000000000000000000000000000000000000000000000000000000845286519250613bad8382860160208a01612fd0565b919092010195945050505050565b8181038181111561069a5761069a6135d0565b8082018082111561069a5761069a6135d0565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b82815260406020820152600061182d6040830184612ff4565b60008251613c3b818460208701612fd0565b9190910192915050565b600060208284031215613c5757600080fd5b81516113fc81612f85565b600060208284031215613c7457600080fd5b6113fc82613210565b805160208083015191908110156135ca577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60209190910360031b1b16919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203613cf057613cf06135d0565b5060010190565b600082613d0657613d06613616565b500690565b7f4d696e742861646472657373206d696e746572416464726573732c75696e743281527f353620746f74616c436f73742c75696e74323536206578706972657341742c5460208201527f6f6b656e446174615b5d20746f6b656e44617461417272617929000000000000604082015260008251613d8f81605a850160208701612fd0565b91909101605a0192915050565b815160009082906020808601845b83811015613dc657815185529382019390820190600101613daa565b50929695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152613e116080830184612ff4565b969550505050505056fe546f6b656e446174612875696e74333220617274696661637449642c75696e743332207769746368496429a2646970667358221220022fdd079c4c3ff68a5df771106ee8b05645682a9d43881d3e9ff11a196f2e3064736f6c63430008110033

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

0000000000000000000000005b25c96ab32ea30504494c0b812f93d6d2d5ce000000000000000000000000001cca4e4dd174750dff60670da08f410665d49a1f0000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000003268747470733a2f2f63727970746f636f76656e2e78797a2f6170692f6875742f6172746966616374732f6d657461646174610000000000000000000000000000

-----Decoded View---------------
Arg [0] : _metadataContractAddress (address): 0x5b25C96AB32eA30504494c0b812F93D6d2d5ce00
Arg [1] : _narratorAddress (address): 0x1CCa4E4Dd174750dFF60670dA08f410665D49A1F
Arg [2] : _baseURI (string): https://cryptocoven.xyz/api/hut/artifacts/metadata

-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000005b25c96ab32ea30504494c0b812f93d6d2d5ce00
Arg [1] : 0000000000000000000000001cca4e4dd174750dff60670da08f410665d49a1f
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000032
Arg [4] : 68747470733a2f2f63727970746f636f76656e2e78797a2f6170692f6875742f
Arg [5] : 6172746966616374732f6d657461646174610000000000000000000000000000


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

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