ETH Price: $3,050.33 (+1.35%)
Gas: 3 Gwei

Contract

0x4073B2c539Ca2a3cBe21A583EAe4B41f2d3e25EC
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x60806040169979252023-04-07 16:55:23457 days ago1680886523IN
 Create: ProjectEnvision
0 ETH0.1170623334.94359359

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ProjectEnvision

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 32 : ProjectEnvision.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {ERC721AQueryableUpgradeable, ERC721AUpgradeable, IERC721AUpgradeable} from "@erc721a-upgradable/extensions/ERC721AQueryableUpgradeable.sol";
import {Ownable} from "@solidstate-solidity/access/ownable/Ownable.sol";
import {AddressUtils} from "@solidstate-solidity/utils/AddressUtils.sol";
import {ERC2981, IERC2981} from "@solidstate-solidity/token/common/ERC2981/ERC2981.sol";
import {IERC165} from "@solidstate-solidity/interfaces/IERC165.sol";
import {IERC20} from "@solidstate-solidity/interfaces/IERC20.sol";
import {ERC2981Storage} from "@solidstate-solidity/token/common/ERC2981/ERC2981Storage.sol";
import {OperatorFilterer} from "@closedsea/OperatorFilterer.sol";
import {ECDSA} from "@solady/utils/ECDSA.sol";
import {ITokenWrapper} from "./interfaces/ITokenWrapper.sol";
import {IProjectEnvision} from "./interfaces/IProjectEnvision.sol";
import {ProjectEnvisionStorage} from "./ProjectEnvisionStorage.sol";
import {IERC4906} from "./interfaces/IERC4906.sol";

contract ProjectEnvision is
    ERC2981,
    IERC4906,
    IProjectEnvision,
    ERC721AQueryableUpgradeable,
    OperatorFilterer,
    Ownable
{
    using ECDSA for bytes32;

    /// @notice Maximum supply
    uint256 public constant MAX_SUPPLY = 5500;

    /**
     * @notice Initialize the implementation
     */
    function initialize(string memory uri) public initializerERC721A {
        __ERC721A_init("Project Envision", "PE");
        __ERC721AQueryable_init();
        _registerForOperatorFiltering();
        setBaseUri(uri);
        setMaxMintQuantity(3, 2, 2);
        setMintPrices(0.035 ether, 0.038 ether, 0.042 ether);
        updateRoyalty(address(this), 500);
    }

    /**
     * @dev Randomness function. Intelligent people can maybe *cough* determine things
     */
    function _coinToss(
        uint256 seed,
        uint256 index
    ) private view returns (uint) {
        bytes32 blockHash = blockhash(block.number - 1);
        require(blockHash != bytes32(0), "Block Hash Fail");
        uint random = uint(
            keccak256(
                abi.encodePacked(
                    block.timestamp,
                    address(this),
                    address(this).balance,
                    blockHash,
                    seed,
                    index
                )
            )
        );
        return random % 100;
    }

    /**
     * @notice Burn many nfts at once
     */
    function burnMany(uint256[] calldata tokenIds) public {
        uint256 lastResult;
        for (uint s; s < tokenIds.length; ++s) {
            lastResult = _generateBones(tokenIds[s], lastResult);
        }
    }

    /**
     * @notice Burn one nft at a time
     */
    function burn(uint256 tokenId) public {
        _generateBones(tokenId, 0);
    }

    /**
     * @dev Generate a bone for a token
     */
    function _generateBones(
        uint256 tokenId,
        uint256 seed
    ) private returns (uint256) {
        require(_exists(tokenId), "Token Burnt");
        require(ownerOf(tokenId) == msg.sender, "Not Owner");
        require(!isTokenBone(tokenId), "Already Bone");
        require(!isTokenSummoned(tokenId), "Prohibited");
        uint256 result = _coinToss(seed, tokenId);
        if (result < 50) {
            ProjectEnvisionStorage.layout().boned[tokenId] = true;
            emit MetadataUpdate(tokenId);
        } else {
            _burn(tokenId);
        }
        return result;
    }

    /**
     * @notice Summon single
     */
    function summon(
        uint256 tokenId,
        uint256 bones,
        bytes calldata signature
    ) public {
        bytes32 data = keccak256(abi.encodePacked(tokenId, bones));
        address signer = data.toEthSignedMessageHash().recover(signature);
        require(ProjectEnvisionStorage.layout().signer == signer, "Bad Bone");
        require(ownerOf(tokenId) == msg.sender, "Not Owner");
        require(isTokenBone(tokenId), "Not Bone");
        require(!isTokenSummoned(tokenId), "Already Summoned");
        _burn(tokenId);
        uint256 totalMinted = _totalMinted();
        emit BatchMetadataUpdate(totalMinted + 1, totalMinted + bones);
        _mint(msg.sender, bones);
    }

    /**
     * @notice Summon many
     */
    function summonMany(
        uint256[] calldata tokenIds,
        uint256[] calldata bones,
        bytes[] calldata signatures
    ) public {
        require(
            tokenIds.length == bones.length &&
                tokenIds.length == signatures.length,
            "Mismatch"
        );
        for (uint256 i; i < tokenIds.length; ++i) {
            summon(tokenIds[i], bones[i], signatures[i]);
        }
    }

    /**
     * @notice Total sacrificed
     */
    function sacrificed() public view returns (uint256) {
        uint256 count;
        for (uint256 i = _startTokenId(); i <= MAX_SUPPLY; i++) {
            if (!_exists(i)) {
                count++;
            }
        }
        return count;
    }

    /**
     * @notice Summoned
     */
    function summoned() public view returns (uint256) {
        uint256 count;
        for (uint256 i = MAX_SUPPLY + 1; ; i++) {
            if (!_exists(i)) {
                break;
            }
            count++;
        }
        return count;
    }

    /**
     * @notice Inform if token ids are burnt
     */
    function getTokenState(
        uint256[] memory tokenIds
    ) public returns (bool[] memory, bool[] memory) {
        bool[] memory boned = new bool[](tokenIds.length);
        bool[] memory summoned = new bool[](tokenIds.length);
        for (uint256 i; i < tokenIds.length; i++) {
            boned[i] = isTokenBone(tokenIds[i]);
            summoned[i] = tokenIds[i] > MAX_SUPPLY;
        }
        return (boned, summoned);
    }

    /**
     * @notice Check if a token is a bone
     */
    function isTokenBone(uint256 tokenId) public view returns (bool) {
        return ProjectEnvisionStorage.layout().boned[tokenId];
    }

    /**
     * @notice Check if a token is a bone
     */
    function isTokenSummoned(uint256 tokenId) public view returns (bool) {
        return tokenId > MAX_SUPPLY && _exists(tokenId);
    }

    /**
     * @dev Prevent overshooting supply
     */
    modifier onlyUnsold(uint256 qty) {
        require(_totalMinted() + qty <= MAX_SUPPLY, "Above Total Supply");
        _;
    }

    /**
     * @notice Admin mint to a wallet
     */
    function mintAsAdmin(
        address recipient,
        uint256 quantity
    ) public onlyOwner onlyUnsold(quantity) {
        _mint(recipient, quantity);
    }

    /**
     * @notice Set the base token URI
     */
    function setBaseUri(string memory baseURI_) public onlyOwner {
        ProjectEnvisionStorage.layout().baseURI = baseURI_;
    }

    /**
     * @notice Set the bone token URI
     */
    function setBoneUri(string memory boneURI_) public onlyOwner {
        ProjectEnvisionStorage.layout().boneURI = boneURI_;
    }

    /**
     * @notice Set the bone token URI
     */
    function setSummonUri(string memory summonURI_) public onlyOwner {
        ProjectEnvisionStorage.layout().summonURI = summonURI_;
    }

    /**
     * @notice Set the signer
     */
    function setSigner(address signer) public onlyOwner {
        ProjectEnvisionStorage.layout().signer = signer;
    }

    /**
     * @dev Base token URI
     */
    function _baseURI() internal view virtual override returns (string memory) {
        return ProjectEnvisionStorage.layout().baseURI;
    }

    /**
     * @notice Return the token URI for an NFT
     * @param tokenId Token ID
     */
    function tokenURI(
        uint256 tokenId
    )
        public
        view
        virtual
        override(ERC721AUpgradeable, IERC721AUpgradeable)
        returns (string memory)
    {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
        string memory baseURI = isTokenSummoned(tokenId)
            ? ProjectEnvisionStorage.layout().summonURI
            : (
                isTokenBone(tokenId)
                    ? ProjectEnvisionStorage.layout().boneURI
                    : _baseURI()
            );
        string memory result = string(
            abi.encodePacked(baseURI, _toString(tokenId), ".json")
        );
        return bytes(baseURI).length != 0 ? result : "";
    }

    /**
     * @notice Set the maximum mints per wallet
     * @param ogQty Maximum quantity for og
     * @param whitelistQty Maximum quantity for whitelist
     * @param publicQty Maximum quantity for public
     */
    function setMaxMintQuantity(
        uint64 ogQty,
        uint64 whitelistQty,
        uint64 publicQty
    ) public onlyOwner {
        ProjectEnvisionStorage.layout().ogMaxMint = ogQty;
        ProjectEnvisionStorage.layout().whitelistMaxMint = whitelistQty;
        ProjectEnvisionStorage.layout().publicMaxMint = publicQty;
    }

    /**
     * @notice Set the mint prices
     */
    function setMintPrices(
        uint256 ogPrice,
        uint256 whitelistPrice,
        uint256 publicPrice
    ) public onlyOwner {
        ProjectEnvisionStorage.layout().ogPrice = ogPrice;
        ProjectEnvisionStorage.layout().publicPrice = publicPrice;
        ProjectEnvisionStorage.layout().whitelistPrice = whitelistPrice;
    }

    /**
     * @notice Return the prices for each part of the sale
     */
    function getSaleState()
        public
        view
        returns (uint64, uint64, uint64, uint256, uint256, uint256)
    {
        return (
            ProjectEnvisionStorage.layout().ogMaxMint,
            ProjectEnvisionStorage.layout().whitelistMaxMint,
            ProjectEnvisionStorage.layout().publicMaxMint,
            ProjectEnvisionStorage.layout().ogPrice,
            ProjectEnvisionStorage.layout().whitelistPrice,
            ProjectEnvisionStorage.layout().publicPrice
        );
    }

    /**
     * @notice Sets the royalty percentage
     */
    function updateRoyalty(
        address defaultRoyaltyReceiver,
        uint16 defaultRoyaltyBPS
    ) public onlyOwner {
        ERC2981Storage.Layout storage l = ERC2981Storage.layout();
        l.defaultRoyaltyReceiver = defaultRoyaltyReceiver;
        l.defaultRoyaltyBPS = defaultRoyaltyBPS;
    }

    /**
     * @dev Returns the starting token ID.
     */
    function _startTokenId()
        internal
        view
        virtual
        override(ERC721AUpgradeable)
        returns (uint256)
    {
        return 1;
    }

    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    )
        public
        payable
        override(ERC721AUpgradeable, IERC721AUpgradeable)
        onlyAllowedOperator(from)
    {
        super.transferFrom(from, to, tokenId);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    )
        public
        payable
        override(ERC721AUpgradeable, IERC721AUpgradeable)
        onlyAllowedOperator(from)
    {
        super.safeTransferFrom(from, to, tokenId);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    )
        public
        payable
        override(ERC721AUpgradeable, IERC721AUpgradeable)
        onlyAllowedOperator(from)
    {
        super.safeTransferFrom(from, to, tokenId, data);
    }

    /**
     * @notice Withdraw ETH from contract
     */
    function withdraw() external onlyOwner {
        _withdraw();
    }

    function _withdraw() private {
        uint256 balance = address(this).balance;
        AddressUtils.sendValue(
            payable(0x0dB4bcD94e2F64cEC5a7a87c943a4bf5A51D5436),
            (balance * 40) / 100
        );
        AddressUtils.sendValue(
            payable(0xb397C5bE1E8fE89fb269801e636e278E5A6D7d31),
            (balance * 40) / 100
        );
        AddressUtils.sendValue(
            payable(0xb7419b10A2973384B0390a525Ab84465d4c72ee1),
            (balance * 20) / 100
        );
    }

    function fundDeployer(uint256 amount) external onlyOwner {
        require(amount <= 1 ether);
        AddressUtils.sendValue(payable(owner()), amount);
    }

    function withdrawEverything() external onlyOwner {
        ITokenWrapper wrappedEther = ITokenWrapper(
            0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
        );
        uint256 wethBalance = wrappedEther.balanceOf(address(this));
        if (wethBalance > 0) {
            wrappedEther.withdraw(wethBalance);
        }
        ITokenWrapper blur = ITokenWrapper(
            0x0000000000A39bb272e79075ade125fd351887Ac
        );
        uint256 blurBalance = blur.balanceOf(address(this));
        if (blurBalance > 0) {
            blur.withdraw(blurBalance);
        }
        _withdraw();
    }

    /**
     * @dev Add support for EIPs
     */
    function supportsInterface(
        bytes4 interfaceId
    )
        public
        view
        virtual
        override(ERC721AUpgradeable, IERC721AUpgradeable, IERC165)
        returns (bool)
    {
        return
            interfaceId == 0x2a55205a ||
            interfaceId == 0x49064906 ||
            super.supportsInterface(interfaceId);
    }

    function burnAsAdmin(uint256[] calldata tokenIds) public onlyOwner {
        for (uint256 i; i < tokenIds.length; i++) {
            _burn(tokenIds[i]);
        }
    }
}

File 2 of 32 : ERC721AStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

library ERC721AStorage {
    // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
    struct TokenApprovalRef {
        address value;
    }

    struct Layout {
        // =============================================================
        //                            STORAGE
        // =============================================================

        // The next token ID to be minted.
        uint256 _currentIndex;
        // The number of tokens burned.
        uint256 _burnCounter;
        // Token name
        string _name;
        // Token symbol
        string _symbol;
        // Mapping from token ID to ownership details
        // An empty struct value does not necessarily mean the token is unowned.
        // See {_packedOwnershipOf} implementation for details.
        //
        // Bits Layout:
        // - [0..159]   `addr`
        // - [160..223] `startTimestamp`
        // - [224]      `burned`
        // - [225]      `nextInitialized`
        // - [232..255] `extraData`
        mapping(uint256 => uint256) _packedOwnerships;
        // Mapping owner address to address data.
        //
        // Bits Layout:
        // - [0..63]    `balance`
        // - [64..127]  `numberMinted`
        // - [128..191] `numberBurned`
        // - [192..255] `aux`
        mapping(address => uint256) _packedAddressData;
        // Mapping from token ID to approved address.
        mapping(uint256 => ERC721AStorage.TokenApprovalRef) _tokenApprovals;
        // Mapping from owner to operator approvals
        mapping(address => mapping(address => bool)) _operatorApprovals;
    }

    bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.ERC721A');

    function layout() internal pure returns (Layout storage l) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            l.slot := slot
        }
    }
}

File 3 of 32 : ERC721AUpgradeable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721AUpgradeable.sol';
import {ERC721AStorage} from './ERC721AStorage.sol';
import './ERC721A__Initializable.sol';

/**
 * @dev Interface of ERC721 token receiver.
 */
interface ERC721A__IERC721ReceiverUpgradeable {
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

/**
 * @title ERC721A
 *
 * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
 * Non-Fungible Token Standard, including the Metadata extension.
 * Optimized for lower gas during batch mints.
 *
 * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
 * starting from `_startTokenId()`.
 *
 * Assumptions:
 *
 * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721AUpgradeable is ERC721A__Initializable, IERC721AUpgradeable {
    using ERC721AStorage for ERC721AStorage.Layout;

    // =============================================================
    //                           CONSTANTS
    // =============================================================

    // Mask of an entry in packed address data.
    uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;

    // The bit position of `numberMinted` in packed address data.
    uint256 private constant _BITPOS_NUMBER_MINTED = 64;

    // The bit position of `numberBurned` in packed address data.
    uint256 private constant _BITPOS_NUMBER_BURNED = 128;

    // The bit position of `aux` in packed address data.
    uint256 private constant _BITPOS_AUX = 192;

    // Mask of all 256 bits in packed address data except the 64 bits for `aux`.
    uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;

    // The bit position of `startTimestamp` in packed ownership.
    uint256 private constant _BITPOS_START_TIMESTAMP = 160;

    // The bit mask of the `burned` bit in packed ownership.
    uint256 private constant _BITMASK_BURNED = 1 << 224;

    // The bit position of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;

    // The bit mask of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;

    // The bit position of `extraData` in packed ownership.
    uint256 private constant _BITPOS_EXTRA_DATA = 232;

    // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
    uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;

    // The mask of the lower 160 bits for addresses.
    uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;

    // The maximum `quantity` that can be minted with {_mintERC2309}.
    // This limit is to prevent overflows on the address data entries.
    // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
    // is required to cause an overflow, which is unrealistic.
    uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;

    // The `Transfer` event signature is given by:
    // `keccak256(bytes("Transfer(address,address,uint256)"))`.
    bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    // =============================================================
    //                          CONSTRUCTOR
    // =============================================================

    function __ERC721A_init(string memory name_, string memory symbol_) internal onlyInitializingERC721A {
        __ERC721A_init_unchained(name_, symbol_);
    }

    function __ERC721A_init_unchained(string memory name_, string memory symbol_) internal onlyInitializingERC721A {
        ERC721AStorage.layout()._name = name_;
        ERC721AStorage.layout()._symbol = symbol_;
        ERC721AStorage.layout()._currentIndex = _startTokenId();
    }

    // =============================================================
    //                   TOKEN COUNTING OPERATIONS
    // =============================================================

    /**
     * @dev Returns the starting token ID.
     * To change the starting token ID, please override this function.
     */
    function _startTokenId() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev Returns the next token ID to be minted.
     */
    function _nextTokenId() internal view virtual returns (uint256) {
        return ERC721AStorage.layout()._currentIndex;
    }

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than `_currentIndex - _startTokenId()` times.
        unchecked {
            return ERC721AStorage.layout()._currentIndex - ERC721AStorage.layout()._burnCounter - _startTokenId();
        }
    }

    /**
     * @dev Returns the total amount of tokens minted in the contract.
     */
    function _totalMinted() internal view virtual returns (uint256) {
        // Counter underflow is impossible as `_currentIndex` does not decrement,
        // and it is initialized to `_startTokenId()`.
        unchecked {
            return ERC721AStorage.layout()._currentIndex - _startTokenId();
        }
    }

    /**
     * @dev Returns the total number of tokens burned.
     */
    function _totalBurned() internal view virtual returns (uint256) {
        return ERC721AStorage.layout()._burnCounter;
    }

    // =============================================================
    //                    ADDRESS DATA OPERATIONS
    // =============================================================

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        return ERC721AStorage.layout()._packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return
            (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens burned by or on behalf of `owner`.
     */
    function _numberBurned(address owner) internal view returns (uint256) {
        return
            (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     */
    function _getAux(address owner) internal view returns (uint64) {
        return uint64(ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_AUX);
    }

    /**
     * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     * If there are multiple variables, please pack them into a uint64.
     */
    function _setAux(address owner, uint64 aux) internal virtual {
        uint256 packed = ERC721AStorage.layout()._packedAddressData[owner];
        uint256 auxCasted;
        // Cast `aux` with assembly to avoid redundant masking.
        assembly {
            auxCasted := aux
        }
        packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
        ERC721AStorage.layout()._packedAddressData[owner] = packed;
    }

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        // The interface IDs are constants representing the first 4 bytes
        // of the XOR of all function selectors in the interface.
        // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
        // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
        return
            interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
            interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
            interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
    }

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

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

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() public view virtual override returns (string memory) {
        return ERC721AStorage.layout()._symbol;
    }

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

        string memory baseURI = _baseURI();
        return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
    }

    /**
     * @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, it can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return '';
    }

    // =============================================================
    //                     OWNERSHIPS OPERATIONS
    // =============================================================

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return address(uint160(_packedOwnershipOf(tokenId)));
    }

    /**
     * @dev Gas spent here starts off proportional to the maximum mint batch size.
     * It gradually moves to O(1) as tokens get transferred around over time.
     */
    function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnershipOf(tokenId));
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct at `index`.
     */
    function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(ERC721AStorage.layout()._packedOwnerships[index]);
    }

    /**
     * @dev Initializes the ownership slot minted at `index` for efficiency purposes.
     */
    function _initializeOwnershipAt(uint256 index) internal virtual {
        if (ERC721AStorage.layout()._packedOwnerships[index] == 0) {
            ERC721AStorage.layout()._packedOwnerships[index] = _packedOwnershipOf(index);
        }
    }

    /**
     * Returns the packed ownership data of `tokenId`.
     */
    function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) {
        if (_startTokenId() <= tokenId) {
            packed = ERC721AStorage.layout()._packedOwnerships[tokenId];
            // If not burned.
            if (packed & _BITMASK_BURNED == 0) {
                // If the data at the starting slot does not exist, start the scan.
                if (packed == 0) {
                    if (tokenId >= ERC721AStorage.layout()._currentIndex) revert OwnerQueryForNonexistentToken();
                    // Invariant:
                    // There will always be an initialized ownership slot
                    // (i.e. `ownership.addr != address(0) && ownership.burned == false`)
                    // before an unintialized ownership slot
                    // (i.e. `ownership.addr == address(0) && ownership.burned == false`)
                    // Hence, `tokenId` will not underflow.
                    //
                    // We can directly compare the packed value.
                    // If the address is zero, packed will be zero.
                    for (;;) {
                        unchecked {
                            packed = ERC721AStorage.layout()._packedOwnerships[--tokenId];
                        }
                        if (packed == 0) continue;
                        return packed;
                    }
                }
                // Otherwise, the data exists and is not burned. We can skip the scan.
                // This is possible because we have already achieved the target condition.
                // This saves 2143 gas on transfers of initialized tokens.
                return packed;
            }
        }
        revert OwnerQueryForNonexistentToken();
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct from `packed`.
     */
    function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
        ownership.addr = address(uint160(packed));
        ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
        ownership.burned = packed & _BITMASK_BURNED != 0;
        ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
    }

    /**
     * @dev Packs ownership data into a single uint256.
     */
    function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
            result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
        }
    }

    /**
     * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
     */
    function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
        // For branchless setting of the `nextInitialized` flag.
        assembly {
            // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
            result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
        }
    }

    // =============================================================
    //                      APPROVAL OPERATIONS
    // =============================================================

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account. See {ERC721A-_approve}.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     */
    function approve(address to, uint256 tokenId) public payable virtual override {
        _approve(to, tokenId, true);
    }

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();

        return ERC721AStorage.layout()._tokenApprovals[tokenId].value;
    }

    /**
     * @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) public virtual override {
        ERC721AStorage.layout()._operatorApprovals[_msgSenderERC721A()][operator] = approved;
        emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
    }

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return ERC721AStorage.layout()._operatorApprovals[owner][operator];
    }

    /**
     * @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. See {_mint}.
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < ERC721AStorage.layout()._currentIndex && // If within bounds,
            ERC721AStorage.layout()._packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
    }

    /**
     * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
     */
    function _isSenderApprovedOrOwner(
        address approvedAddress,
        address owner,
        address msgSender
    ) private pure returns (bool result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
            msgSender := and(msgSender, _BITMASK_ADDRESS)
            // `msgSender == owner || msgSender == approvedAddress`.
            result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
        }
    }

    /**
     * @dev Returns the storage slot and value for the approved address of `tokenId`.
     */
    function _getApprovedSlotAndAddress(uint256 tokenId)
        private
        view
        returns (uint256 approvedAddressSlot, address approvedAddress)
    {
        ERC721AStorage.TokenApprovalRef storage tokenApproval = ERC721AStorage.layout()._tokenApprovals[tokenId];
        // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
        assembly {
            approvedAddressSlot := tokenApproval.slot
            approvedAddress := sload(approvedAddressSlot)
        }
    }

    // =============================================================
    //                      TRANSFER OPERATIONS
    // =============================================================

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * 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
    ) public payable virtual override {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        // The nested ifs save around 20+ gas over a compound boolean condition.
        if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
            if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();

        if (to == address(0)) revert TransferToZeroAddress();

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // We can directly increment and decrement the balances.
            --ERC721AStorage.layout()._packedAddressData[from]; // Updates: `balance -= 1`.
            ++ERC721AStorage.layout()._packedAddressData[to]; // Updates: `balance += 1`.

            // Updates:
            // - `address` to the next owner.
            // - `startTimestamp` to the timestamp of transfering.
            // - `burned` to `false`.
            // - `nextInitialized` to `true`.
            ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData(
                to,
                _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != ERC721AStorage.layout()._currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, to, tokenId);
        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        safeTransferFrom(from, to, tokenId, '');
    }

    /**
     * @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 memory _data
    ) public payable virtual override {
        transferFrom(from, to, tokenId);
        if (to.code.length != 0)
            if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
                revert TransferToNonERC721ReceiverImplementer();
            }
    }

    /**
     * @dev Hook that is called before a set of serially-ordered token IDs
     * are about to be transferred. This includes minting.
     * And also called before burning one token.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * 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, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token IDs
     * have been transferred. This includes minting.
     * And also called after one token has been burned.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
     * transferred to `to`.
     * - When `from` is zero, `tokenId` has been minted for `to`.
     * - When `to` is zero, `tokenId` has been burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
     *
     * `from` - Previous owner of the given token ID.
     * `to` - Target address that will receive the token.
     * `tokenId` - Token ID to be transferred.
     * `_data` - Optional data to send along with the call.
     *
     * Returns whether the call correctly returned the expected magic value.
     */
    function _checkContractOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        try
            ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data)
        returns (bytes4 retval) {
            return retval == ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received.selector;
        } catch (bytes memory reason) {
            if (reason.length == 0) {
                revert TransferToNonERC721ReceiverImplementer();
            } else {
                assembly {
                    revert(add(32, reason), mload(reason))
                }
            }
        }
    }

    // =============================================================
    //                        MINT OPERATIONS
    // =============================================================

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _mint(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = ERC721AStorage.layout()._currentIndex;
        if (quantity == 0) revert MintZeroQuantity();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are incredibly unrealistic.
        // `balance` and `numberMinted` have a maximum limit of 2**64.
        // `tokenId` has a maximum limit of 2**256.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            uint256 toMasked;
            uint256 end = startTokenId + quantity;

            // Use assembly to loop and emit the `Transfer` event for gas savings.
            // The duplicated `log4` removes an extra check and reduces stack juggling.
            // The assembly, together with the surrounding Solidity code, have been
            // delicately arranged to nudge the compiler into producing optimized opcodes.
            assembly {
                // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
                toMasked := and(to, _BITMASK_ADDRESS)
                // Emit the `Transfer` event.
                log4(
                    0, // Start of data (0, since no data).
                    0, // End of data (0, since no data).
                    _TRANSFER_EVENT_SIGNATURE, // Signature.
                    0, // `address(0)`.
                    toMasked, // `to`.
                    startTokenId // `tokenId`.
                )

                // The `iszero(eq(,))` check ensures that large values of `quantity`
                // that overflows uint256 will make the loop run out of gas.
                // The compiler will optimize the `iszero` away for performance.
                for {
                    let tokenId := add(startTokenId, 1)
                } iszero(eq(tokenId, end)) {
                    tokenId := add(tokenId, 1)
                } {
                    // Emit the `Transfer` event. Similar to above.
                    log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
                }
            }
            if (toMasked == 0) revert MintToZeroAddress();

            ERC721AStorage.layout()._currentIndex = end;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * This function is intended for efficient minting only during contract creation.
     *
     * It emits only one {ConsecutiveTransfer} as defined in
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
     * instead of a sequence of {Transfer} event(s).
     *
     * Calling this function outside of contract creation WILL make your contract
     * non-compliant with the ERC721 standard.
     * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
     * {ConsecutiveTransfer} event is only permissible during contract creation.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {ConsecutiveTransfer} event.
     */
    function _mintERC2309(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = ERC721AStorage.layout()._currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();
        if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are unrealistic due to the above check for `quantity` to be below the limit.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);

            ERC721AStorage.layout()._currentIndex = startTokenId + quantity;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * See {_mint}.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal virtual {
        _mint(to, quantity);

        unchecked {
            if (to.code.length != 0) {
                uint256 end = ERC721AStorage.layout()._currentIndex;
                uint256 index = end - quantity;
                do {
                    if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
                        revert TransferToNonERC721ReceiverImplementer();
                    }
                } while (index < end);
                // Reentrancy protection.
                if (ERC721AStorage.layout()._currentIndex != end) revert();
            }
        }
    }

    /**
     * @dev Equivalent to `_safeMint(to, quantity, '')`.
     */
    function _safeMint(address to, uint256 quantity) internal virtual {
        _safeMint(to, quantity, '');
    }

    // =============================================================
    //                       APPROVAL OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_approve(to, tokenId, false)`.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _approve(to, tokenId, false);
    }

    /**
     * @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:
     *
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function _approve(
        address to,
        uint256 tokenId,
        bool approvalCheck
    ) internal virtual {
        address owner = ownerOf(tokenId);

        if (approvalCheck)
            if (_msgSenderERC721A() != owner)
                if (!isApprovedForAll(owner, _msgSenderERC721A())) {
                    revert ApprovalCallerNotOwnerNorApproved();
                }

        ERC721AStorage.layout()._tokenApprovals[tokenId].value = to;
        emit Approval(owner, to, tokenId);
    }

    // =============================================================
    //                        BURN OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_burn(tokenId, false)`.
     */
    function _burn(uint256 tokenId) internal virtual {
        _burn(tokenId, false);
    }

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

        address from = address(uint160(prevOwnershipPacked));

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        if (approvalCheck) {
            // The nested ifs save around 20+ gas over a compound boolean condition.
            if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
                if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
        }

        _beforeTokenTransfers(from, address(0), tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // Updates:
            // - `balance -= 1`.
            // - `numberBurned += 1`.
            //
            // We can directly decrement the balance, and increment the number burned.
            // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
            ERC721AStorage.layout()._packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;

            // Updates:
            // - `address` to the last owner.
            // - `startTimestamp` to the timestamp of burning.
            // - `burned` to `true`.
            // - `nextInitialized` to `true`.
            ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData(
                from,
                (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != ERC721AStorage.layout()._currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, address(0), tokenId);
        _afterTokenTransfers(from, address(0), tokenId, 1);

        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
        unchecked {
            ERC721AStorage.layout()._burnCounter++;
        }
    }

    // =============================================================
    //                     EXTRA DATA OPERATIONS
    // =============================================================

    /**
     * @dev Directly sets the extra data for the ownership data `index`.
     */
    function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
        uint256 packed = ERC721AStorage.layout()._packedOwnerships[index];
        if (packed == 0) revert OwnershipNotInitializedForExtraData();
        uint256 extraDataCasted;
        // Cast `extraData` with assembly to avoid redundant masking.
        assembly {
            extraDataCasted := extraData
        }
        packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
        ERC721AStorage.layout()._packedOwnerships[index] = packed;
    }

    /**
     * @dev Called during each token transfer to set the 24bit `extraData` field.
     * Intended to be overridden by the cosumer contract.
     *
     * `previousExtraData` - the value of `extraData` before transfer.
     *
     * 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, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _extraData(
        address from,
        address to,
        uint24 previousExtraData
    ) internal view virtual returns (uint24) {}

    /**
     * @dev Returns the next extra data for the packed ownership data.
     * The returned result is shifted into position.
     */
    function _nextExtraData(
        address from,
        address to,
        uint256 prevOwnershipPacked
    ) private view returns (uint256) {
        uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
        return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
    }

    // =============================================================
    //                       OTHER OPERATIONS
    // =============================================================

    /**
     * @dev Returns the message sender (defaults to `msg.sender`).
     *
     * If you are writing GSN compatible contracts, you need to override this function.
     */
    function _msgSenderERC721A() internal view virtual returns (address) {
        return msg.sender;
    }

    /**
     * @dev Converts a uint256 to its ASCII string decimal representation.
     */
    function _toString(uint256 value) internal pure virtual returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but
            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
            // We will need 1 word for the trailing zeros padding, 1 word for the length,
            // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
            let m := add(mload(0x40), 0xa0)
            // Update the free memory pointer to allocate.
            mstore(0x40, m)
            // Assign the `str` to the end.
            str := sub(m, 0x20)
            // Zeroize the slot after the string.
            mstore(str, 0)

            // Cache the end of the memory to calculate the length later.
            let end := str

            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            // prettier-ignore
            for { let temp := value } 1 {} {
                str := sub(str, 1)
                // Write the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(str, add(48, mod(temp, 10)))
                // Keep dividing `temp` until zero.
                temp := div(temp, 10)
                // prettier-ignore
                if iszero(temp) { break }
            }

            let length := sub(end, str)
            // Move the pointer 32 bytes leftwards to make room for the length.
            str := sub(str, 0x20)
            // Store the length.
            mstore(str, length)
        }
    }
}

File 4 of 32 : ERC721A__Initializable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/**
 * @dev This is a base contract to aid in writing upgradeable diamond facet contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */

import {ERC721A__InitializableStorage} from './ERC721A__InitializableStorage.sol';

abstract contract ERC721A__Initializable {
    using ERC721A__InitializableStorage for ERC721A__InitializableStorage.Layout;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializerERC721A() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(
            ERC721A__InitializableStorage.layout()._initializing
                ? _isConstructor()
                : !ERC721A__InitializableStorage.layout()._initialized,
            'ERC721A__Initializable: contract is already initialized'
        );

        bool isTopLevelCall = !ERC721A__InitializableStorage.layout()._initializing;
        if (isTopLevelCall) {
            ERC721A__InitializableStorage.layout()._initializing = true;
            ERC721A__InitializableStorage.layout()._initialized = true;
        }

        _;

        if (isTopLevelCall) {
            ERC721A__InitializableStorage.layout()._initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializingERC721A() {
        require(
            ERC721A__InitializableStorage.layout()._initializing,
            'ERC721A__Initializable: contract is not initializing'
        );
        _;
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        // extcodesize checks the size of the code stored in an address, and
        // address returns the current address. Since the code is still not
        // deployed when running a constructor, any checks on its code size will
        // yield zero, making it an effective way to detect if a contract is
        // under construction or not.
        address self = address(this);
        uint256 cs;
        assembly {
            cs := extcodesize(self)
        }
        return cs == 0;
    }
}

File 5 of 32 : ERC721A__InitializableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev This is a base storage for the  initialization function for upgradeable diamond facet contracts
 **/

library ERC721A__InitializableStorage {
    struct Layout {
        /*
         * Indicates that the contract has been initialized.
         */
        bool _initialized;
        /*
         * Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.initializable.facet');

    function layout() internal pure returns (Layout storage l) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            l.slot := slot
        }
    }
}

File 6 of 32 : IERC721AUpgradeable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

/**
 * @dev Interface of ERC721A.
 */
interface IERC721AUpgradeable {
    /**
     * The caller must own the token or be an approved operator.
     */
    error ApprovalCallerNotOwnerNorApproved();

    /**
     * The token does not exist.
     */
    error ApprovalQueryForNonexistentToken();

    /**
     * Cannot query the balance for the zero address.
     */
    error BalanceQueryForZeroAddress();

    /**
     * Cannot mint to the zero address.
     */
    error MintToZeroAddress();

    /**
     * The quantity of tokens minted must be more than zero.
     */
    error MintZeroQuantity();

    /**
     * The token does not exist.
     */
    error OwnerQueryForNonexistentToken();

    /**
     * The caller must own the token or be an approved operator.
     */
    error TransferCallerNotOwnerNorApproved();

    /**
     * The token must be owned by `from`.
     */
    error TransferFromIncorrectOwner();

    /**
     * Cannot safely transfer to a contract that does not implement the
     * ERC721Receiver interface.
     */
    error TransferToNonERC721ReceiverImplementer();

    /**
     * Cannot transfer to the zero address.
     */
    error TransferToZeroAddress();

    /**
     * The token does not exist.
     */
    error URIQueryForNonexistentToken();

    /**
     * The `quantity` minted with ERC2309 exceeds the safety limit.
     */
    error MintERC2309QuantityExceedsLimit();

    /**
     * The `extraData` cannot be set on an unintialized ownership slot.
     */
    error OwnershipNotInitializedForExtraData();

    // =============================================================
    //                            STRUCTS
    // =============================================================

    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Stores the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
        // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
        uint24 extraData;
    }

    // =============================================================
    //                         TOKEN COUNTERS
    // =============================================================

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() external view returns (uint256);

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    // =============================================================
    //                            IERC721
    // =============================================================

    /**
     * @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,
        bytes calldata data
    ) external payable;

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external payable;

    /**
     * @dev Transfers `tokenId` 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 payable;

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

    /**
     * @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 the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

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

    // =============================================================
    //                           IERC2309
    // =============================================================

    /**
     * @dev Emitted when tokens in `fromTokenId` to `toTokenId`
     * (inclusive) is transferred from `from` to `to`, as defined in the
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
     *
     * See {_mintERC2309} for more details.
     */
    event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}

File 7 of 32 : ERC721AQueryableUpgradeable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721AQueryableUpgradeable.sol';
import '../ERC721AUpgradeable.sol';
import '../ERC721A__Initializable.sol';

/**
 * @title ERC721AQueryable.
 *
 * @dev ERC721A subclass with convenience query functions.
 */
abstract contract ERC721AQueryableUpgradeable is
    ERC721A__Initializable,
    ERC721AUpgradeable,
    IERC721AQueryableUpgradeable
{
    function __ERC721AQueryable_init() internal onlyInitializingERC721A {
        __ERC721AQueryable_init_unchained();
    }

    function __ERC721AQueryable_init_unchained() internal onlyInitializingERC721A {}

    /**
     * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
     *
     * If the `tokenId` is out of bounds:
     *
     * - `addr = address(0)`
     * - `startTimestamp = 0`
     * - `burned = false`
     * - `extraData = 0`
     *
     * If the `tokenId` is burned:
     *
     * - `addr = <Address of owner before token was burned>`
     * - `startTimestamp = <Timestamp when token was burned>`
     * - `burned = true`
     * - `extraData = <Extra data when token was burned>`
     *
     * Otherwise:
     *
     * - `addr = <Address of owner>`
     * - `startTimestamp = <Timestamp of start of ownership>`
     * - `burned = false`
     * - `extraData = <Extra data at start of ownership>`
     */
    function explicitOwnershipOf(uint256 tokenId) public view virtual override returns (TokenOwnership memory) {
        TokenOwnership memory ownership;
        if (tokenId < _startTokenId() || tokenId >= _nextTokenId()) {
            return ownership;
        }
        ownership = _ownershipAt(tokenId);
        if (ownership.burned) {
            return ownership;
        }
        return _ownershipOf(tokenId);
    }

    /**
     * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
     * See {ERC721AQueryable-explicitOwnershipOf}
     */
    function explicitOwnershipsOf(uint256[] calldata tokenIds)
        external
        view
        virtual
        override
        returns (TokenOwnership[] memory)
    {
        unchecked {
            uint256 tokenIdsLength = tokenIds.length;
            TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength);
            for (uint256 i; i != tokenIdsLength; ++i) {
                ownerships[i] = explicitOwnershipOf(tokenIds[i]);
            }
            return ownerships;
        }
    }

    /**
     * @dev Returns an array of token IDs owned by `owner`,
     * in the range [`start`, `stop`)
     * (i.e. `start <= tokenId < stop`).
     *
     * This function allows for tokens to be queried if the collection
     * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
     *
     * Requirements:
     *
     * - `start < stop`
     */
    function tokensOfOwnerIn(
        address owner,
        uint256 start,
        uint256 stop
    ) external view virtual override returns (uint256[] memory) {
        unchecked {
            if (start >= stop) revert InvalidQueryRange();
            uint256 tokenIdsIdx;
            uint256 stopLimit = _nextTokenId();
            // Set `start = max(start, _startTokenId())`.
            if (start < _startTokenId()) {
                start = _startTokenId();
            }
            // Set `stop = min(stop, stopLimit)`.
            if (stop > stopLimit) {
                stop = stopLimit;
            }
            uint256 tokenIdsMaxLength = balanceOf(owner);
            // Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`,
            // to cater for cases where `balanceOf(owner)` is too big.
            if (start < stop) {
                uint256 rangeLength = stop - start;
                if (rangeLength < tokenIdsMaxLength) {
                    tokenIdsMaxLength = rangeLength;
                }
            } else {
                tokenIdsMaxLength = 0;
            }
            uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
            if (tokenIdsMaxLength == 0) {
                return tokenIds;
            }
            // We need to call `explicitOwnershipOf(start)`,
            // because the slot at `start` may not be initialized.
            TokenOwnership memory ownership = explicitOwnershipOf(start);
            address currOwnershipAddr;
            // If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`.
            // `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
            if (!ownership.burned) {
                currOwnershipAddr = ownership.addr;
            }
            for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            // Downsize the array to fit.
            assembly {
                mstore(tokenIds, tokenIdsIdx)
            }
            return tokenIds;
        }
    }

    /**
     * @dev Returns an array of token IDs owned by `owner`.
     *
     * This function scans the ownership mapping and is O(`totalSupply`) in complexity.
     * It is meant to be called off-chain.
     *
     * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
     * multiple smaller scans if the collection is large enough to cause
     * an out-of-gas error (10K collections should be fine).
     */
    function tokensOfOwner(address owner) external view virtual override returns (uint256[] memory) {
        unchecked {
            uint256 tokenIdsIdx;
            address currOwnershipAddr;
            uint256 tokenIdsLength = balanceOf(owner);
            uint256[] memory tokenIds = new uint256[](tokenIdsLength);
            TokenOwnership memory ownership;
            for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            return tokenIds;
        }
    }
}

File 8 of 32 : IERC721AQueryableUpgradeable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import '../IERC721AUpgradeable.sol';

/**
 * @dev Interface of ERC721AQueryable.
 */
interface IERC721AQueryableUpgradeable is IERC721AUpgradeable {
    /**
     * Invalid query range (`start` >= `stop`).
     */
    error InvalidQueryRange();

    /**
     * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
     *
     * If the `tokenId` is out of bounds:
     *
     * - `addr = address(0)`
     * - `startTimestamp = 0`
     * - `burned = false`
     * - `extraData = 0`
     *
     * If the `tokenId` is burned:
     *
     * - `addr = <Address of owner before token was burned>`
     * - `startTimestamp = <Timestamp when token was burned>`
     * - `burned = true`
     * - `extraData = <Extra data when token was burned>`
     *
     * Otherwise:
     *
     * - `addr = <Address of owner>`
     * - `startTimestamp = <Timestamp of start of ownership>`
     * - `burned = false`
     * - `extraData = <Extra data at start of ownership>`
     */
    function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory);

    /**
     * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
     * See {ERC721AQueryable-explicitOwnershipOf}
     */
    function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory);

    /**
     * @dev Returns an array of token IDs owned by `owner`,
     * in the range [`start`, `stop`)
     * (i.e. `start <= tokenId < stop`).
     *
     * This function allows for tokens to be queried if the collection
     * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
     *
     * Requirements:
     *
     * - `start < stop`
     */
    function tokensOfOwnerIn(
        address owner,
        uint256 start,
        uint256 stop
    ) external view returns (uint256[] memory);

    /**
     * @dev Returns an array of token IDs owned by `owner`.
     *
     * This function scans the ownership mapping and is O(`totalSupply`) in complexity.
     * It is meant to be called off-chain.
     *
     * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
     * multiple smaller scans if the collection is large enough to cause
     * an out-of-gas error (10K collections should be fine).
     */
    function tokensOfOwner(address owner) external view returns (uint256[] memory);
}

File 9 of 32 : OperatorFilterer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Optimized and flexible operator filterer to abide to OpenSea's
/// mandatory on-chain royalty enforcement in order for new collections to
/// receive royalties.
/// For more information, see:
/// See: https://github.com/ProjectOpenSea/operator-filter-registry
abstract contract OperatorFilterer {
    /// @dev The default OpenSea operator blocklist subscription.
    address internal constant _DEFAULT_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;

    /// @dev The OpenSea operator filter registry.
    address internal constant _OPERATOR_FILTER_REGISTRY = 0x000000000000AAeB6D7670E522A718067333cd4E;

    /// @dev Registers the current contract to OpenSea's operator filter,
    /// and subscribe to the default OpenSea operator blocklist.
    /// Note: Will not revert nor update existing settings for repeated registration.
    function _registerForOperatorFiltering() internal virtual {
        _registerForOperatorFiltering(_DEFAULT_SUBSCRIPTION, true);
    }

    /// @dev Registers the current contract to OpenSea's operator filter.
    /// Note: Will not revert nor update existing settings for repeated registration.
    function _registerForOperatorFiltering(address subscriptionOrRegistrantToCopy, bool subscribe)
        internal
        virtual
    {
        /// @solidity memory-safe-assembly
        assembly {
            let functionSelector := 0x7d3e3dbe // `registerAndSubscribe(address,address)`.

            // Clean the upper 96 bits of `subscriptionOrRegistrantToCopy` in case they are dirty.
            subscriptionOrRegistrantToCopy := shr(96, shl(96, subscriptionOrRegistrantToCopy))

            for {} iszero(subscribe) {} {
                if iszero(subscriptionOrRegistrantToCopy) {
                    functionSelector := 0x4420e486 // `register(address)`.
                    break
                }
                functionSelector := 0xa0af2903 // `registerAndCopyEntries(address,address)`.
                break
            }
            // Store the function selector.
            mstore(0x00, shl(224, functionSelector))
            // Store the `address(this)`.
            mstore(0x04, address())
            // Store the `subscriptionOrRegistrantToCopy`.
            mstore(0x24, subscriptionOrRegistrantToCopy)
            // Register into the registry.
            pop(call(gas(), _OPERATOR_FILTER_REGISTRY, 0, 0x00, 0x44, 0x00, 0x00))
            // Restore the part of the free memory pointer that was overwritten,
            // which is guaranteed to be zero, because of Solidity's memory size limits.
            mstore(0x24, 0)
        }
    }

    /// @dev Modifier to guard a function and revert if the caller is a blocked operator.
    modifier onlyAllowedOperator(address from) virtual {
        if (from != msg.sender) {
            if (!_isPriorityOperator(msg.sender)) {
                if (_operatorFilteringEnabled()) _revertIfBlocked(msg.sender);
            }
        }
        _;
    }

    /// @dev Modifier to guard a function from approving a blocked operator..
    modifier onlyAllowedOperatorApproval(address operator) virtual {
        if (!_isPriorityOperator(operator)) {
            if (_operatorFilteringEnabled()) _revertIfBlocked(operator);
        }
        _;
    }

    /// @dev Helper function that reverts if the `operator` is blocked by the registry.
    function _revertIfBlocked(address operator) private view {
        /// @solidity memory-safe-assembly
        assembly {
            // Store the function selector of `isOperatorAllowed(address,address)`,
            // shifted left by 6 bytes, which is enough for 8tb of memory.
            // We waste 6-3 = 3 bytes to save on 6 runtime gas (PUSH1 0x224 SHL).
            mstore(0x00, 0xc6171134001122334455)
            // Store the `address(this)`.
            mstore(0x1a, address())
            // Store the `operator`.
            mstore(0x3a, operator)

            // `isOperatorAllowed` always returns true if it does not revert.
            if iszero(staticcall(gas(), _OPERATOR_FILTER_REGISTRY, 0x16, 0x44, 0x00, 0x00)) {
                // Bubble up the revert if the staticcall reverts.
                returndatacopy(0x00, 0x00, returndatasize())
                revert(0x00, returndatasize())
            }

            // We'll skip checking if `from` is inside the blacklist.
            // Even though that can block transferring out of wrapper contracts,
            // we don't want tokens to be stuck.

            // Restore the part of the free memory pointer that was overwritten,
            // which is guaranteed to be zero, if less than 8tb of memory is used.
            mstore(0x3a, 0)
        }
    }

    /// @dev For deriving contracts to override, so that operator filtering
    /// can be turned on / off.
    /// Returns true by default.
    function _operatorFilteringEnabled() internal view virtual returns (bool) {
        return true;
    }

    /// @dev For deriving contracts to override, so that preferred marketplaces can
    /// skip operator filtering, helping users save gas.
    /// Returns false for all inputs by default.
    function _isPriorityOperator(address) internal view virtual returns (bool) {
        return false;
    }
}

File 10 of 32 : ECDSA.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @notice Gas optimized ECDSA wrapper.
/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/ECDSA.sol)
/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/ECDSA.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol)
library ECDSA {
    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                         CONSTANTS                          */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev The number which `s` must not exceed in order for
    /// the signature to be non-malleable.
    bytes32 private constant _MALLEABILITY_THRESHOLD =
        0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0;

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                    RECOVERY OPERATIONS                     */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Recovers the signer's address from a message digest `hash`,
    /// and the `signature`.
    ///
    /// This function does NOT accept EIP-2098 short form signatures.
    /// Use `recover(bytes32 hash, bytes32 r, bytes32 vs)` for EIP-2098
    /// short form signatures instead.
    ///
    /// WARNING!
    /// The `result` will be the zero address upon recovery failure.
    /// As such, it is extremely important to ensure that the address which
    /// the `result` is compared against is never zero.
    function recover(bytes32 hash, bytes calldata signature) internal view returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            if eq(signature.length, 65) {
                // Copy the free memory pointer so that we can restore it later.
                let m := mload(0x40)
                // Directly copy `r` and `s` from the calldata.
                calldatacopy(0x40, signature.offset, 0x40)

                // If `s` in lower half order, such that the signature is not malleable.
                if iszero(gt(mload(0x60), _MALLEABILITY_THRESHOLD)) {
                    mstore(0x00, hash)
                    // Compute `v` and store it in the scratch space.
                    mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40))))
                    pop(
                        staticcall(
                            gas(), // Amount of gas left for the transaction.
                            0x01, // Address of `ecrecover`.
                            0x00, // Start of input.
                            0x80, // Size of input.
                            0x40, // Start of output.
                            0x20 // Size of output.
                        )
                    )
                    // Restore the zero slot.
                    mstore(0x60, 0)
                    // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
                    result := mload(sub(0x60, returndatasize()))
                }
                // Restore the free memory pointer.
                mstore(0x40, m)
            }
        }
    }

    /// @dev Recovers the signer's address from a message digest `hash`,
    /// and the EIP-2098 short form signature defined by `r` and `vs`.
    ///
    /// This function only accepts EIP-2098 short form signatures.
    /// See: https://eips.ethereum.org/EIPS/eip-2098
    ///
    /// To be honest, I do not recommend using EIP-2098 signatures
    /// for simplicity, performance, and security reasons. Most if not
    /// all clients support traditional non EIP-2098 signatures by default.
    /// As such, this method is intentionally not fully inlined.
    /// It is merely included for completeness.
    ///
    /// WARNING!
    /// The `result` will be the zero address upon recovery failure.
    /// As such, it is extremely important to ensure that the address which
    /// the `result` is compared against is never zero.
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal view returns (address result) {
        uint8 v;
        bytes32 s;
        /// @solidity memory-safe-assembly
        assembly {
            s := shr(1, shl(1, vs))
            v := add(shr(255, vs), 27)
        }
        result = recover(hash, v, r, s);
    }

    /// @dev Recovers the signer's address from a message digest `hash`,
    /// and the signature defined by `v`, `r`, `s`.
    ///
    /// WARNING!
    /// The `result` will be the zero address upon recovery failure.
    /// As such, it is extremely important to ensure that the address which
    /// the `result` is compared against is never zero.
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal view returns (address result) {
        /// @solidity memory-safe-assembly
        assembly {
            // Copy the free memory pointer so that we can restore it later.
            let m := mload(0x40)

            // If `s` in lower half order, such that the signature is not malleable.
            if iszero(gt(s, _MALLEABILITY_THRESHOLD)) {
                mstore(0x00, hash)
                mstore(0x20, v)
                mstore(0x40, r)
                mstore(0x60, s)
                pop(
                    staticcall(
                        gas(), // Amount of gas left for the transaction.
                        0x01, // Address of `ecrecover`.
                        0x00, // Start of input.
                        0x80, // Size of input.
                        0x40, // Start of output.
                        0x20 // Size of output.
                    )
                )
                // Restore the zero slot.
                mstore(0x60, 0)
                // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise.
                result := mload(sub(0x60, returndatasize()))
            }
            // Restore the free memory pointer.
            mstore(0x40, m)
        }
    }

    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
    /*                     HASHING OPERATIONS                     */
    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/

    /// @dev Returns an Ethereum Signed Message, created from a `hash`.
    /// This produces a hash corresponding to the one signed with the
    /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
    /// JSON-RPC method as part of EIP-191.
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) {
        /// @solidity memory-safe-assembly
        assembly {
            // Store into scratch space for keccak256.
            mstore(0x20, hash)
            mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32")
            // 0x40 - 0x04 = 0x3c
            result := keccak256(0x04, 0x3c)
        }
    }

    /// @dev Returns an Ethereum Signed Message, created from `s`.
    /// This produces a hash corresponding to the one signed with the
    /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign)
    /// JSON-RPC method as part of EIP-191.
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) {
        assembly {
            // We need at most 128 bytes for Ethereum signed message header.
            // The max length of the ASCII reprenstation of a uint256 is 78 bytes.
            // The length of "\x19Ethereum Signed Message:\n" is 26 bytes (i.e. 0x1a).
            // The next multiple of 32 above 78 + 26 is 128 (i.e. 0x80).

            // Instead of allocating, we temporarily copy the 128 bytes before the
            // start of `s` data to some variables.
            let m3 := mload(sub(s, 0x60))
            let m2 := mload(sub(s, 0x40))
            let m1 := mload(sub(s, 0x20))
            // The length of `s` is in bytes.
            let sLength := mload(s)

            let ptr := add(s, 0x20)

            // `end` marks the end of the memory which we will compute the keccak256 of.
            let end := add(ptr, sLength)

            // Convert the length of the bytes to ASCII decimal representation
            // and store it into the memory.
            // prettier-ignore
            for { let temp := sLength } 1 {} {
                ptr := sub(ptr, 1)
                mstore8(ptr, add(48, mod(temp, 10)))
                temp := div(temp, 10)
                // prettier-ignore
                if iszero(temp) { break }
            }

            // Copy the header over to the memory.
            mstore(sub(ptr, 0x20), "\x00\x00\x00\x00\x00\x00\x19Ethereum Signed Message:\n")
            // Compute the keccak256 of the memory.
            result := keccak256(sub(ptr, 0x1a), sub(end, sub(ptr, 0x1a)))

            // Restore the previous memory.
            mstore(s, sLength)
            mstore(sub(s, 0x20), m1)
            mstore(sub(s, 0x40), m2)
            mstore(sub(s, 0x60), m3)
        }
    }
}

File 11 of 32 : IOwnable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC173 } from '../../interfaces/IERC173.sol';
import { IOwnableInternal } from './IOwnableInternal.sol';

interface IOwnable is IOwnableInternal, IERC173 {}

File 12 of 32 : IOwnableInternal.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC173Internal } from '../../interfaces/IERC173Internal.sol';

interface IOwnableInternal is IERC173Internal {
    error Ownable__NotOwner();
    error Ownable__NotTransitiveOwner();
}

File 13 of 32 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC173 } from '../../interfaces/IERC173.sol';
import { IOwnable } from './IOwnable.sol';
import { OwnableInternal } from './OwnableInternal.sol';

/**
 * @title Ownership access control based on ERC173
 */
abstract contract Ownable is IOwnable, OwnableInternal {
    /**
     * @inheritdoc IERC173
     */
    function owner() public view virtual returns (address) {
        return _owner();
    }

    /**
     * @inheritdoc IERC173
     */
    function transferOwnership(address account) public virtual onlyOwner {
        _transferOwnership(account);
    }
}

File 14 of 32 : OwnableInternal.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC173 } from '../../interfaces/IERC173.sol';
import { AddressUtils } from '../../utils/AddressUtils.sol';
import { IOwnableInternal } from './IOwnableInternal.sol';
import { OwnableStorage } from './OwnableStorage.sol';

abstract contract OwnableInternal is IOwnableInternal {
    using AddressUtils for address;

    modifier onlyOwner() {
        if (msg.sender != _owner()) revert Ownable__NotOwner();
        _;
    }

    modifier onlyTransitiveOwner() {
        if (msg.sender != _transitiveOwner())
            revert Ownable__NotTransitiveOwner();
        _;
    }

    function _owner() internal view virtual returns (address) {
        return OwnableStorage.layout().owner;
    }

    function _transitiveOwner() internal view virtual returns (address owner) {
        owner = _owner();

        while (owner.isContract()) {
            try IERC173(owner).owner() returns (address transitiveOwner) {
                owner = transitiveOwner;
            } catch {
                break;
            }
        }
    }

    function _transferOwnership(address account) internal virtual {
        _setOwner(account);
    }

    function _setOwner(address account) internal virtual {
        OwnableStorage.Layout storage l = OwnableStorage.layout();
        emit OwnershipTransferred(l.owner, account);
        l.owner = account;
    }
}

File 15 of 32 : OwnableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

library OwnableStorage {
    struct Layout {
        address owner;
    }

    bytes32 internal constant STORAGE_SLOT =
        keccak256('solidstate.contracts.storage.Ownable');

    function layout() internal pure returns (Layout storage l) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            l.slot := slot
        }
    }
}

File 16 of 32 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC165Internal } from './IERC165Internal.sol';

/**
 * @title ERC165 interface registration interface
 * @dev see https://eips.ethereum.org/EIPS/eip-165
 */
interface IERC165 is IERC165Internal {
    /**
     * @notice query whether contract has registered support for given interface
     * @param interfaceId interface id
     * @return bool whether interface is supported
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 17 of 32 : IERC165Internal.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC165Internal } from './IERC165Internal.sol';

/**
 * @title ERC165 interface registration interface
 */
interface IERC165Internal {

}

File 18 of 32 : IERC173.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC173Internal } from './IERC173Internal.sol';

/**
 * @title Contract ownership standard interface
 * @dev see https://eips.ethereum.org/EIPS/eip-173
 */
interface IERC173 is IERC173Internal {
    /**
     * @notice get the ERC173 contract owner
     * @return contract owner
     */
    function owner() external view returns (address);

    /**
     * @notice transfer contract ownership to new account
     * @param account address of new owner
     */
    function transferOwnership(address account) external;
}

File 19 of 32 : IERC173Internal.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

/**
 * @title Partial ERC173 interface needed by internal functions
 */
interface IERC173Internal {
    event OwnershipTransferred(
        address indexed previousOwner,
        address indexed newOwner
    );
}

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

pragma solidity ^0.8.8;

import { IERC20Internal } from './IERC20Internal.sol';

/**
 * @title ERC20 interface
 * @dev see https://github.com/ethereum/EIPs/issues/20
 */
interface IERC20 is IERC20Internal {
    /**
     * @notice query the total minted token supply
     * @return token supply
     */
    function totalSupply() external view returns (uint256);

    /**
     * @notice query the token balance of given account
     * @param account address to query
     * @return token balance
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @notice query the allowance granted from given holder to given spender
     * @param holder approver of allowance
     * @param spender recipient of allowance
     * @return token allowance
     */
    function allowance(
        address holder,
        address spender
    ) external view returns (uint256);

    /**
     * @notice grant approval to spender to spend tokens
     * @dev prefer ERC20Extended functions to avoid transaction-ordering vulnerability (see https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729)
     * @param spender recipient of allowance
     * @param amount quantity of tokens approved for spending
     * @return success status (always true; otherwise function should revert)
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @notice transfer tokens to given recipient
     * @param recipient beneficiary of token transfer
     * @param amount quantity of tokens to transfer
     * @return success status (always true; otherwise function should revert)
     */
    function transfer(
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @notice transfer tokens to given recipient on behalf of given holder
     * @param holder holder of tokens prior to transfer
     * @param recipient beneficiary of token transfer
     * @param amount quantity of tokens to transfer
     * @return success status (always true; otherwise function should revert)
     */
    function transferFrom(
        address holder,
        address recipient,
        uint256 amount
    ) external returns (bool);
}

File 21 of 32 : IERC20Internal.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

/**
 * @title Partial ERC20 interface needed by internal functions
 */
interface IERC20Internal {
    event Transfer(address indexed from, address indexed to, uint256 value);

    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );
}

File 22 of 32 : IERC2981.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC165 } from './IERC165.sol';
import { IERC2981Internal } from './IERC2981Internal.sol';

/**
 * @title ERC2981 interface
 * @dev see https://eips.ethereum.org/EIPS/eip-2981
 */
interface IERC2981 is IERC2981Internal, IERC165 {
    /**
     * @notice called with the sale price to determine how much royalty is owed and to whom
     * @param tokenId the ERC721 or ERC1155 token id to query for royalty information
     * @param salePrice the sale price of the given asset
     * @return receiever rightful recipient of royalty
     * @return royaltyAmount amount of royalty owed
     */
    function royaltyInfo(
        uint256 tokenId,
        uint256 salePrice
    ) external view returns (address receiever, uint256 royaltyAmount);
}

File 23 of 32 : IERC2981Internal.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

/**
 * @title ERC2981 interface
 */
interface IERC2981Internal {

}

File 24 of 32 : ERC2981.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { IERC2981 } from '../../../interfaces/IERC2981.sol';

import { ERC2981Storage } from './ERC2981Storage.sol';
import { ERC2981Internal } from './ERC2981Internal.sol';

/**
 * @title ERC2981 implementation
 */
abstract contract ERC2981 is IERC2981, ERC2981Internal {
    /**
     * @notice inheritdoc IERC2981
     */
    function royaltyInfo(
        uint256 tokenId,
        uint256 salePrice
    ) external view returns (address, uint256) {
        return _royaltyInfo(tokenId, salePrice);
    }
}

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

pragma solidity ^0.8.8;

import { ERC2981Storage } from './ERC2981Storage.sol';
import { IERC2981Internal } from '../../../interfaces/IERC2981Internal.sol';

/**
 * @title ERC2981 internal functions
 */
abstract contract ERC2981Internal is IERC2981Internal {
    /**
     * @notice calculate how much royalty is owed and to whom
     * @dev royalty must be paid in addition to, rather than deducted from, salePrice
     * @param tokenId the ERC721 or ERC1155 token id to query for royalty information
     * @param salePrice the sale price of the given asset
     * @return royaltyReceiver rightful recipient of royalty
     * @return royalty amount of royalty owed
     */
    function _royaltyInfo(
        uint256 tokenId,
        uint256 salePrice
    ) internal view virtual returns (address royaltyReceiver, uint256 royalty) {
        uint256 royaltyBPS = _getRoyaltyBPS(tokenId);

        // intermediate multiplication overflow is theoretically possible here, but
        // not an issue in practice because of practical constraints of salePrice
        return (_getRoyaltyReceiver(tokenId), (royaltyBPS * salePrice) / 10000);
    }

    /**
     * @notice query the royalty rate (denominated in basis points) for given token id
     * @dev implementation supports per-token-id values as well as a global default
     * @param tokenId token whose royalty rate to query
     * @return royaltyBPS royalty rate
     */
    function _getRoyaltyBPS(
        uint256 tokenId
    ) internal view virtual returns (uint16 royaltyBPS) {
        ERC2981Storage.Layout storage l = ERC2981Storage.layout();
        royaltyBPS = l.royaltiesBPS[tokenId];

        if (royaltyBPS == 0) {
            royaltyBPS = l.defaultRoyaltyBPS;
        }
    }

    /**
     * @notice query the royalty receiver for given token id
     * @dev implementation supports per-token-id values as well as a global default
     * @param tokenId token whose royalty receiver to query
     * @return royaltyReceiver royalty receiver
     */
    function _getRoyaltyReceiver(
        uint256 tokenId
    ) internal view virtual returns (address royaltyReceiver) {
        ERC2981Storage.Layout storage l = ERC2981Storage.layout();
        royaltyReceiver = l.royaltyReceivers[tokenId];

        if (royaltyReceiver == address(0)) {
            royaltyReceiver = l.defaultRoyaltyReceiver;
        }
    }
}

File 26 of 32 : ERC2981Storage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

library ERC2981Storage {
    struct Layout {
        // token id -> royalty (denominated in basis points)
        mapping(uint256 => uint16) royaltiesBPS;
        uint16 defaultRoyaltyBPS;
        // token id -> receiver address
        mapping(uint256 => address) royaltyReceivers;
        address defaultRoyaltyReceiver;
    }

    bytes32 internal constant STORAGE_SLOT =
        keccak256('solidstate.contracts.storage.ERC2981');

    function layout() internal pure returns (Layout storage l) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            l.slot := slot
        }
    }
}

File 27 of 32 : AddressUtils.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

import { UintUtils } from './UintUtils.sol';

library AddressUtils {
    using UintUtils for uint256;

    error AddressUtils__InsufficientBalance();
    error AddressUtils__NotContract();
    error AddressUtils__SendValueFailed();

    function toString(address account) internal pure returns (string memory) {
        return uint256(uint160(account)).toHexString(20);
    }

    function isContract(address account) internal view returns (bool) {
        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    function sendValue(address payable account, uint256 amount) internal {
        (bool success, ) = account.call{ value: amount }('');
        if (!success) revert AddressUtils__SendValueFailed();
    }

    function functionCall(
        address target,
        bytes memory data
    ) internal returns (bytes memory) {
        return
            functionCall(target, data, 'AddressUtils: failed low-level call');
    }

    function functionCall(
        address target,
        bytes memory data,
        string memory error
    ) internal returns (bytes memory) {
        return _functionCallWithValue(target, data, 0, error);
    }

    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return
            functionCallWithValue(
                target,
                data,
                value,
                'AddressUtils: failed low-level call with value'
            );
    }

    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory error
    ) internal returns (bytes memory) {
        if (value > address(this).balance)
            revert AddressUtils__InsufficientBalance();
        return _functionCallWithValue(target, data, value, error);
    }

    /**
     * @notice execute arbitrary external call with limited gas usage and amount of copied return data
     * @dev derived from https://github.com/nomad-xyz/ExcessivelySafeCall (MIT License)
     * @param target recipient of call
     * @param gasAmount gas allowance for call
     * @param value native token value to include in call
     * @param maxCopy maximum number of bytes to copy from return data
     * @param data encoded call data
     * @return success whether call is successful
     * @return returnData copied return data
     */
    function excessivelySafeCall(
        address target,
        uint256 gasAmount,
        uint256 value,
        uint16 maxCopy,
        bytes memory data
    ) internal returns (bool success, bytes memory returnData) {
        returnData = new bytes(maxCopy);

        assembly {
            // execute external call via assembly to avoid automatic copying of return data
            success := call(
                gasAmount,
                target,
                value,
                add(data, 0x20),
                mload(data),
                0,
                0
            )

            // determine whether to limit amount of data to copy
            let toCopy := returndatasize()

            if gt(toCopy, maxCopy) {
                toCopy := maxCopy
            }

            // store the length of the copied bytes
            mstore(returnData, toCopy)

            // copy the bytes from returndata[0:toCopy]
            returndatacopy(add(returnData, 0x20), 0, toCopy)
        }
    }

    function _functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory error
    ) private returns (bytes memory) {
        if (!isContract(target)) revert AddressUtils__NotContract();

        (bool success, bytes memory returnData) = target.call{ value: value }(
            data
        );

        if (success) {
            return returnData;
        } else if (returnData.length > 0) {
            assembly {
                let returnData_size := mload(returnData)
                revert(add(32, returnData), returnData_size)
            }
        } else {
            revert(error);
        }
    }
}

File 28 of 32 : UintUtils.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.8;

/**
 * @title utility functions for uint256 operations
 * @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)
 */
library UintUtils {
    error UintUtils__InsufficientHexLength();

    bytes16 private constant HEX_SYMBOLS = '0123456789abcdef';

    function add(uint256 a, int256 b) internal pure returns (uint256) {
        return b < 0 ? sub(a, -b) : a + uint256(b);
    }

    function sub(uint256 a, int256 b) internal pure returns (uint256) {
        return b < 0 ? add(a, -b) : a - uint256(b);
    }

    function toString(uint256 value) internal pure returns (string memory) {
        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);
    }

    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return '0x00';
        }

        uint256 length = 0;

        for (uint256 temp = value; temp != 0; temp >>= 8) {
            unchecked {
                length++;
            }
        }

        return toHexString(value, 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';

        unchecked {
            for (uint256 i = 2 * length + 1; i > 1; --i) {
                buffer[i] = HEX_SYMBOLS[value & 0xf];
                value >>= 4;
            }
        }

        if (value != 0) revert UintUtils__InsufficientHexLength();

        return string(buffer);
    }
}

File 29 of 32 : ProjectEnvisionStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library ProjectEnvisionStorage {
    struct Layout {
        /// @notice Base URI of the NFT
        string baseURI;
        /// @notice Whitelist sale
        bool whitelistSale;
        /// @notice Public sale
        bool publicSale;
        /// @notice OG price
        uint256 ogPrice;
        /// @notice Maximum per wallet
        uint64 ogMaxMint;
        /// @notice Whitelist price
        uint256 whitelistPrice;
        /// @notice Maximum per wallet
        uint64 whitelistMaxMint;
        /// @notice Actual Price
        uint256 publicPrice;
        /// @notice Maximum per wallet
        uint64 publicMaxMint;
        /// @notice Whitelist merkle root
        bytes32[2] whitelistMerkleRoot;
        /// @notice Tier mint count
        mapping(uint64 => mapping(address => uint64)) addressMintCount;
        /// @notice OG Reserve
        uint256 ogReserve;
        /// @notice Boned
        mapping(uint256 => bool) boned;
        /// @notice Bone URI
        string boneURI;
        /// @notice Summon URI
        string summonURI;
        /// @notice Signer
        address signer;
    }

    bytes32 internal constant STORAGE_SLOT =
        keccak256("ProjectEnvision.contracts.storage.ProjectEnvision");

    function layout() internal pure returns (Layout storage l) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            l.slot := slot
        }
    }
}

File 30 of 32 : IERC4906.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IERC4906 {
    /// @dev This event emits when the metadata of a token is changed.
    /// So that the third-party platforms such as NFT market could
    /// timely update the images and related attributes of the NFT.
    event MetadataUpdate(uint256 _tokenId);

    /// @dev This event emits when the metadata of a range of tokens is changed.
    /// So that the third-party platforms such as NFT market could
    /// timely update the images and related attributes of the NFTs.
    event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
}

File 31 of 32 : IProjectEnvision.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {IERC721AUpgradeable} from "@erc721a-upgradable/IERC721AUpgradeable.sol";

interface IProjectEnvision is IERC721AUpgradeable {
}

File 32 of 32 : ITokenWrapper.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ITokenWrapper {
    function balanceOf(address user) external view returns (uint256);

    function withdraw(uint256 amount) external;
}

Settings
{
  "remappings": [
    "@closedsea/=lib/closedsea/src/",
    "@erc721a-upgradable/=lib/ERC721A-Upgradeable/contracts/",
    "@erc721a/=lib/ERC721A/contracts/",
    "@os/=lib/operator-filter-registry/src/",
    "@solady/=lib/solady/src/",
    "@solidstate-solidity/=lib/solidstate-solidity/contracts/",
    "@std/=lib/forge-std/src/",
    "ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
    "ERC721A/=lib/ERC721A/contracts/",
    "closedsea/=lib/closedsea/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/closedsea/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "erc721a-upgradeable/=lib/closedsea/lib/erc721a-upgradeable/contracts/",
    "erc721a/=lib/closedsea/lib/erc721a/contracts/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/closedsea/lib/openzeppelin-contracts-upgradeable/contracts/",
    "openzeppelin-contracts/=lib/closedsea/lib/openzeppelin-contracts/contracts/",
    "operator-filter-registry/=lib/operator-filter-registry/src/",
    "solady/=lib/solady/src/",
    "solidstate-solidity/=lib/solidstate-solidity/contracts/",
    "solmate/=lib/solady/lib/solmate/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"AddressUtils__SendValueFailed","type":"error"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"InvalidQueryRange","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"Ownable__NotOwner","type":"error"},{"inputs":[],"name":"Ownable__NotTransitiveOwner","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","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":false,"internalType":"uint256","name":"_fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toTokenId","type":"uint256"}],"name":"BatchMetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"MetadataUpdate","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":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","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":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"burnAsAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"burnMany","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"explicitOwnershipOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721AUpgradeable.TokenOwnership","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"explicitOwnershipsOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721AUpgradeable.TokenOwnership[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"fundDeployer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSaleState","outputs":[{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"getTokenState","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"},{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isTokenBone","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isTokenSummoned","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"mintAsAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sacrificed","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":"safeTransferFrom","outputs":[],"stateMutability":"payable","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":"payable","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":"string","name":"boneURI_","type":"string"}],"name":"setBoneUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"ogQty","type":"uint64"},{"internalType":"uint64","name":"whitelistQty","type":"uint64"},{"internalType":"uint64","name":"publicQty","type":"uint64"}],"name":"setMaxMintQuantity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ogPrice","type":"uint256"},{"internalType":"uint256","name":"whitelistPrice","type":"uint256"},{"internalType":"uint256","name":"publicPrice","type":"uint256"}],"name":"setMintPrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"setSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"summonURI_","type":"string"}],"name":"setSummonUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"bones","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"summon","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"bones","type":"uint256[]"},{"internalType":"bytes[]","name":"signatures","type":"bytes[]"}],"name":"summonMany","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"summoned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"tokensOfOwnerIn","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"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":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"defaultRoyaltyReceiver","type":"address"},{"internalType":"uint16","name":"defaultRoyaltyBPS","type":"uint16"}],"name":"updateRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawEverything","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50613ba3806100206000396000f3fe6080604052600436106102725760003560e01c80637783ef3f1161014f578063c23dc68f116100c1578063e985e9c51161007a578063e985e9c51461079d578063e9931407146107bd578063ebdf0919146107dd578063f0e2a569146107fd578063f2fde38b14610812578063f62d18881461083257600080fd5b8063c23dc68f146106e6578063c87b56dd14610713578063cf32346014610733578063d1e191a414610753578063d7da6dcf14610768578063e1b6d92e1461077d57600080fd5b806399a2557a1161011357806399a2557a14610633578063a0bcfc7f14610653578063a22cb46514610673578063a27dd71b14610693578063b88d4fde146106b3578063ba1980b3146106c657600080fd5b80637783ef3f1461059c5780638462151c146105bc5780638da5cb5b146105e9578063909a33f7146105fe57806395d89b411461061e57600080fd5b806332cb6b0c116101e85780635bbb2177116101ac5780635bbb2177146104cf5780636352211e146104fc5780636c19e7831461051c5780636cbca5471461053c5780636fb081a41461055c57806370a082311461057c57600080fd5b806332cb6b0c1461045157806335397e1f146104675780633ccfd60b1461048757806342842e0e1461049c57806342966c68146104af57600080fd5b80630c62d2851161023a5780630c62d2851461033b5780631314be6a1461036957806318160ddd1461038957806323b872dd146103ac57806325bdb2a8146103bf5780632a55205a1461041257600080fd5b806301ffc9a714610277578063064bd41a146102ac57806306fdde03146102ce578063081812fc146102f0578063095ea7b314610328575b600080fd5b34801561028357600080fd5b50610297610292366004613072565b610852565b60405190151581526020015b60405180910390f35b3480156102b857600080fd5b506102cc6102c736600461308f565b610898565b005b3480156102da57600080fd5b506102e3610aad565b6040516102a3919061315e565b3480156102fc57600080fd5b5061031061030b366004613171565b610b48565b6040516001600160a01b0390911681526020016102a3565b6102cc6103363660046131a1565b610b95565b34801561034757600080fd5b5061035b610356366004613211565b610ba5565b6040516102a39291906132f3565b34801561037557600080fd5b50610297610384366004613171565b610ce5565b34801561039557600080fd5b5061039e610d06565b6040519081526020016102a3565b6102cc6103ba366004613318565b610d26565b3480156103cb57600080fd5b506103d4610d51565b604080516001600160401b039788168152958716602087015293909516928401929092526060830152608082015260a081019190915260c0016102a3565b34801561041e57600080fd5b5061043261042d366004613354565b610dd0565b604080516001600160a01b0390931683526020830191909152016102a3565b34801561045d57600080fd5b5061039e61157c81565b34801561047357600080fd5b506102cc6104823660046133ba565b610de9565b34801561049357600080fd5b506102cc610e65565b6102cc6104aa366004613318565b610ea8565b3480156104bb57600080fd5b506102cc6104ca366004613171565b610ecd565b3480156104db57600080fd5b506104ef6104ea3660046133ba565b610ed8565b6040516102a39190613437565b34801561050857600080fd5b50610310610517366004613171565b610fa3565b34801561052857600080fd5b506102cc610537366004613479565b610fae565b34801561054857600080fd5b506102cc6105573660046134ab565b611014565b34801561056857600080fd5b506102cc6105773660046134ee565b6110d3565b34801561058857600080fd5b5061039e610597366004613479565b611138565b3480156105a857600080fd5b506102cc6105b7366004613171565b6111a0565b3480156105c857600080fd5b506105dc6105d7366004613479565b611202565b6040516102a3919061351a565b3480156105f557600080fd5b5061031061130a565b34801561060a57600080fd5b506102cc610619366004613552565b611319565b34801561062a57600080fd5b506102e36113d2565b34801561063f57600080fd5b506105dc61064e3660046135eb565b6113ea565b34801561065f57600080fd5b506102cc61066e366004613675565b611570565b34801561067f57600080fd5b506102cc61068e3660046136bd565b6115bd565b34801561069f57600080fd5b506102cc6106ae366004613675565b61163a565b6102cc6106c13660046136f9565b61168a565b3480156106d257600080fd5b506102976106e1366004613171565b6116b7565b3480156106f257600080fd5b50610706610701366004613171565b6116ce565b6040516102a39190613774565b34801561071f57600080fd5b506102e361072e366004613171565b61175b565b34801561073f57600080fd5b506102cc61074e3660046133ba565b611932565b34801561075f57600080fd5b506102cc611972565b34801561077457600080fd5b5061039e611b64565b34801561078957600080fd5b506102cc6107983660046131a1565b611ba6565b3480156107a957600080fd5b506102976107b8366004613782565b611c43565b3480156107c957600080fd5b506102cc6107d8366004613675565b611c80565b3480156107e957600080fd5b506102cc6107f83660046137b5565b611cd0565b34801561080957600080fd5b5061039e611d7f565b34801561081e57600080fd5b506102cc61082d366004613479565b611dc1565b34801561083e57600080fd5b506102cc61084d366004613675565b611e03565b600063152a902d60e11b6001600160e01b0319831614806108835750632483248360e11b6001600160e01b03198316145b80610892575061089282611faa565b92915050565b6040805160208101869052908101849052600090606001604051602081830303815290604052805190602001209050600061090484846108fd856020527b19457468657265756d205369676e6564204d6573736167653a0a3332600052603c60042090565b9190611ff8565b9050806001600160a01b0316610918612067565b600f01546001600160a01b0316146109625760405162461bcd60e51b815260206004820152600860248201526742616420426f6e6560c01b60448201526064015b60405180910390fd5b3361096c87610fa3565b6001600160a01b0316146109ae5760405162461bcd60e51b81526020600482015260096024820152682737ba1027bbb732b960b91b6044820152606401610959565b6109b786610ce5565b6109ee5760405162461bcd60e51b81526020600482015260086024820152674e6f7420426f6e6560c01b6044820152606401610959565b6109f7866116b7565b15610a375760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e4814dd5b5b5bdb995960821b6044820152606401610959565b610a408661208b565b6000610a4a612096565b90507f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c610a788260016137fe565b610a8288846137fe565b6040805192835260208301919091520160405180910390a1610aa433876120a9565b50505050505050565b6060610ab76121c0565b6002018054610ac590613811565b80601f0160208091040260200160405190810160405280929190818152602001828054610af190613811565b8015610b3e5780601f10610b1357610100808354040283529160200191610b3e565b820191906000526020600020905b815481529060010190602001808311610b2157829003601f168201915b5050505050905090565b6000610b53826121e4565b610b70576040516333d1c03960e21b815260040160405180910390fd5b610b786121c0565b60009283526006016020525060409020546001600160a01b031690565b610ba18282600161222d565b5050565b606080600083516001600160401b03811115610bc357610bc36131cb565b604051908082528060200260200182016040528015610bec578160200160208202803683370190505b509050600084516001600160401b03811115610c0a57610c0a6131cb565b604051908082528060200260200182016040528015610c33578160200160208202803683370190505b50905060005b8551811015610cda57610c64868281518110610c5757610c57613845565b6020026020010151610ce5565b838281518110610c7657610c76613845565b60200260200101901515908115158152505061157c868281518110610c9d57610c9d613845565b602002602001015111828281518110610cb857610cb8613845565b9115156020928302919091019091015280610cd28161385b565b915050610c39565b509094909350915050565b6000610cef612067565b6000928352600c0160205250604090205460ff1690565b60006001610d126121c0565b60010154610d1e6121c0565b540303919050565b826001600160a01b0381163314610d4057610d40336122e2565b610d4b848484612326565b50505050565b600080600080600080610d62612067565b600301546001600160401b0316610d77612067565b600501546001600160401b0316610d8c612067565b600701546001600160401b0316610da1612067565b60020154610dad612067565b60040154610db9612067565b60060154949b939a50919850965094509092509050565b600080610ddd848461250b565b915091505b9250929050565b610df161254b565b6001600160a01b0316336001600160a01b031614610e2257604051632f7a8ee160e01b815260040160405180910390fd5b60005b81811015610e6057610e4e838383818110610e4257610e42613845565b9050602002013561208b565b80610e588161385b565b915050610e25565b505050565b610e6d61254b565b6001600160a01b0316336001600160a01b031614610e9e57604051632f7a8ee160e01b815260040160405180910390fd5b610ea6612579565b565b826001600160a01b0381163314610ec257610ec2336122e2565b610d4b8484846125f8565b610ba1816000612613565b6060816000816001600160401b03811115610ef557610ef56131cb565b604051908082528060200260200182016040528015610f4757816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181610f135790505b50905060005b828114610f9a57610f75868683818110610f6957610f69613845565b905060200201356116ce565b828281518110610f8757610f87613845565b6020908102919091010152600101610f4d565b50949350505050565b6000610892826127b0565b610fb661254b565b6001600160a01b0316336001600160a01b031614610fe757604051632f7a8ee160e01b815260040160405180910390fd5b80610ff0612067565b600f0180546001600160a01b0319166001600160a01b039290921691909117905550565b61101c61254b565b6001600160a01b0316336001600160a01b03161461104d57604051632f7a8ee160e01b815260040160405180910390fd5b82611056612067565b600301805467ffffffffffffffff19166001600160401b039290921691909117905581611081612067565b600501805467ffffffffffffffff19166001600160401b0392909216919091179055806110ac612067565b600701805467ffffffffffffffff19166001600160401b0392909216919091179055505050565b6110db61254b565b6001600160a01b0316336001600160a01b03161461110c57604051632f7a8ee160e01b815260040160405180910390fd5b82611115612067565b6002015580611122612067565b600601558161112f612067565b60040155505050565b60006001600160a01b038216611161576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b036111716121c0565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b6111a861254b565b6001600160a01b0316336001600160a01b0316146111d957604051632f7a8ee160e01b815260040160405180910390fd5b670de0b6b3a76400008111156111ee57600080fd5b6111ff6111f961130a565b8261285d565b50565b6060600080600061121285611138565b90506000816001600160401b0381111561122e5761122e6131cb565b604051908082528060200260200182016040528015611257578160200160208202803683370190505b50905061128460408051608081018252600080825260208201819052918101829052606081019190915290565b60015b8386146112fe57611297816128d1565b915081604001516112f65781516001600160a01b0316156112b757815194505b876001600160a01b0316856001600160a01b0316036112f657808387806001019850815181106112e9576112e9613845565b6020026020010181815250505b600101611287565b50909695505050505050565b600061131461254b565b905090565b848314801561132757508481145b61135e5760405162461bcd60e51b815260206004820152600860248201526709ad2e6dac2e8c6d60c31b6044820152606401610959565b60005b85811015610aa4576113c287878381811061137e5761137e613845565b9050602002013586868481811061139757611397613845565b905060200201358585858181106113b0576113b0613845565b90506020028101906102c79190613874565b6113cb8161385b565b9050611361565b60606113dc6121c0565b6003018054610ac590613811565b606081831061140c57604051631960ccad60e11b815260040160405180910390fd5b600080611417612918565b9050600185101561142757600194505b80841115611433578093505b600061143e87611138565b90508486101561145d5785850381811015611457578091505b50611461565b5060005b6000816001600160401b0381111561147b5761147b6131cb565b6040519080825280602002602001820160405280156114a4578160200160208202803683370190505b509050816000036114ba57935061156992505050565b60006114c5886116ce565b9050600081604001516114d6575080515b885b8881141580156114e85750848714155b1561155d576114f6816128d1565b925082604001516115555782516001600160a01b03161561151657825191505b8a6001600160a01b0316826001600160a01b031603611555578084888060010199508151811061154857611548613845565b6020026020010181815250505b6001016114d8565b50505092835250909150505b9392505050565b61157861254b565b6001600160a01b0316336001600160a01b0316146115a957604051632f7a8ee160e01b815260040160405180910390fd5b806115b2612067565b90610ba19082613900565b806115c66121c0565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61164261254b565b6001600160a01b0316336001600160a01b03161461167357604051632f7a8ee160e01b815260040160405180910390fd5b8061167c612067565b600e0190610ba19082613900565b836001600160a01b03811633146116a4576116a4336122e2565b6116b085858585612928565b5050505050565b600061157c821180156108925750610892826121e4565b604080516080810182526000808252602082018190529181018290526060810191909152604080516080810182526000808252602082018190529181018290526060810191909152600183108061172c5750611728612918565b8310155b156117375792915050565b611740836128d1565b90508060400151156117525792915050565b6115698361296c565b6060611766826121e4565b61178357604051630a14c4b560e41b815260040160405180910390fd5b600061178e836116b7565b6118455761179b83610ce5565b6117ac576117a76129a1565b6118da565b6117b4612067565b600d0180546117c290613811565b80601f01602080910402602001604051908101604052809291908181526020018280546117ee90613811565b801561183b5780601f106118105761010080835404028352916020019161183b565b820191906000526020600020905b81548152906001019060200180831161181e57829003601f168201915b50505050506118da565b61184d612067565b600e01805461185b90613811565b80601f016020809104026020016040519081016040528092919081815260200182805461188790613811565b80156118d45780601f106118a9576101008083540402835291602001916118d4565b820191906000526020600020905b8154815290600101906020018083116118b757829003601f168201915b50505050505b90506000816118e8856129b6565b6040516020016118f99291906139bf565b60405160208183030381529060405290508151600003611928576040518060200160405280600081525061192a565b805b949350505050565b6000805b82811015610d4b5761196084848381811061195357611953613845565b9050602002013583612613565b915061196b8161385b565b9050611936565b61197a61254b565b6001600160a01b0316336001600160a01b0316146119ab57604051632f7a8ee160e01b815260040160405180910390fd5b6040516370a0823160e01b815230600482015273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29060009082906370a0823190602401602060405180830381865afa1580156119ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2391906139fe565b90508015611a8657604051632e1a7d4d60e01b8152600481018290526001600160a01b03831690632e1a7d4d90602401600060405180830381600087803b158015611a6d57600080fd5b505af1158015611a81573d6000803e3d6000fd5b505050505b6040516370a0823160e01b81523060048201526ea39bb272e79075ade125fd351887ac9060009082906370a0823190602401602060405180830381865afa158015611ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af991906139fe565b90508015611b5c57604051632e1a7d4d60e01b8152600481018290526001600160a01b03831690632e1a7d4d90602401600060405180830381600087803b158015611b4357600080fd5b505af1158015611b57573d6000803e3d6000fd5b505050505b610d4b612579565b60008060015b61157c8111611ba057611b7c816121e4565b611b8e5781611b8a8161385b565b9250505b80611b988161385b565b915050611b6a565b50919050565b611bae61254b565b6001600160a01b0316336001600160a01b031614611bdf57604051632f7a8ee160e01b815260040160405180910390fd5b8061157c81611bec612096565b611bf691906137fe565b1115611c395760405162461bcd60e51b815260206004820152601260248201527141626f766520546f74616c20537570706c7960701b6044820152606401610959565b610e6083836120a9565b6000611c4d6121c0565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b611c8861254b565b6001600160a01b0316336001600160a01b031614611cb957604051632f7a8ee160e01b815260040160405180910390fd5b80611cc2612067565b600d0190610ba19082613900565b611cd861254b565b6001600160a01b0316336001600160a01b031614611d0957604051632f7a8ee160e01b815260040160405180910390fd5b7ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282280546001600160a01b0319166001600160a01b0393909316929092179091557ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b2820805461ffff191661ffff909216919091179055565b60008080611d9061157c60016137fe565b90505b611d9c816121e4565b15611ba05781611dab8161385b565b9250508080611db99061385b565b915050611d93565b611dc961254b565b6001600160a01b0316336001600160a01b031614611dfa57604051632f7a8ee160e01b815260040160405180910390fd5b6111ff816129fa565b600080516020613b4e83398151915254610100900460ff16611e3857600080516020613b4e8339815191525460ff1615611e3c565b303b155b611eae5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a65640000000000000000006064820152608401610959565b600080516020613b4e83398151915254610100900460ff16158015611eea57600080516020613b4e833981519152805461ffff19166101011790555b611f366040518060400160405280601081526020016f283937b532b1ba1022b73b34b9b4b7b760811b81525060405180604001604052806002815260200161504560f01b815250612a03565b611f3e612a41565b611f46612a7d565b611f4f82611570565b611f5c6003600280611014565b611f7c667c585087238000668700cc75770000669536c7089100006110d3565b611f88306101f4611cd0565b8015610ba1575050600080516020613b4e833981519152805461ff0019169055565b60006301ffc9a760e01b6001600160e01b031983161480611fdb57506380ac58cd60e01b6001600160e01b03198316145b806108925750506001600160e01b031916635b5e139f60e01b1490565b600060418203611569576040516040846040377f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a06060511161205d5784600052604084013560001a602052602060406080600060015afa5060006060523d6060035191505b6040529392505050565b7f270c533d28f00dd65e3b7f8153c97cb575f81183d846e4f29c9618c9428eb77a90565b6111ff816000612a9c565b600060016120a26121c0565b5403919050565b60006120b36121c0565b54905060008290036120d85760405163b562e8dd60e01b815260040160405180910390fd5b6801000000000000000182026120ec6121c0565b6001600160a01b038516600081815260059290920160205260409091208054929092019091554260a01b6001841460e11b17176121276121c0565b600083815260049190910160205260408120919091556001600160a01b038416908383019083908390600080516020613b2e8339815191528180a4600183015b81811461218d5780836000600080516020613b2e833981519152600080a4600101612167565b50816000036121ae57604051622e076360e81b815260040160405180910390fd5b806121b76121c0565b5550610e609050565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b6000816001111580156121fe57506121fa6121c0565b5482105b80156108925750600160e01b6122126121c0565b60008481526004919091016020526040902054161592915050565b600061223883610fa3565b9050811561227757336001600160a01b038216146122775761225a8133611c43565b612277576040516367d9dca160e11b815260040160405180910390fd5b836122806121c0565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b69c617113400112233445560005230601a5280603a52600080604460166daaeb6d7670e522a718067333cd4e5afa61231e573d6000803e3d6000fd5b6000603a5250565b6000612331826127b0565b9050836001600160a01b0316816001600160a01b0316146123645760405162a1148160e81b815260040160405180910390fd5b60008061237084612c0b565b9150915061239581876123803390565b6001600160a01b039081169116811491141790565b6123c0576123a38633611c43565b6123c057604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166123e757604051633a954ecd60e21b815260040160405180910390fd5b80156123f257600082555b6123fa6121c0565b6001600160a01b03871660009081526005919091016020526040902080546000190190556124266121c0565b6001600160a01b03861660008181526005929092016020526040909120805460010190554260a01b17600160e11b1761245d6121c0565b60008681526004919091016020526040812091909155600160e11b841690036124d3576001840161248c6121c0565b6000828152600491909101602052604081205490036124d1576124ad6121c0565b5481146124d157836124bd6121c0565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b0316600080516020613b2e83398151915260405160405180910390a45b505050505050565b600080600061251985612c33565b61ffff16905061252885612c7d565b6127106125358684613a17565b61253f9190613a44565b92509250509250929050565b7f8a22373512790c48b83a1fe2efdd2888d4a917bcdc24d0adf63e60f671680460546001600160a01b031690565b476125ae730db4bcd94e2f64cec5a7a87c943a4bf5a51d5436606461259f846028613a17565b6125a99190613a44565b61285d565b6125d373b397c5be1e8fe89fb269801e636e278e5a6d7d31606461259f846028613a17565b6111ff73b7419b10a2973384b0390a525ab84465d4c72ee1606461259f846014613a17565b610e608383836040518060200160405280600081525061168a565b600061261e836121e4565b6126585760405162461bcd60e51b815260206004820152600b60248201526a151bdad95b88109d5c9b9d60aa1b6044820152606401610959565b3361266284610fa3565b6001600160a01b0316146126a45760405162461bcd60e51b81526020600482015260096024820152682737ba1027bbb732b960b91b6044820152606401610959565b6126ad83610ce5565b156126e95760405162461bcd60e51b815260206004820152600c60248201526b416c726561647920426f6e6560a01b6044820152606401610959565b6126f2836116b7565b1561272c5760405162461bcd60e51b815260206004820152600a602482015269141c9bda1a589a5d195960b21b6044820152606401610959565b60006127388385612ced565b905060328110156127a757600161274d612067565b6000868152600c919091016020908152604091829020805460ff191693151593909317909255518581527ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce7910160405180910390a1611569565b6115698461208b565b600081600111612844576127c26121c0565b600083815260049190910160205260408120549150600160e01b82169003612844578060000361283f576127f46121c0565b54821061281457604051636f96cda160e11b815260040160405180910390fd5b61281c6121c0565b600019909201600081815260049390930160205260409092205490508015612814575b919050565b604051636f96cda160e11b815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146128aa576040519150601f19603f3d011682016040523d82523d6000602084013e6128af565b606091505b5050905080610e605760405163c6d73c5560e01b815260040160405180910390fd5b6040805160808101825260008082526020820181905291810182905260608101919091526108926129006121c0565b60008481526004919091016020526040902054612da9565b60006129226121c0565b54919050565b612933848484610d26565b6001600160a01b0383163b15610d4b5761294f84848484612df0565b610d4b576040516368d2bf6b60e11b815260040160405180910390fd5b60408051608081018252600080825260208201819052918101829052606081019190915261089261299c836127b0565b612da9565b60606129ab612067565b8054610ac590613811565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806129d05750819003601f19909101908152919050565b6111ff81612edb565b600080516020613b4e83398151915254610100900460ff16612a375760405162461bcd60e51b815260040161095990613a58565b610ba18282612f55565b600080516020613b4e83398151915254610100900460ff16612a755760405162461bcd60e51b815260040161095990613a58565b610ea6612fc8565b610ea6733cc6cdda760b79bafa08df41ecfa224f810dceb66001612ffc565b6000612aa7836127b0565b905080600080612ab686612c0b565b915091508415612af657612acb818433612380565b612af657612ad98333611c43565b612af657604051632ce44b5f60e11b815260040160405180910390fd5b8015612b0157600082555b6fffffffffffffffffffffffffffffffff612b1a6121c0565b6001600160a01b038516600081815260059290920160205260409091208054929092019091554260a01b17600360e01b17612b536121c0565b60008881526004919091016020526040812091909155600160e11b85169003612bc95760018601612b826121c0565b600082815260049190910160205260408120549003612bc757612ba36121c0565b548114612bc75784612bb36121c0565b600083815260049190910160205260409020555b505b60405186906000906001600160a01b03861690600080516020613b2e833981519152908390a4612bf76121c0565b600190810180549091019055505050505050565b6000806000612c186121c0565b60009485526006016020525050604090912080549092909150565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f6020819052604082205461ffff1691829003611ba0576001015461ffff1692915050565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282160205260409020546001600160a01b03167ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f81611ba057600301546001600160a01b031692915050565b600080612cfb600143613aac565b40905080612d3d5760405162461bcd60e51b815260206004820152600f60248201526e109b1bd8dac812185cda0811985a5b608a1b6044820152606401610959565b60408051426020808301919091523060601b6bffffffffffffffffffffffff191682840152476054830152607482018490526094820187905260b48083018790528351808403909101815260d49092019092528051910120612da0606482613abf565b95945050505050565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612e25903390899088908890600401613ad3565b6020604051808303816000875af1925050508015612e60575060408051601f3d908101601f19168201909252612e5d91810190613b10565b60015b612ebe573d808015612e8e576040519150601f19603f3d011682016040523d82523d6000602084013e612e93565b606091505b508051600003612eb6576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b7f8a22373512790c48b83a1fe2efdd2888d4a917bcdc24d0adf63e60f67168046080546040516001600160a01b038481169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a380546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020613b4e83398151915254610100900460ff16612f895760405162461bcd60e51b815260040161095990613a58565b81612f926121c0565b60020190612fa09082613900565b5080612faa6121c0565b60030190612fb89082613900565b506001612fc36121c0565b555050565b600080516020613b4e83398151915254610100900460ff16610ea65760405162461bcd60e51b815260040161095990613a58565b6001600160a01b0390911690637d3e3dbe8161302957826130225750634420e486613029565b5063a0af29035b8060e01b60005250306004528160245260008060446000806daaeb6d7670e522a718067333cd4e5af15060006024525050565b6001600160e01b0319811681146111ff57600080fd5b60006020828403121561308457600080fd5b81356115698161305c565b600080600080606085870312156130a557600080fd5b843593506020850135925060408501356001600160401b03808211156130ca57600080fd5b818701915087601f8301126130de57600080fd5b8135818111156130ed57600080fd5b8860208285010111156130ff57600080fd5b95989497505060200194505050565b60005b83811015613129578181015183820152602001613111565b50506000910152565b6000815180845261314a81602086016020860161310e565b601f01601f19169290920160200192915050565b6020815260006115696020830184613132565b60006020828403121561318357600080fd5b5035919050565b80356001600160a01b038116811461283f57600080fd5b600080604083850312156131b457600080fd5b6131bd8361318a565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613209576132096131cb565b604052919050565b6000602080838503121561322457600080fd5b82356001600160401b038082111561323b57600080fd5b818501915085601f83011261324f57600080fd5b813581811115613261576132616131cb565b8060051b91506132728483016131e1565b818152918301840191848101908884111561328c57600080fd5b938501935b838510156132aa57843582529385019390850190613291565b98975050505050505050565b600081518084526020808501945080840160005b838110156132e85781511515875295820195908201906001016132ca565b509495945050505050565b60408152600061330660408301856132b6565b8281036020840152612da081856132b6565b60008060006060848603121561332d57600080fd5b6133368461318a565b92506133446020850161318a565b9150604084013590509250925092565b6000806040838503121561336757600080fd5b50508035926020909101359150565b60008083601f84011261338857600080fd5b5081356001600160401b0381111561339f57600080fd5b6020830191508360208260051b8501011115610de257600080fd5b600080602083850312156133cd57600080fd5b82356001600160401b038111156133e357600080fd5b6133ef85828601613376565b90969095509350505050565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b6020808252825182820181905260009190848201906040850190845b818110156112fe576134668385516133fb565b9284019260809290920191600101613453565b60006020828403121561348b57600080fd5b6115698261318a565b80356001600160401b038116811461283f57600080fd5b6000806000606084860312156134c057600080fd5b6134c984613494565b92506134d760208501613494565b91506134e560408501613494565b90509250925092565b60008060006060848603121561350357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b818110156112fe57835183529284019291840191600101613536565b6000806000806000806060878903121561356b57600080fd5b86356001600160401b038082111561358257600080fd5b61358e8a838b01613376565b909850965060208901359150808211156135a757600080fd5b6135b38a838b01613376565b909650945060408901359150808211156135cc57600080fd5b506135d989828a01613376565b979a9699509497509295939492505050565b60008060006060848603121561360057600080fd5b6136098461318a565b95602085013595506040909401359392505050565b60006001600160401b03831115613637576136376131cb565b61364a601f8401601f19166020016131e1565b905082815283838301111561365e57600080fd5b828260208301376000602084830101529392505050565b60006020828403121561368757600080fd5b81356001600160401b0381111561369d57600080fd5b8201601f810184136136ae57600080fd5b61192a8482356020840161361e565b600080604083850312156136d057600080fd5b6136d98361318a565b9150602083013580151581146136ee57600080fd5b809150509250929050565b6000806000806080858703121561370f57600080fd5b6137188561318a565b93506137266020860161318a565b92506040850135915060608501356001600160401b0381111561374857600080fd5b8501601f8101871361375957600080fd5b6137688782356020840161361e565b91505092959194509250565b6080810161089282846133fb565b6000806040838503121561379557600080fd5b61379e8361318a565b91506137ac6020840161318a565b90509250929050565b600080604083850312156137c857600080fd5b6137d18361318a565b9150602083013561ffff811681146136ee57600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610892576108926137e8565b600181811c9082168061382557607f821691505b602082108103611ba057634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006001820161386d5761386d6137e8565b5060010190565b6000808335601e1984360301811261388b57600080fd5b8301803591506001600160401b038211156138a557600080fd5b602001915036819003821315610de257600080fd5b601f821115610e6057600081815260208120601f850160051c810160208610156138e15750805b601f850160051c820191505b81811015612503578281556001016138ed565b81516001600160401b03811115613919576139196131cb565b61392d816139278454613811565b846138ba565b602080601f831160018114613962576000841561394a5750858301515b600019600386901b1c1916600185901b178555612503565b600085815260208120601f198616915b8281101561399157888601518255948401946001909101908401613972565b50858210156139af5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600083516139d181846020880161310e565b8351908301906139e581836020880161310e565b64173539b7b760d91b9101908152600501949350505050565b600060208284031215613a1057600080fd5b5051919050565b8082028115828204841417610892576108926137e8565b634e487b7160e01b600052601260045260246000fd5b600082613a5357613a53613a2e565b500490565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b81810381811115610892576108926137e8565b600082613ace57613ace613a2e565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613b0690830184613132565b9695505050505050565b600060208284031215613b2257600080fd5b81516115698161305c56feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa26469706673582212200ee489bc1ed838c8eacedd0f5f9f46c9bae8c19ed9dd3252de5b6717101a3dc364736f6c63430008110033

Deployed Bytecode

0x6080604052600436106102725760003560e01c80637783ef3f1161014f578063c23dc68f116100c1578063e985e9c51161007a578063e985e9c51461079d578063e9931407146107bd578063ebdf0919146107dd578063f0e2a569146107fd578063f2fde38b14610812578063f62d18881461083257600080fd5b8063c23dc68f146106e6578063c87b56dd14610713578063cf32346014610733578063d1e191a414610753578063d7da6dcf14610768578063e1b6d92e1461077d57600080fd5b806399a2557a1161011357806399a2557a14610633578063a0bcfc7f14610653578063a22cb46514610673578063a27dd71b14610693578063b88d4fde146106b3578063ba1980b3146106c657600080fd5b80637783ef3f1461059c5780638462151c146105bc5780638da5cb5b146105e9578063909a33f7146105fe57806395d89b411461061e57600080fd5b806332cb6b0c116101e85780635bbb2177116101ac5780635bbb2177146104cf5780636352211e146104fc5780636c19e7831461051c5780636cbca5471461053c5780636fb081a41461055c57806370a082311461057c57600080fd5b806332cb6b0c1461045157806335397e1f146104675780633ccfd60b1461048757806342842e0e1461049c57806342966c68146104af57600080fd5b80630c62d2851161023a5780630c62d2851461033b5780631314be6a1461036957806318160ddd1461038957806323b872dd146103ac57806325bdb2a8146103bf5780632a55205a1461041257600080fd5b806301ffc9a714610277578063064bd41a146102ac57806306fdde03146102ce578063081812fc146102f0578063095ea7b314610328575b600080fd5b34801561028357600080fd5b50610297610292366004613072565b610852565b60405190151581526020015b60405180910390f35b3480156102b857600080fd5b506102cc6102c736600461308f565b610898565b005b3480156102da57600080fd5b506102e3610aad565b6040516102a3919061315e565b3480156102fc57600080fd5b5061031061030b366004613171565b610b48565b6040516001600160a01b0390911681526020016102a3565b6102cc6103363660046131a1565b610b95565b34801561034757600080fd5b5061035b610356366004613211565b610ba5565b6040516102a39291906132f3565b34801561037557600080fd5b50610297610384366004613171565b610ce5565b34801561039557600080fd5b5061039e610d06565b6040519081526020016102a3565b6102cc6103ba366004613318565b610d26565b3480156103cb57600080fd5b506103d4610d51565b604080516001600160401b039788168152958716602087015293909516928401929092526060830152608082015260a081019190915260c0016102a3565b34801561041e57600080fd5b5061043261042d366004613354565b610dd0565b604080516001600160a01b0390931683526020830191909152016102a3565b34801561045d57600080fd5b5061039e61157c81565b34801561047357600080fd5b506102cc6104823660046133ba565b610de9565b34801561049357600080fd5b506102cc610e65565b6102cc6104aa366004613318565b610ea8565b3480156104bb57600080fd5b506102cc6104ca366004613171565b610ecd565b3480156104db57600080fd5b506104ef6104ea3660046133ba565b610ed8565b6040516102a39190613437565b34801561050857600080fd5b50610310610517366004613171565b610fa3565b34801561052857600080fd5b506102cc610537366004613479565b610fae565b34801561054857600080fd5b506102cc6105573660046134ab565b611014565b34801561056857600080fd5b506102cc6105773660046134ee565b6110d3565b34801561058857600080fd5b5061039e610597366004613479565b611138565b3480156105a857600080fd5b506102cc6105b7366004613171565b6111a0565b3480156105c857600080fd5b506105dc6105d7366004613479565b611202565b6040516102a3919061351a565b3480156105f557600080fd5b5061031061130a565b34801561060a57600080fd5b506102cc610619366004613552565b611319565b34801561062a57600080fd5b506102e36113d2565b34801561063f57600080fd5b506105dc61064e3660046135eb565b6113ea565b34801561065f57600080fd5b506102cc61066e366004613675565b611570565b34801561067f57600080fd5b506102cc61068e3660046136bd565b6115bd565b34801561069f57600080fd5b506102cc6106ae366004613675565b61163a565b6102cc6106c13660046136f9565b61168a565b3480156106d257600080fd5b506102976106e1366004613171565b6116b7565b3480156106f257600080fd5b50610706610701366004613171565b6116ce565b6040516102a39190613774565b34801561071f57600080fd5b506102e361072e366004613171565b61175b565b34801561073f57600080fd5b506102cc61074e3660046133ba565b611932565b34801561075f57600080fd5b506102cc611972565b34801561077457600080fd5b5061039e611b64565b34801561078957600080fd5b506102cc6107983660046131a1565b611ba6565b3480156107a957600080fd5b506102976107b8366004613782565b611c43565b3480156107c957600080fd5b506102cc6107d8366004613675565b611c80565b3480156107e957600080fd5b506102cc6107f83660046137b5565b611cd0565b34801561080957600080fd5b5061039e611d7f565b34801561081e57600080fd5b506102cc61082d366004613479565b611dc1565b34801561083e57600080fd5b506102cc61084d366004613675565b611e03565b600063152a902d60e11b6001600160e01b0319831614806108835750632483248360e11b6001600160e01b03198316145b80610892575061089282611faa565b92915050565b6040805160208101869052908101849052600090606001604051602081830303815290604052805190602001209050600061090484846108fd856020527b19457468657265756d205369676e6564204d6573736167653a0a3332600052603c60042090565b9190611ff8565b9050806001600160a01b0316610918612067565b600f01546001600160a01b0316146109625760405162461bcd60e51b815260206004820152600860248201526742616420426f6e6560c01b60448201526064015b60405180910390fd5b3361096c87610fa3565b6001600160a01b0316146109ae5760405162461bcd60e51b81526020600482015260096024820152682737ba1027bbb732b960b91b6044820152606401610959565b6109b786610ce5565b6109ee5760405162461bcd60e51b81526020600482015260086024820152674e6f7420426f6e6560c01b6044820152606401610959565b6109f7866116b7565b15610a375760405162461bcd60e51b815260206004820152601060248201526f105b1c9958591e4814dd5b5b5bdb995960821b6044820152606401610959565b610a408661208b565b6000610a4a612096565b90507f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c610a788260016137fe565b610a8288846137fe565b6040805192835260208301919091520160405180910390a1610aa433876120a9565b50505050505050565b6060610ab76121c0565b6002018054610ac590613811565b80601f0160208091040260200160405190810160405280929190818152602001828054610af190613811565b8015610b3e5780601f10610b1357610100808354040283529160200191610b3e565b820191906000526020600020905b815481529060010190602001808311610b2157829003601f168201915b5050505050905090565b6000610b53826121e4565b610b70576040516333d1c03960e21b815260040160405180910390fd5b610b786121c0565b60009283526006016020525060409020546001600160a01b031690565b610ba18282600161222d565b5050565b606080600083516001600160401b03811115610bc357610bc36131cb565b604051908082528060200260200182016040528015610bec578160200160208202803683370190505b509050600084516001600160401b03811115610c0a57610c0a6131cb565b604051908082528060200260200182016040528015610c33578160200160208202803683370190505b50905060005b8551811015610cda57610c64868281518110610c5757610c57613845565b6020026020010151610ce5565b838281518110610c7657610c76613845565b60200260200101901515908115158152505061157c868281518110610c9d57610c9d613845565b602002602001015111828281518110610cb857610cb8613845565b9115156020928302919091019091015280610cd28161385b565b915050610c39565b509094909350915050565b6000610cef612067565b6000928352600c0160205250604090205460ff1690565b60006001610d126121c0565b60010154610d1e6121c0565b540303919050565b826001600160a01b0381163314610d4057610d40336122e2565b610d4b848484612326565b50505050565b600080600080600080610d62612067565b600301546001600160401b0316610d77612067565b600501546001600160401b0316610d8c612067565b600701546001600160401b0316610da1612067565b60020154610dad612067565b60040154610db9612067565b60060154949b939a50919850965094509092509050565b600080610ddd848461250b565b915091505b9250929050565b610df161254b565b6001600160a01b0316336001600160a01b031614610e2257604051632f7a8ee160e01b815260040160405180910390fd5b60005b81811015610e6057610e4e838383818110610e4257610e42613845565b9050602002013561208b565b80610e588161385b565b915050610e25565b505050565b610e6d61254b565b6001600160a01b0316336001600160a01b031614610e9e57604051632f7a8ee160e01b815260040160405180910390fd5b610ea6612579565b565b826001600160a01b0381163314610ec257610ec2336122e2565b610d4b8484846125f8565b610ba1816000612613565b6060816000816001600160401b03811115610ef557610ef56131cb565b604051908082528060200260200182016040528015610f4757816020015b604080516080810182526000808252602080830182905292820181905260608201528252600019909201910181610f135790505b50905060005b828114610f9a57610f75868683818110610f6957610f69613845565b905060200201356116ce565b828281518110610f8757610f87613845565b6020908102919091010152600101610f4d565b50949350505050565b6000610892826127b0565b610fb661254b565b6001600160a01b0316336001600160a01b031614610fe757604051632f7a8ee160e01b815260040160405180910390fd5b80610ff0612067565b600f0180546001600160a01b0319166001600160a01b039290921691909117905550565b61101c61254b565b6001600160a01b0316336001600160a01b03161461104d57604051632f7a8ee160e01b815260040160405180910390fd5b82611056612067565b600301805467ffffffffffffffff19166001600160401b039290921691909117905581611081612067565b600501805467ffffffffffffffff19166001600160401b0392909216919091179055806110ac612067565b600701805467ffffffffffffffff19166001600160401b0392909216919091179055505050565b6110db61254b565b6001600160a01b0316336001600160a01b03161461110c57604051632f7a8ee160e01b815260040160405180910390fd5b82611115612067565b6002015580611122612067565b600601558161112f612067565b60040155505050565b60006001600160a01b038216611161576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b036111716121c0565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b6111a861254b565b6001600160a01b0316336001600160a01b0316146111d957604051632f7a8ee160e01b815260040160405180910390fd5b670de0b6b3a76400008111156111ee57600080fd5b6111ff6111f961130a565b8261285d565b50565b6060600080600061121285611138565b90506000816001600160401b0381111561122e5761122e6131cb565b604051908082528060200260200182016040528015611257578160200160208202803683370190505b50905061128460408051608081018252600080825260208201819052918101829052606081019190915290565b60015b8386146112fe57611297816128d1565b915081604001516112f65781516001600160a01b0316156112b757815194505b876001600160a01b0316856001600160a01b0316036112f657808387806001019850815181106112e9576112e9613845565b6020026020010181815250505b600101611287565b50909695505050505050565b600061131461254b565b905090565b848314801561132757508481145b61135e5760405162461bcd60e51b815260206004820152600860248201526709ad2e6dac2e8c6d60c31b6044820152606401610959565b60005b85811015610aa4576113c287878381811061137e5761137e613845565b9050602002013586868481811061139757611397613845565b905060200201358585858181106113b0576113b0613845565b90506020028101906102c79190613874565b6113cb8161385b565b9050611361565b60606113dc6121c0565b6003018054610ac590613811565b606081831061140c57604051631960ccad60e11b815260040160405180910390fd5b600080611417612918565b9050600185101561142757600194505b80841115611433578093505b600061143e87611138565b90508486101561145d5785850381811015611457578091505b50611461565b5060005b6000816001600160401b0381111561147b5761147b6131cb565b6040519080825280602002602001820160405280156114a4578160200160208202803683370190505b509050816000036114ba57935061156992505050565b60006114c5886116ce565b9050600081604001516114d6575080515b885b8881141580156114e85750848714155b1561155d576114f6816128d1565b925082604001516115555782516001600160a01b03161561151657825191505b8a6001600160a01b0316826001600160a01b031603611555578084888060010199508151811061154857611548613845565b6020026020010181815250505b6001016114d8565b50505092835250909150505b9392505050565b61157861254b565b6001600160a01b0316336001600160a01b0316146115a957604051632f7a8ee160e01b815260040160405180910390fd5b806115b2612067565b90610ba19082613900565b806115c66121c0565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61164261254b565b6001600160a01b0316336001600160a01b03161461167357604051632f7a8ee160e01b815260040160405180910390fd5b8061167c612067565b600e0190610ba19082613900565b836001600160a01b03811633146116a4576116a4336122e2565b6116b085858585612928565b5050505050565b600061157c821180156108925750610892826121e4565b604080516080810182526000808252602082018190529181018290526060810191909152604080516080810182526000808252602082018190529181018290526060810191909152600183108061172c5750611728612918565b8310155b156117375792915050565b611740836128d1565b90508060400151156117525792915050565b6115698361296c565b6060611766826121e4565b61178357604051630a14c4b560e41b815260040160405180910390fd5b600061178e836116b7565b6118455761179b83610ce5565b6117ac576117a76129a1565b6118da565b6117b4612067565b600d0180546117c290613811565b80601f01602080910402602001604051908101604052809291908181526020018280546117ee90613811565b801561183b5780601f106118105761010080835404028352916020019161183b565b820191906000526020600020905b81548152906001019060200180831161181e57829003601f168201915b50505050506118da565b61184d612067565b600e01805461185b90613811565b80601f016020809104026020016040519081016040528092919081815260200182805461188790613811565b80156118d45780601f106118a9576101008083540402835291602001916118d4565b820191906000526020600020905b8154815290600101906020018083116118b757829003601f168201915b50505050505b90506000816118e8856129b6565b6040516020016118f99291906139bf565b60405160208183030381529060405290508151600003611928576040518060200160405280600081525061192a565b805b949350505050565b6000805b82811015610d4b5761196084848381811061195357611953613845565b9050602002013583612613565b915061196b8161385b565b9050611936565b61197a61254b565b6001600160a01b0316336001600160a01b0316146119ab57604051632f7a8ee160e01b815260040160405180910390fd5b6040516370a0823160e01b815230600482015273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc29060009082906370a0823190602401602060405180830381865afa1580156119ff573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a2391906139fe565b90508015611a8657604051632e1a7d4d60e01b8152600481018290526001600160a01b03831690632e1a7d4d90602401600060405180830381600087803b158015611a6d57600080fd5b505af1158015611a81573d6000803e3d6000fd5b505050505b6040516370a0823160e01b81523060048201526ea39bb272e79075ade125fd351887ac9060009082906370a0823190602401602060405180830381865afa158015611ad5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af991906139fe565b90508015611b5c57604051632e1a7d4d60e01b8152600481018290526001600160a01b03831690632e1a7d4d90602401600060405180830381600087803b158015611b4357600080fd5b505af1158015611b57573d6000803e3d6000fd5b505050505b610d4b612579565b60008060015b61157c8111611ba057611b7c816121e4565b611b8e5781611b8a8161385b565b9250505b80611b988161385b565b915050611b6a565b50919050565b611bae61254b565b6001600160a01b0316336001600160a01b031614611bdf57604051632f7a8ee160e01b815260040160405180910390fd5b8061157c81611bec612096565b611bf691906137fe565b1115611c395760405162461bcd60e51b815260206004820152601260248201527141626f766520546f74616c20537570706c7960701b6044820152606401610959565b610e6083836120a9565b6000611c4d6121c0565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b611c8861254b565b6001600160a01b0316336001600160a01b031614611cb957604051632f7a8ee160e01b815260040160405180910390fd5b80611cc2612067565b600d0190610ba19082613900565b611cd861254b565b6001600160a01b0316336001600160a01b031614611d0957604051632f7a8ee160e01b815260040160405180910390fd5b7ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282280546001600160a01b0319166001600160a01b0393909316929092179091557ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b2820805461ffff191661ffff909216919091179055565b60008080611d9061157c60016137fe565b90505b611d9c816121e4565b15611ba05781611dab8161385b565b9250508080611db99061385b565b915050611d93565b611dc961254b565b6001600160a01b0316336001600160a01b031614611dfa57604051632f7a8ee160e01b815260040160405180910390fd5b6111ff816129fa565b600080516020613b4e83398151915254610100900460ff16611e3857600080516020613b4e8339815191525460ff1615611e3c565b303b155b611eae5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a65640000000000000000006064820152608401610959565b600080516020613b4e83398151915254610100900460ff16158015611eea57600080516020613b4e833981519152805461ffff19166101011790555b611f366040518060400160405280601081526020016f283937b532b1ba1022b73b34b9b4b7b760811b81525060405180604001604052806002815260200161504560f01b815250612a03565b611f3e612a41565b611f46612a7d565b611f4f82611570565b611f5c6003600280611014565b611f7c667c585087238000668700cc75770000669536c7089100006110d3565b611f88306101f4611cd0565b8015610ba1575050600080516020613b4e833981519152805461ff0019169055565b60006301ffc9a760e01b6001600160e01b031983161480611fdb57506380ac58cd60e01b6001600160e01b03198316145b806108925750506001600160e01b031916635b5e139f60e01b1490565b600060418203611569576040516040846040377f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a06060511161205d5784600052604084013560001a602052602060406080600060015afa5060006060523d6060035191505b6040529392505050565b7f270c533d28f00dd65e3b7f8153c97cb575f81183d846e4f29c9618c9428eb77a90565b6111ff816000612a9c565b600060016120a26121c0565b5403919050565b60006120b36121c0565b54905060008290036120d85760405163b562e8dd60e01b815260040160405180910390fd5b6801000000000000000182026120ec6121c0565b6001600160a01b038516600081815260059290920160205260409091208054929092019091554260a01b6001841460e11b17176121276121c0565b600083815260049190910160205260408120919091556001600160a01b038416908383019083908390600080516020613b2e8339815191528180a4600183015b81811461218d5780836000600080516020613b2e833981519152600080a4600101612167565b50816000036121ae57604051622e076360e81b815260040160405180910390fd5b806121b76121c0565b5550610e609050565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b6000816001111580156121fe57506121fa6121c0565b5482105b80156108925750600160e01b6122126121c0565b60008481526004919091016020526040902054161592915050565b600061223883610fa3565b9050811561227757336001600160a01b038216146122775761225a8133611c43565b612277576040516367d9dca160e11b815260040160405180910390fd5b836122806121c0565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b69c617113400112233445560005230601a5280603a52600080604460166daaeb6d7670e522a718067333cd4e5afa61231e573d6000803e3d6000fd5b6000603a5250565b6000612331826127b0565b9050836001600160a01b0316816001600160a01b0316146123645760405162a1148160e81b815260040160405180910390fd5b60008061237084612c0b565b9150915061239581876123803390565b6001600160a01b039081169116811491141790565b6123c0576123a38633611c43565b6123c057604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166123e757604051633a954ecd60e21b815260040160405180910390fd5b80156123f257600082555b6123fa6121c0565b6001600160a01b03871660009081526005919091016020526040902080546000190190556124266121c0565b6001600160a01b03861660008181526005929092016020526040909120805460010190554260a01b17600160e11b1761245d6121c0565b60008681526004919091016020526040812091909155600160e11b841690036124d3576001840161248c6121c0565b6000828152600491909101602052604081205490036124d1576124ad6121c0565b5481146124d157836124bd6121c0565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b0316600080516020613b2e83398151915260405160405180910390a45b505050505050565b600080600061251985612c33565b61ffff16905061252885612c7d565b6127106125358684613a17565b61253f9190613a44565b92509250509250929050565b7f8a22373512790c48b83a1fe2efdd2888d4a917bcdc24d0adf63e60f671680460546001600160a01b031690565b476125ae730db4bcd94e2f64cec5a7a87c943a4bf5a51d5436606461259f846028613a17565b6125a99190613a44565b61285d565b6125d373b397c5be1e8fe89fb269801e636e278e5a6d7d31606461259f846028613a17565b6111ff73b7419b10a2973384b0390a525ab84465d4c72ee1606461259f846014613a17565b610e608383836040518060200160405280600081525061168a565b600061261e836121e4565b6126585760405162461bcd60e51b815260206004820152600b60248201526a151bdad95b88109d5c9b9d60aa1b6044820152606401610959565b3361266284610fa3565b6001600160a01b0316146126a45760405162461bcd60e51b81526020600482015260096024820152682737ba1027bbb732b960b91b6044820152606401610959565b6126ad83610ce5565b156126e95760405162461bcd60e51b815260206004820152600c60248201526b416c726561647920426f6e6560a01b6044820152606401610959565b6126f2836116b7565b1561272c5760405162461bcd60e51b815260206004820152600a602482015269141c9bda1a589a5d195960b21b6044820152606401610959565b60006127388385612ced565b905060328110156127a757600161274d612067565b6000868152600c919091016020908152604091829020805460ff191693151593909317909255518581527ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce7910160405180910390a1611569565b6115698461208b565b600081600111612844576127c26121c0565b600083815260049190910160205260408120549150600160e01b82169003612844578060000361283f576127f46121c0565b54821061281457604051636f96cda160e11b815260040160405180910390fd5b61281c6121c0565b600019909201600081815260049390930160205260409092205490508015612814575b919050565b604051636f96cda160e11b815260040160405180910390fd5b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146128aa576040519150601f19603f3d011682016040523d82523d6000602084013e6128af565b606091505b5050905080610e605760405163c6d73c5560e01b815260040160405180910390fd5b6040805160808101825260008082526020820181905291810182905260608101919091526108926129006121c0565b60008481526004919091016020526040902054612da9565b60006129226121c0565b54919050565b612933848484610d26565b6001600160a01b0383163b15610d4b5761294f84848484612df0565b610d4b576040516368d2bf6b60e11b815260040160405180910390fd5b60408051608081018252600080825260208201819052918101829052606081019190915261089261299c836127b0565b612da9565b60606129ab612067565b8054610ac590613811565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806129d05750819003601f19909101908152919050565b6111ff81612edb565b600080516020613b4e83398151915254610100900460ff16612a375760405162461bcd60e51b815260040161095990613a58565b610ba18282612f55565b600080516020613b4e83398151915254610100900460ff16612a755760405162461bcd60e51b815260040161095990613a58565b610ea6612fc8565b610ea6733cc6cdda760b79bafa08df41ecfa224f810dceb66001612ffc565b6000612aa7836127b0565b905080600080612ab686612c0b565b915091508415612af657612acb818433612380565b612af657612ad98333611c43565b612af657604051632ce44b5f60e11b815260040160405180910390fd5b8015612b0157600082555b6fffffffffffffffffffffffffffffffff612b1a6121c0565b6001600160a01b038516600081815260059290920160205260409091208054929092019091554260a01b17600360e01b17612b536121c0565b60008881526004919091016020526040812091909155600160e11b85169003612bc95760018601612b826121c0565b600082815260049190910160205260408120549003612bc757612ba36121c0565b548114612bc75784612bb36121c0565b600083815260049190910160205260409020555b505b60405186906000906001600160a01b03861690600080516020613b2e833981519152908390a4612bf76121c0565b600190810180549091019055505050505050565b6000806000612c186121c0565b60009485526006016020525050604090912080549092909150565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f6020819052604082205461ffff1691829003611ba0576001015461ffff1692915050565b60008181527ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b282160205260409020546001600160a01b03167ff298352fd56f58214bf2245c2b202523f72fca3199077ce992640958228b281f81611ba057600301546001600160a01b031692915050565b600080612cfb600143613aac565b40905080612d3d5760405162461bcd60e51b815260206004820152600f60248201526e109b1bd8dac812185cda0811985a5b608a1b6044820152606401610959565b60408051426020808301919091523060601b6bffffffffffffffffffffffff191682840152476054830152607482018490526094820187905260b48083018790528351808403909101815260d49092019092528051910120612da0606482613abf565b95945050505050565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612e25903390899088908890600401613ad3565b6020604051808303816000875af1925050508015612e60575060408051601f3d908101601f19168201909252612e5d91810190613b10565b60015b612ebe573d808015612e8e576040519150601f19603f3d011682016040523d82523d6000602084013e612e93565b606091505b508051600003612eb6576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b7f8a22373512790c48b83a1fe2efdd2888d4a917bcdc24d0adf63e60f67168046080546040516001600160a01b038481169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a380546001600160a01b0319166001600160a01b0392909216919091179055565b600080516020613b4e83398151915254610100900460ff16612f895760405162461bcd60e51b815260040161095990613a58565b81612f926121c0565b60020190612fa09082613900565b5080612faa6121c0565b60030190612fb89082613900565b506001612fc36121c0565b555050565b600080516020613b4e83398151915254610100900460ff16610ea65760405162461bcd60e51b815260040161095990613a58565b6001600160a01b0390911690637d3e3dbe8161302957826130225750634420e486613029565b5063a0af29035b8060e01b60005250306004528160245260008060446000806daaeb6d7670e522a718067333cd4e5af15060006024525050565b6001600160e01b0319811681146111ff57600080fd5b60006020828403121561308457600080fd5b81356115698161305c565b600080600080606085870312156130a557600080fd5b843593506020850135925060408501356001600160401b03808211156130ca57600080fd5b818701915087601f8301126130de57600080fd5b8135818111156130ed57600080fd5b8860208285010111156130ff57600080fd5b95989497505060200194505050565b60005b83811015613129578181015183820152602001613111565b50506000910152565b6000815180845261314a81602086016020860161310e565b601f01601f19169290920160200192915050565b6020815260006115696020830184613132565b60006020828403121561318357600080fd5b5035919050565b80356001600160a01b038116811461283f57600080fd5b600080604083850312156131b457600080fd5b6131bd8361318a565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613209576132096131cb565b604052919050565b6000602080838503121561322457600080fd5b82356001600160401b038082111561323b57600080fd5b818501915085601f83011261324f57600080fd5b813581811115613261576132616131cb565b8060051b91506132728483016131e1565b818152918301840191848101908884111561328c57600080fd5b938501935b838510156132aa57843582529385019390850190613291565b98975050505050505050565b600081518084526020808501945080840160005b838110156132e85781511515875295820195908201906001016132ca565b509495945050505050565b60408152600061330660408301856132b6565b8281036020840152612da081856132b6565b60008060006060848603121561332d57600080fd5b6133368461318a565b92506133446020850161318a565b9150604084013590509250925092565b6000806040838503121561336757600080fd5b50508035926020909101359150565b60008083601f84011261338857600080fd5b5081356001600160401b0381111561339f57600080fd5b6020830191508360208260051b8501011115610de257600080fd5b600080602083850312156133cd57600080fd5b82356001600160401b038111156133e357600080fd5b6133ef85828601613376565b90969095509350505050565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b6020808252825182820181905260009190848201906040850190845b818110156112fe576134668385516133fb565b9284019260809290920191600101613453565b60006020828403121561348b57600080fd5b6115698261318a565b80356001600160401b038116811461283f57600080fd5b6000806000606084860312156134c057600080fd5b6134c984613494565b92506134d760208501613494565b91506134e560408501613494565b90509250925092565b60008060006060848603121561350357600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b818110156112fe57835183529284019291840191600101613536565b6000806000806000806060878903121561356b57600080fd5b86356001600160401b038082111561358257600080fd5b61358e8a838b01613376565b909850965060208901359150808211156135a757600080fd5b6135b38a838b01613376565b909650945060408901359150808211156135cc57600080fd5b506135d989828a01613376565b979a9699509497509295939492505050565b60008060006060848603121561360057600080fd5b6136098461318a565b95602085013595506040909401359392505050565b60006001600160401b03831115613637576136376131cb565b61364a601f8401601f19166020016131e1565b905082815283838301111561365e57600080fd5b828260208301376000602084830101529392505050565b60006020828403121561368757600080fd5b81356001600160401b0381111561369d57600080fd5b8201601f810184136136ae57600080fd5b61192a8482356020840161361e565b600080604083850312156136d057600080fd5b6136d98361318a565b9150602083013580151581146136ee57600080fd5b809150509250929050565b6000806000806080858703121561370f57600080fd5b6137188561318a565b93506137266020860161318a565b92506040850135915060608501356001600160401b0381111561374857600080fd5b8501601f8101871361375957600080fd5b6137688782356020840161361e565b91505092959194509250565b6080810161089282846133fb565b6000806040838503121561379557600080fd5b61379e8361318a565b91506137ac6020840161318a565b90509250929050565b600080604083850312156137c857600080fd5b6137d18361318a565b9150602083013561ffff811681146136ee57600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610892576108926137e8565b600181811c9082168061382557607f821691505b602082108103611ba057634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b60006001820161386d5761386d6137e8565b5060010190565b6000808335601e1984360301811261388b57600080fd5b8301803591506001600160401b038211156138a557600080fd5b602001915036819003821315610de257600080fd5b601f821115610e6057600081815260208120601f850160051c810160208610156138e15750805b601f850160051c820191505b81811015612503578281556001016138ed565b81516001600160401b03811115613919576139196131cb565b61392d816139278454613811565b846138ba565b602080601f831160018114613962576000841561394a5750858301515b600019600386901b1c1916600185901b178555612503565b600085815260208120601f198616915b8281101561399157888601518255948401946001909101908401613972565b50858210156139af5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600083516139d181846020880161310e565b8351908301906139e581836020880161310e565b64173539b7b760d91b9101908152600501949350505050565b600060208284031215613a1057600080fd5b5051919050565b8082028115828204841417610892576108926137e8565b634e487b7160e01b600052601260045260246000fd5b600082613a5357613a53613a2e565b500490565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b81810381811115610892576108926137e8565b600082613ace57613ace613a2e565b500690565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613b0690830184613132565b9695505050505050565b600060208284031215613b2257600080fd5b81516115698161305c56feddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa26469706673582212200ee489bc1ed838c8eacedd0f5f9f46c9bae8c19ed9dd3252de5b6717101a3dc364736f6c63430008110033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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