ETH Price: $3,309.03 (-4.07%)

Contract

0xfa1B15dF09c2944a91A2F9F10A6133090d4119BD
 

Overview

ETH Balance

0.0069 ETH

Eth Value

$22.83 (@ $3,309.03/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Burn Redeem211176642024-11-04 23:47:1122 days ago1730764031IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.000903395.35724008
Update Burn Rede...211176252024-11-04 23:39:2322 days ago1730763563IN
0xfa1B15dF...90d4119BD
0 ETH0.000462785.63745989
Burn Redeem210733582024-10-29 19:22:5928 days ago1730229779IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0029489719.32993456
Burn Redeem210516052024-10-26 18:31:5931 days ago1729967519IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.001069417.00982427
Burn Redeem210235862024-10-22 20:44:2335 days ago1729629863IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0014478310.32248207
Burn Redeem210229122024-10-22 18:28:2335 days ago1729621703IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0016003410.48995453
Burn Redeem209690202024-10-15 5:57:1142 days ago1728971831IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0016166911.93488189
Burn Redeem209661082024-10-14 20:11:3543 days ago1728936695IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0033967125.07537367
Burn Redeem209501462024-10-12 14:34:2345 days ago1728743663IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0079690652.23559326
Burn Redeem209461992024-10-12 1:18:2345 days ago1728695903IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.001294179.22696392
Burn Redeem209354952024-10-10 13:25:3547 days ago1728566735IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0036036823.62140082
Update Burn Rede...209290052024-10-09 15:43:1148 days ago1728488591IN
0xfa1B15dF...90d4119BD
0 ETH0.0049662.38212123
Burn Redeem209184642024-10-08 4:27:3549 days ago1728361655IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0015169111.19824241
Burn Redeem208945922024-10-04 20:36:1153 days ago1728074171IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.000960446.29551445
Burn Redeem208668292024-09-30 23:42:1157 days ago1727739731IN
0xfa1B15dF...90d4119BD
0.03243 ETH0.001182198.41634881
Burn Redeem208667462024-09-30 23:25:2357 days ago1727738723IN
0xfa1B15dF...90d4119BD
0.0207 ETH0.000982976.99802085
Update Burn Rede...206575822024-09-01 18:42:1186 days ago1725216131IN
0xfa1B15dF...90d4119BD
0 ETH0.000106821.29856363
Update Burn Rede...206575562024-09-01 18:36:5986 days ago1725215819IN
0xfa1B15dF...90d4119BD
0 ETH0.000111581.35649388
Update Burn Rede...202090282024-07-01 3:37:23148 days ago1719805043IN
0xfa1B15dF...90d4119BD
0 ETH0.000263813.20514975
Burn Redeem201301422024-06-20 3:03:59159 days ago1718852639IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.000678775.01085323
Burn Redeem196842822024-04-18 18:59:35222 days ago1713466775IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0016037110.77819437
Burn Redeem196834462024-04-18 16:10:47222 days ago1713456647IN
0xfa1B15dF...90d4119BD
0.00969 ETH0.0030398817.47713712
Update Burn Rede...196570422024-04-14 23:27:59226 days ago1713137279IN
0xfa1B15dF...90d4119BD
0 ETH0.000751079.08396772
Burn Redeem195525352024-03-31 7:56:35240 days ago1711871795IN
0xfa1B15dF...90d4119BD
0.00069 ETH0.0025734717.83397785
Update Burn Rede...195392512024-03-29 11:05:23242 days ago1711710323IN
0xfa1B15dF...90d4119BD
0 ETH0.0015281418.5175547
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
209244042024-10-09 0:20:2349 days ago1728433223
0xfa1B15dF...90d4119BD
45.67368 ETH
196834462024-04-18 16:10:47222 days ago1713456647
0xfa1B15dF...90d4119BD
0.009 ETH
194627022024-03-18 15:56:11253 days ago1710777371
0xfa1B15dF...90d4119BD
0.009 ETH
194598192024-03-18 6:11:59253 days ago1710742319
0xfa1B15dF...90d4119BD
0.009 ETH
194465112024-03-16 9:17:11255 days ago1710580631
0xfa1B15dF...90d4119BD
0.009 ETH
193881632024-03-08 4:48:11263 days ago1709873291
0xfa1B15dF...90d4119BD
0.009 ETH
192663492024-02-20 3:50:35280 days ago1708401035
0xfa1B15dF...90d4119BD
0.0009 ETH
192663492024-02-20 3:50:35280 days ago1708401035
0xfa1B15dF...90d4119BD
0.009 ETH
192663492024-02-20 3:50:35280 days ago1708401035
0xfa1B15dF...90d4119BD
0.009 ETH
192663492024-02-20 3:50:35280 days ago1708401035
0xfa1B15dF...90d4119BD
0.009 ETH
192211182024-02-13 19:20:35287 days ago1707852035
0xfa1B15dF...90d4119BD
0.0006 ETH
192211182024-02-13 19:20:35287 days ago1707852035
0xfa1B15dF...90d4119BD
0.009 ETH
192211182024-02-13 19:20:35287 days ago1707852035
0xfa1B15dF...90d4119BD
0.009 ETH
191975202024-02-10 11:50:11290 days ago1707565811
0xfa1B15dF...90d4119BD
0.0006 ETH
191975202024-02-10 11:50:11290 days ago1707565811
0xfa1B15dF...90d4119BD
0.009 ETH
191975202024-02-10 11:50:11290 days ago1707565811
0xfa1B15dF...90d4119BD
0.009 ETH
180174432023-08-29 2:55:23455 days ago1693277723
0xfa1B15dF...90d4119BD
0.0006 ETH
179746272023-08-23 3:08:47461 days ago1692760127
0xfa1B15dF...90d4119BD
0.0006 ETH
179454022023-08-19 0:59:11466 days ago1692406751
0xfa1B15dF...90d4119BD
0.00069 ETH
179453942023-08-19 0:57:35466 days ago1692406655
0xfa1B15dF...90d4119BD
0.00069 ETH
179453882023-08-19 0:56:23466 days ago1692406583
0xfa1B15dF...90d4119BD
0.00069 ETH
177155002023-07-17 20:56:59498 days ago1689627419
0xfa1B15dF...90d4119BD
0.0069 ETH
171515602023-04-29 11:48:47577 days ago1682768927
0xfa1B15dF...90d4119BD
0.01 ETH
171428162023-04-28 6:22:23578 days ago1682662943
0xfa1B15dF...90d4119BD
0.01 ETH
171428162023-04-28 6:22:23578 days ago1682662943
0xfa1B15dF...90d4119BD
0.01 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC1155BurnRedeem

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 500 runs

Other Settings:
default evmVersion
File 1 of 27 : ERC1155BurnRedeem.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@manifoldxyz/creator-core-solidity/contracts/core/IERC1155CreatorCore.sol";

import "./BurnRedeemCore.sol";
import "./IERC1155BurnRedeem.sol";

contract ERC1155BurnRedeem is BurnRedeemCore, IERC1155BurnRedeem {
    using Strings for uint256;

    // { creatorContractAddress => { index =>  tokenId } }
    mapping(address => mapping(uint256 => uint256)) private _redeemTokenIds;
    // { creatorContractAddress => { tokenId =>  index } }
    mapping(address => mapping(uint256 => uint256)) private _redeemIndexes;

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

    /**
     * See {IERC1155BurnRedeem-initializeBurnRedeem}.
     */
    function initializeBurnRedeem(
        address creatorContractAddress,
        uint256 index,
        BurnRedeemParameters calldata burnRedeemParameters
    ) external override creatorAdminRequired(creatorContractAddress) {
        _initialize(creatorContractAddress, index, burnRedeemParameters);

        // Mint a new token with amount '0' to the creator
        address[] memory receivers = new address[](1);
        receivers[0] = msg.sender;
        string[] memory uris = new string[](1);
        uint256[] memory amounts = new uint256[](1);
        uint256[] memory newTokenIds = IERC1155CreatorCore(creatorContractAddress).mintExtensionNew(receivers, amounts, uris);
        _redeemTokenIds[creatorContractAddress][index] = newTokenIds[0];
        _redeemIndexes[creatorContractAddress][newTokenIds[0]] = index;
    }

    /**
     * See {IERC1155BurnRedeem-updateBurnRedeem}.
     */
    function updateBurnRedeem(
        address creatorContractAddress,
        uint256 index,
        BurnRedeemParameters calldata burnRedeemParameters
    ) external override creatorAdminRequired(creatorContractAddress) {
        _update(creatorContractAddress, index, burnRedeemParameters);
    }

    /**
     * See {IERC1155BurnRedeem-updateURI}.
     */
    function updateURI(
        address creatorContractAddress,
        uint256 index, StorageProtocol storageProtocol,
        string calldata location
    ) external override creatorAdminRequired(creatorContractAddress) {
        BurnRedeem storage burnRedeemInstance = _getBurnRedeem(creatorContractAddress, index);
        burnRedeemInstance.storageProtocol = storageProtocol;
        burnRedeemInstance.location = location;
    }

    /**
     * Helper to mint multiple redeem tokens
     */
    function _redeem(address creatorContractAddress, uint256 index, BurnRedeem storage burnRedeemInstance, address to, uint32 count) internal override {
        address[] memory addresses = new address[](1);
        addresses[0] = to;
        uint256[] memory tokenIds = new uint256[](1);
        tokenIds[0] = _redeemTokenIds[creatorContractAddress][index];
        uint256[] memory values = new uint256[](1);
        values[0] = burnRedeemInstance.redeemAmount * count;
        
        IERC1155CreatorCore(creatorContractAddress).mintExtensionExisting(addresses, tokenIds, values);
        burnRedeemInstance.redeemedCount += uint32(values[0]);

        emit BurnRedeemMint(creatorContractAddress, index, tokenIds[0]);
    }

    /**
     * See {ICreatorExtensionTokenURI-tokenURI}.
     */
    function tokenURI(address creatorContractAddress, uint256 tokenId) external override view returns(string memory uri) {
        uint256 index = _redeemIndexes[creatorContractAddress][tokenId];
        require(index > 0, "Token does not exist");
        BurnRedeem memory burnRedeem = _burnRedeems[creatorContractAddress][index];

        string memory prefix = "";
        if (burnRedeem.storageProtocol == StorageProtocol.ARWEAVE) {
            prefix = ARWEAVE_PREFIX;
        } else if (burnRedeem.storageProtocol == StorageProtocol.IPFS) {
            prefix = IPFS_PREFIX;
        }
        uri = string(abi.encodePacked(prefix, burnRedeem.location));
    }
}

File 2 of 27 : IERC1155BurnRedeem.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "./IBurnRedeemCore.sol";

interface IERC1155BurnRedeem is IBurnRedeemCore {
    struct ExtendedConfig {
        uint256 redeemTokenId;
    }

    /**
     * @notice initialize a new burn redeem, emit initialize event, and return the newly created index
     * @param creatorContractAddress    the creator contract the burn will mint redeem tokens for
     * @param index                     the index of the burnRedeem in the mapping of creatorContractAddress' _burnRedeems
     * @param burnRedeemParameters      the parameters which will affect the minting behavior of the burn redeem
     */
    function initializeBurnRedeem(address creatorContractAddress, uint256 index, BurnRedeemParameters calldata burnRedeemParameters) external;

    /**
     * @notice update an existing burn redeem at index
     * @param creatorContractAddress    the creator contract corresponding to the burn redeem
     * @param index                     the index of the burn redeem in the list of creatorContractAddress' _burnRedeems
     * @param burnRedeemParameters      the parameters which will affect the minting behavior of the burn redeem
     */
    function updateBurnRedeem(address creatorContractAddress, uint256 index, BurnRedeemParameters calldata burnRedeemParameters) external;

    /**
     * @notice update an existing burn redeem at index
     * @param creatorContractAddress    the creator contract corresponding to the burn redeem
     * @param index                     the index of the burn redeem in the list of creatorContractAddress' _burnRedeems
     * @param storageProtocol           the storage protocol for the metadata
     * @param location                  the location of the metadata
     */
    function updateURI(address creatorContractAddress, uint256 index, StorageProtocol storageProtocol, string calldata location) external;
}

File 3 of 27 : BurnRedeemCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/////////////////////////////////////////////////////////////////////////////////////
//                                                                                 //
//                                                                                 //
//                                     .%(#.                                       //
//                                      #(((#%,                                    //
//                                      (#(((((#%*                                 //
//                                      /#((((((((##*                              //
//                                      (#((((((((((##%.                           //
//                                     ,##(/*/(////((((#%*                         //
//                                   .###(//****/////(((##%,                       //
//                  (,          ,%#((((((///******/////((##%(                      //
//                *((,         ,##(///////*********////((###%*                     //
//              /((((         ,##(//////************/(((((###%                     //
//             /((((         ,##((////***************/((((###%                     //
//             (((          .###((///*****************((((####                     //
//             .            (##((//*******************((((##%*                     //
//               (#.       .###((/********************((((##%.      %.             //
//             ,%(#.       .###(/********,,,,,,,*****/(((###%#     ((%,            //
//            /%#/(/       /###(//****,,,,,,,,,,,****/((((((##%%%%#((#%.           //
//           /##(//(#.    ,###((/****,,,,,,,,,,,,,***/((/(((((((((#####%           //
//          *%##(/////((###((((/***,,,,,,,,,,,,,,,***//((((((((((####%%%/          //
//          ####(((//////(//////**,,,,,,.....,,,,,,****/(((((//((####%%%%          //
//         .####(((/((((((/////**,,,,,.......,,,,,,,,*****/////(#####%%%%          //
//         .#%###((////(((//***,,,,,,..........,,,,,,,,*****//((#####%%%%          //
//          /%%%###/////*****,,,,,,,..............,,,,,,,****/(((####%%%%          //
//           /%%###(////****,,,,,,.....        ......,,,,,,**(((####%%%%           //
//            ,#%###(///****,,,,,....            .....,,,,,***/(/(##%%(            //
//              (####(//****,,....                 ....,,,,,***/(####              //
//                (###(/***,,,...                    ...,,,,***(##/                //
//             #.   (#((/**,,,,..                    ...,,,,*((#,                  //
//               ,#(##(((//,,,,..                   ...,,,*/(((#((/                //
//                  *#(((///*,,....                ....,*//((((                    //
//                      *(///***,....            ...,***//,                        //
//                           ,//***,...       ..,,*,                               //
//                                                                                 //
//                                                                                 //
/////////////////////////////////////////////////////////////////////////////////////

import "@manifoldxyz/creator-core-solidity/contracts/extensions/ICreatorExtensionTokenURI.sol";
import "@manifoldxyz/libraries-solidity/contracts/access/AdminControl.sol";
import "@manifoldxyz/libraries-solidity/contracts/access/IAdminControl.sol";

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";

import "../../libraries/manifold-membership/IManifoldMembership.sol";
import "./IBurnRedeemCore.sol";
import "./Interfaces.sol";

/**
 * @title Burn Redeem Core
 * @author manifold.xyz
 * @notice Core logic for Burn Redeem shared extensions.
 */
abstract contract BurnRedeemCore is ERC165, AdminControl, ReentrancyGuard, IBurnRedeemCore, ICreatorExtensionTokenURI {
    using Strings for uint256;

    uint256 public constant BURN_FEE = 690000000000000;
    uint256 public constant MULTI_BURN_FEE = 990000000000000;

    string internal constant ARWEAVE_PREFIX = "https://arweave.net/";
    string internal constant IPFS_PREFIX = "ipfs://";

    uint256 internal constant MAX_UINT_16 = 0xffff;
    uint256 internal constant MAX_UINT_32 = 0xffffffff;
    uint256 internal constant MAX_UINT_256 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;

    // { creatorContractAddress => { index => BurnRedeem } }
    mapping(address => mapping(uint256 => BurnRedeem)) internal _burnRedeems;

    address public manifoldMembershipContract;

    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165, AdminControl) returns (bool) {
        return interfaceId == type(IBurnRedeemCore).interfaceId ||
            interfaceId == type(IERC721Receiver).interfaceId ||
            interfaceId == type(IERC1155Receiver).interfaceId ||
            interfaceId == type(ICreatorExtensionTokenURI).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @notice This extension is shared, not single-creator. So we must ensure
     * that a burn redeems's initializer is an admin on the creator contract
     * @param creatorContractAddress    the address of the creator contract to check the admin against
     */
    modifier creatorAdminRequired(address creatorContractAddress) {
        require(IAdminControl(creatorContractAddress).isAdmin(msg.sender), "Wallet is not an admin");
        _;
    }

    /**
     * Initialiazes a burn redeem with base parameters
     */
    function _initialize(
        address creatorContractAddress,
        uint256 index,
        BurnRedeemParameters calldata burnRedeemParameters
    ) internal {
        BurnRedeem storage burnRedeemInstance = _burnRedeems[creatorContractAddress][index];

        // Sanity checks
        require(burnRedeemInstance.storageProtocol == StorageProtocol.INVALID, "Burn redeem already initialized");
        _validateParameters(burnRedeemParameters);

        // Create the burn redeem
        _setParameters(burnRedeemInstance, burnRedeemParameters);
        _setBurnGroups(burnRedeemInstance, burnRedeemParameters.burnSet);

        emit BurnRedeemInitialized(creatorContractAddress, index, msg.sender);
    }

    /**
     * Updates a burn redeem with base parameters
     */
    function _update(
        address creatorContractAddress,
        uint256 index,
        BurnRedeemParameters calldata burnRedeemParameters
    ) internal {
        BurnRedeem storage burnRedeemInstance = _getBurnRedeem(creatorContractAddress, index);

        // Sanity checks
        require(burnRedeemInstance.storageProtocol != StorageProtocol.INVALID, "Burn redeem not initialized");
        _validateParameters(burnRedeemParameters);
        // The current redeemedCount must be divisible by redeemAmount
        require(burnRedeemInstance.redeemedCount % burnRedeemParameters.redeemAmount == 0, "Invalid amount");

        // Overwrite the existing burnRedeem
        _setParameters(burnRedeemInstance, burnRedeemParameters);
        _setBurnGroups(burnRedeemInstance, burnRedeemParameters.burnSet);
        _maybeUpdateTotalSupply(burnRedeemInstance);
    }

    /**
     * See {IBurnRedeemCore-getBurnRedeem}.
     */
    function getBurnRedeem(address creatorContractAddress, uint256 index) external override view returns(BurnRedeem memory) {
        return _getBurnRedeem(creatorContractAddress, index);
    }

    /**
     * Helper to get burn redeem instance
     */
    function _getBurnRedeem(address creatorContractAddress, uint256 index) internal view returns(BurnRedeem storage burnRedeemInstance) {
        burnRedeemInstance = _burnRedeems[creatorContractAddress][index];
        require(burnRedeemInstance.storageProtocol != StorageProtocol.INVALID, "Burn redeem not initialized");
    }

    /**
     * Helper to get active burn redeem instance
     */
    function _getActiveBurnRedeem(address creatorContractAddress, uint256 index) private view returns(BurnRedeem storage burnRedeemInstance) {
        burnRedeemInstance = _burnRedeems[creatorContractAddress][index];
        require(burnRedeemInstance.storageProtocol != StorageProtocol.INVALID, "Burn redeem not initialized");
        require(
            burnRedeemInstance.startDate <= block.timestamp && 
            (block.timestamp < burnRedeemInstance.endDate || burnRedeemInstance.endDate == 0),
            "Burn redeem not active"
        );
    }

    /**
     * Helper to update total supply if redeemedCount exceeds totalSupply after airdrop or instance update.
     */
    function _maybeUpdateTotalSupply(BurnRedeem storage burnRedeemInstance) private {
        if (
            burnRedeemInstance.totalSupply != 0 &&
            burnRedeemInstance.redeemedCount > burnRedeemInstance.totalSupply
        ) {
            burnRedeemInstance.totalSupply = burnRedeemInstance.redeemedCount;
        }
    }

    /**
     * See {IBurnRedeemCore-burnRedeem}.
     */
    function burnRedeem(address creatorContractAddress, uint256 index, uint32 burnRedeemCount, BurnToken[] calldata burnTokens) external payable override nonReentrant {
        uint256 payableCost = _burnRedeem(msg.value, creatorContractAddress, index, burnRedeemCount, burnTokens, _isActiveMember(msg.sender), true);
        if (msg.value > payableCost) {
            _forwardValue(payable(msg.sender), msg.value - payableCost);
        }
    }

    /**
     * (Batch overload) see {IBurnRedeemCore-burnRedeem}.
     */
    function burnRedeem(address[] calldata creatorContractAddresses, uint256[] calldata indexes, uint32[] calldata burnRedeemCounts, BurnToken[][] calldata burnTokens) external payable override nonReentrant {
        require(
            creatorContractAddresses.length == indexes.length &&
            creatorContractAddresses.length == burnRedeemCounts.length &&
            creatorContractAddresses.length == burnTokens.length,
            "Invalid calldata"
        );

        bool isActiveMember = _isActiveMember(msg.sender);
        uint256 msgValueRemaining = msg.value;
        for (uint256 i; i < creatorContractAddresses.length;) {
            msgValueRemaining -= _burnRedeem(msgValueRemaining, creatorContractAddresses[i], indexes[i], burnRedeemCounts[i], burnTokens[i], isActiveMember, false);
            unchecked { ++i; }
        }

        if (msgValueRemaining != 0) {
            _forwardValue(payable(msg.sender), msgValueRemaining);
        }
    }

    /**
     * See {IBurnRedeemCore-airdrop}.
     */
    function airdrop(address creatorContractAddress, uint256 index, address[] calldata recipients, uint32[] calldata amounts) external override creatorAdminRequired(creatorContractAddress) {
        require(recipients.length == amounts.length, "Invalid calldata");
        BurnRedeem storage burnRedeemInstance = _getBurnRedeem(creatorContractAddress, index);

        uint256 totalAmount;
        for (uint256 i; i < amounts.length;) {
            totalAmount += amounts[i] * burnRedeemInstance.redeemAmount;
            unchecked{ ++i; }
        }
        require(
            totalAmount + burnRedeemInstance.redeemedCount <= MAX_UINT_32,
            "Invalid amount"
        );

        // Airdrop the tokens
        for (uint256 i; i < recipients.length;) {
            _redeem(creatorContractAddress, index, burnRedeemInstance, recipients[i], amounts[i]);
            unchecked{ ++i; }
        }

        _maybeUpdateTotalSupply(burnRedeemInstance);
    }

    function _burnRedeem(uint256 msgValue, address creatorContractAddress, uint256 index, uint32 burnRedeemCount, BurnToken[] calldata burnTokens, bool isActiveMember, bool revertNoneRemaining) private returns (uint256) {
        BurnRedeem storage burnRedeemInstance = _getActiveBurnRedeem(creatorContractAddress, index);

        // Get the amount that can be burned
        burnRedeemCount = _getAvailableBurnRedeemCount(burnRedeemInstance.totalSupply, burnRedeemInstance.redeemedCount, burnRedeemInstance.redeemAmount, burnRedeemCount);
        if (burnRedeemCount == 0) {
            if (revertNoneRemaining) revert("No tokens available");
            return 0;
        }

        uint256 payableCost = burnRedeemInstance.cost;
        uint256 cost = burnRedeemInstance.cost;
        if (!isActiveMember) {
            payableCost += _getManifoldFee(burnTokens.length);
        }
        if (burnRedeemCount > 1) {
            payableCost *= burnRedeemCount;
            cost *= burnRedeemCount;
        }
        require(msgValue >= payableCost, "Invalid amount");
        if (cost > 0) {
            _forwardValue(burnRedeemInstance.paymentReceiver, cost);
        }

        // Do burn redeem
        _burnTokens(burnRedeemInstance, burnTokens, burnRedeemCount, msg.sender);
        _redeem(creatorContractAddress, index, burnRedeemInstance, msg.sender, burnRedeemCount);

        return payableCost;
    }

    /**
     * @dev See {IBurnRedeemCore-recoverERC721}.
     */
    function recoverERC721(address tokenAddress, uint256 tokenId, address destination) external override adminRequired {
        IERC721(tokenAddress).transferFrom(address(this), destination, tokenId);
    }

    /**
     * @dev See {IBurnRedeemCore-withdraw}.
     */
    function withdraw(address payable recipient, uint256 amount) external override adminRequired {
        (bool sent, ) = recipient.call{value: amount}("");
        require(sent, "Failed to transfer to recipient");
    }

    /**
     * @dev See {IBurnRedeemCore-setManifoldMembership}.
     */
    function setMembershipAddress(address addr) external override adminRequired {
        manifoldMembershipContract = addr;
    }

    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     */
    function onERC721Received(
        address,
        address from,
        uint256 id,
        bytes calldata data
    ) external override nonReentrant returns(bytes4) {
        _onERC721Received(from, id, data);
        return this.onERC721Received.selector;
    }

    /**
     * @dev See {IERC1155Receiver-onERC1155Received}.
     */
    function onERC1155Received(
        address,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external override nonReentrant returns(bytes4) {
        // Check calldata is valid
        require(data.length % 32 == 0, "Invalid data");

        address creatorContractAddress;
        uint256 burnRedeemIndex;
        uint32 burnRedeemCount;
        uint256 burnItemIndex;
        bytes32[] memory merkleProof;
        (creatorContractAddress, burnRedeemIndex, burnRedeemCount, burnItemIndex, merkleProof) = abi.decode(data, (address, uint256, uint32, uint256, bytes32[]));

        // Do burn redeem
        _onERC1155Received(from, id, value, creatorContractAddress, burnRedeemIndex, burnRedeemCount, burnItemIndex, merkleProof);

        return this.onERC1155Received.selector;
    }

    /**
     * @dev See {IERC1155Receiver-onERC1155BatchReceived}.
     */
    function onERC1155BatchReceived(
        address,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external override nonReentrant returns(bytes4) {
        // Check calldata is valid
        require(data.length % 32 == 0, "Invalid data");

        address creatorContractAddress;
        uint256 burnRedeemIndex;
        uint32 burnRedeemCount;
        BurnToken[] memory burnTokens;
        (creatorContractAddress, burnRedeemIndex, burnRedeemCount, burnTokens) = abi.decode(data, (address, uint256, uint32, BurnToken[]));

        // Do burn redeem
        _onERC1155BatchReceived(from, ids, values, creatorContractAddress, burnRedeemIndex, burnRedeemCount, burnTokens);

        return this.onERC1155BatchReceived.selector;
    }

    /**
     * @notice ERC721 token transfer callback
     * @param from      the person sending the tokens
     * @param id        the token id of the burn token
     * @param data      bytes indicating the target burnRedeem and, optionally, a merkle proof that the token is valid
     */
    function _onERC721Received(
        address from,
        uint256 id,
        bytes calldata data
    ) private {
        // Check calldata is valid
        require(data.length % 32 == 0, "Invalid data");

        address creatorContractAddress;
        uint256 burnRedeemIndex;
        uint256 burnItemIndex;
        bytes32[] memory merkleProof;
        (creatorContractAddress, burnRedeemIndex, burnItemIndex, merkleProof) = abi.decode(data, (address, uint256, uint256, bytes32[]));

        BurnRedeem storage burnRedeemInstance = _getActiveBurnRedeem(creatorContractAddress, burnRedeemIndex);

        // A single ERC721 can only be sent in directly for a burn if:
        // 1. There is no cost to the burn (because no payment can be sent with a transfer)
        // 2. The burn only requires one NFT (one burnSet element and one count)
        // 3. They are an active member (because no fee payment can be sent with a transfer)
        require(
            burnRedeemInstance.cost == 0 &&
            burnRedeemInstance.burnSet.length == 1 &&
            burnRedeemInstance.burnSet[0].requiredCount == 1 &&
            _isActiveMember(from),
            "Invalid input"
        );

        uint256 burnRedeemCount = _getAvailableBurnRedeemCount(burnRedeemInstance.totalSupply, burnRedeemInstance.redeemedCount, burnRedeemInstance.redeemAmount, 1);
        require(burnRedeemCount != 0, "No tokens available");

        // Check that the burn token is valid
        BurnItem memory burnItem = burnRedeemInstance.burnSet[0].items[burnItemIndex];

        // Can only take in one burn item
        require(burnItem.tokenSpec == TokenSpec.ERC721, "Invalid input");
        _validateBurnItem(burnItem, msg.sender, id, merkleProof);

        // Do burn and redeem
        _burn(burnItem, address(this), msg.sender, id, 1);
        _redeem(creatorContractAddress, burnRedeemIndex, burnRedeemInstance, from, 1);
    }

    /**
     * Execute onERC1155Received burn/redeem
     */
    function _onERC1155Received(address from, uint256 tokenId, uint256 value, address creatorContractAddress, uint256 burnRedeemIndex, uint32 burnRedeemCount, uint256 burnItemIndex, bytes32[] memory merkleProof) private {
        BurnRedeem storage burnRedeemInstance = _getActiveBurnRedeem(creatorContractAddress, burnRedeemIndex);

        // A single 1155 can only be sent in directly for a burn if:
        // 1. There is no cost to the burn (because no payment can be sent with a transfer)
        // 2. The burn only requires one NFT (one burn set element and one required count in the set)
        // 3. They are an active member (because no fee payment can be sent with a transfer)
        require(
            burnRedeemInstance.cost == 0 &&
            burnRedeemInstance.burnSet.length == 1 &&
            burnRedeemInstance.burnSet[0].requiredCount == 1 &&
            _isActiveMember(from),
            "Invalid input"
        );

        uint32 availableBurnRedeemCount = _getAvailableBurnRedeemCount(burnRedeemInstance.totalSupply, burnRedeemInstance.redeemedCount, burnRedeemInstance.redeemAmount, burnRedeemCount);
        require(availableBurnRedeemCount != 0, "No tokens available");

        // Check that the burn token is valid
        BurnItem memory burnItem = burnRedeemInstance.burnSet[0].items[burnItemIndex];
        require(value == burnItem.amount * burnRedeemCount, "Invalid input");
        _validateBurnItem(burnItem, msg.sender, tokenId, merkleProof);

        _burn(burnItem, address(this), msg.sender, tokenId, availableBurnRedeemCount);
        _redeem(creatorContractAddress, burnRedeemIndex, burnRedeemInstance, from, availableBurnRedeemCount);

        // Return excess amount
        if (availableBurnRedeemCount != burnRedeemCount) {
            IERC1155(msg.sender).safeTransferFrom(address(this), from, tokenId, (burnRedeemCount - availableBurnRedeemCount) * burnItem.amount, "");
        }
    }

    /**
     * Execute onERC1155BatchReceived burn/redeem
     */
    function _onERC1155BatchReceived(address from, uint256[] memory tokenIds, uint256[] memory values, address creatorContractAddress, uint256 burnRedeemIndex, uint32 burnRedeemCount, BurnToken[] memory burnTokens) private {
        BurnRedeem storage burnRedeemInstance = _getActiveBurnRedeem(creatorContractAddress, burnRedeemIndex);

        // A single 1155 can only be sent in directly for a burn if:
        // 1. There is no cost to the burn (because no payment can be sent with a transfer)
        // 2. We have the right data length
        // 3. They are an active member (because no fee payment can be sent with a transfer)
        require(
            burnRedeemInstance.cost == 0 &&
            burnTokens.length == tokenIds.length &&
            _isActiveMember(from),
            "Invalid input"
        );
        uint32 availableBurnRedeemCount = _getAvailableBurnRedeemCount(burnRedeemInstance.totalSupply, burnRedeemInstance.redeemedCount, burnRedeemInstance.redeemAmount, burnRedeemCount);
        require(availableBurnRedeemCount != 0, "No tokens available");

        // Verify the values match what is needed
        uint256[] memory returnValues = new uint256[](tokenIds.length);
        for (uint256 i; i < burnTokens.length;) {
            BurnToken memory burnToken = burnTokens[i];
            BurnItem memory burnItem = burnRedeemInstance.burnSet[burnToken.groupIndex].items[burnToken.itemIndex];
            require(burnToken.id == tokenIds[i], "Invalid token");
            require(burnItem.amount * burnRedeemCount == values[i], "Invalid amount");
            if (availableBurnRedeemCount != burnRedeemCount) {
                returnValues[i] = values[i] - burnItem.amount * availableBurnRedeemCount;
            }
            unchecked { ++i; }
        }

        // Do burn redeem
        _burnTokens(burnRedeemInstance, burnTokens, availableBurnRedeemCount, address(this));
        _redeem(creatorContractAddress, burnRedeemIndex, burnRedeemInstance, from, availableBurnRedeemCount);

        // Return excess amount
        if (availableBurnRedeemCount != burnRedeemCount) {
            IERC1155(msg.sender).safeBatchTransferFrom(address(this), from, tokenIds, returnValues, "");
        }
    }

    /**
     * Send funds to receiver
     */
    function _forwardValue(address payable receiver, uint256 amount) private {
        (bool sent, ) = receiver.call{value: amount}("");
        require(sent, "Failed to transfer to recipient");
    }

    /**
     * Burn all listed tokens and check that the burn set is satisfied
     */
    function _burnTokens(BurnRedeem storage burnRedeemInstance, BurnToken[] memory burnTokens, uint256 burnRedeemCount, address owner) private {
        // Check that each group in the burn set is satisfied
        uint256[] memory groupCounts = new uint256[](burnRedeemInstance.burnSet.length);

        for (uint256 i; i < burnTokens.length;) {
            BurnToken memory burnToken = burnTokens[i];
            BurnItem memory burnItem = burnRedeemInstance.burnSet[burnToken.groupIndex].items[burnToken.itemIndex];

            _validateBurnItem(burnItem, burnToken.contractAddress, burnToken.id, burnToken.merkleProof);

            _burn(burnItem, owner, burnToken.contractAddress, burnToken.id, burnRedeemCount);
            groupCounts[burnToken.groupIndex] += burnRedeemCount;

            unchecked { ++i; }
        }

        for (uint256 i; i < groupCounts.length;) {
            require(groupCounts[i] == burnRedeemInstance.burnSet[i].requiredCount * burnRedeemCount, "Invalid number of tokens");
            unchecked { ++i; }
        }
    }

    /**
     * Helper to validate the parameters for a burn redeem
     */
    function _validateParameters(BurnRedeemParameters calldata burnRedeemParameters) internal pure {
        require(burnRedeemParameters.storageProtocol != StorageProtocol.INVALID, "Storage protocol invalid");
        require(burnRedeemParameters.paymentReceiver != address(0), "Payment receiver required");
        require(burnRedeemParameters.endDate == 0 || burnRedeemParameters.startDate < burnRedeemParameters.endDate, "startDate after endDate");
        require(burnRedeemParameters.totalSupply % burnRedeemParameters.redeemAmount == 0, "Remainder left from totalSupply");
    }

    /**
     * Helper to set top level properties for a burn redeem
     */
    function _setParameters(BurnRedeem storage burnRedeemInstance, BurnRedeemParameters calldata burnRedeemParameters) private {
        burnRedeemInstance.startDate = burnRedeemParameters.startDate;
        burnRedeemInstance.endDate = burnRedeemParameters.endDate;
        burnRedeemInstance.redeemAmount = burnRedeemParameters.redeemAmount;
        burnRedeemInstance.totalSupply = burnRedeemParameters.totalSupply;
        burnRedeemInstance.storageProtocol = burnRedeemParameters.storageProtocol;
        burnRedeemInstance.location = burnRedeemParameters.location;
        burnRedeemInstance.cost = burnRedeemParameters.cost;
        burnRedeemInstance.paymentReceiver = burnRedeemParameters.paymentReceiver;
    }

    /**
     * Helper to set the burn groups for a burn redeem
     */
    function _setBurnGroups(BurnRedeem storage burnRedeemInstance, BurnGroup[] calldata burnGroups) private {
        delete burnRedeemInstance.burnSet;
        for (uint256 i; i < burnGroups.length;) {
            burnRedeemInstance.burnSet.push();
            BurnGroup storage burnGroup = burnRedeemInstance.burnSet[i];
            require(
                burnGroups[i].requiredCount > 0 &&
                burnGroups[i].requiredCount <= burnGroups[i].items.length,
                "Invalid input"
            );
            burnGroup.requiredCount = burnGroups[i].requiredCount;
            for (uint256 j; j < burnGroups[i].items.length;) {
                BurnItem memory burnItem = burnGroups[i].items[j];
                require(
                    (
                        (burnItem.tokenSpec == TokenSpec.ERC1155 && burnItem.amount > 0) ||
                        (burnItem.tokenSpec == TokenSpec.ERC721 && burnItem.amount == 0)
                    ) &&
                    burnItem.validationType != ValidationType.INVALID,
                    "Invalid input");
                burnGroup.items.push(burnGroups[i].items[j]);
                unchecked { ++j; }
            }
            unchecked { ++i; }
        }
    }

    /**
     * Helper to get the Manifold fee for the sender
     */
    function _getManifoldFee(uint256 burnTokenCount) private pure returns(uint256 fee) {
        fee = burnTokenCount <= 1 ? BURN_FEE : MULTI_BURN_FEE;
    }

    /**
     * Helper to check if the sender holds an active Manifold membership
     */
    function _isActiveMember(address sender) private view returns(bool) {
        return manifoldMembershipContract != address(0) &&
            IManifoldMembership(manifoldMembershipContract).isActiveMember(sender);
    }

    /*
     * Helper to validate burn item
     */
    function _validateBurnItem(BurnItem memory burnItem, address contractAddress, uint256 tokenId, bytes32[] memory merkleProof) private pure {
        require(contractAddress == burnItem.contractAddress, "Invalid burn token");
        if (burnItem.validationType == ValidationType.CONTRACT) {
            return;
        } else if (burnItem.validationType == ValidationType.RANGE) {
            require(tokenId >= burnItem.minTokenId && tokenId <= burnItem.maxTokenId, "Invalid token ID");
            return;
        } else if (burnItem.validationType == ValidationType.MERKLE_TREE) {
            bytes32 leaf = keccak256(abi.encodePacked(tokenId));
            require(MerkleProof.verify(merkleProof, burnItem.merkleRoot, leaf), "Invalid merkle proof");
            return;
        }
        revert("Invalid burn item");
    }

    /**
     * Helper to get the number of burn redeems the person can accomplish
     */
    function _getAvailableBurnRedeemCount(uint32 totalSupply, uint32 redeemedCount, uint32 redeemAmount, uint32 desiredCount) internal pure returns(uint32 burnRedeemCount) {
        if (totalSupply == 0) {
            burnRedeemCount = desiredCount;
        } else {
            uint32 remainingCount = (totalSupply - redeemedCount) / redeemAmount;
            if (remainingCount > desiredCount) {
                burnRedeemCount = desiredCount;
            } else {
                burnRedeemCount = remainingCount;
            }
        }
    }

    /** 
     * Abstract helper to mint multiple redeem tokens. To be implemented by inheriting contracts.
     */
    function _redeem(address creatorContractAddress, uint256 index, BurnRedeem storage burnRedeemInstance, address to, uint32 count) internal virtual;

    /**
     * Helper to burn token
     */
    function _burn(BurnItem memory burnItem, address from, address contractAddress, uint256 tokenId, uint256 burnRedeemCount) private {
        if (burnItem.tokenSpec == TokenSpec.ERC1155) {
            uint256 amount = burnItem.amount * burnRedeemCount;

            if (burnItem.burnSpec == BurnSpec.NONE) {
                // Send to 0xdEaD to burn if contract doesn't have burn function
                IERC1155(contractAddress).safeTransferFrom(from, address(0xdEaD), tokenId, amount, "");

            } else if (burnItem.burnSpec == BurnSpec.MANIFOLD) {
                // Burn using the creator core's burn function
                uint256[] memory tokenIds = new uint256[](1);
                tokenIds[0] = tokenId;
                uint256[] memory amounts = new uint256[](1);
                amounts[0] = amount;
                Manifold1155(contractAddress).burn(from, tokenIds, amounts);

            } else if (burnItem.burnSpec == BurnSpec.OPENZEPPELIN) {
                // Burn using OpenZeppelin's burn function
                OZBurnable1155(contractAddress).burn(from, tokenId, amount);

            } else {
                revert("Invalid burn spec");
            }
        } else if (burnItem.tokenSpec == TokenSpec.ERC721) {
            require(burnRedeemCount == 1, "Invalid burn count");
            if (burnItem.burnSpec == BurnSpec.NONE) {
                // Send to 0xdEaD to burn if contract doesn't have burn function
                IERC721(contractAddress).safeTransferFrom(from, address(0xdEaD), tokenId, "");

            } else if (burnItem.burnSpec == BurnSpec.MANIFOLD || burnItem.burnSpec == BurnSpec.OPENZEPPELIN) {
                if (from != address(this)) {
                    // 721 `burn` functions do not have a `from` parameter, so we must verify the owner
                    require(IERC721(contractAddress).ownerOf(tokenId) == from, "Sender is not owner");
                }
                // Burn using the contract's burn function
                Burnable721(contractAddress).burn(tokenId);

            } else {
                revert("Invalid burn spec");
            }
        } else {
            revert("Invalid token spec");
        }
    }
}

File 4 of 27 : IERC1155CreatorCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "./CreatorCore.sol";

/**
 * @dev Core ERC1155 creator interface
 */
interface IERC1155CreatorCore is ICreatorCore {

    /**
     * @dev mint a token with no extension. Can only be called by an admin.
     *
     * @param to       - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
     * @param amounts  - Can be a single element array (all recipients get the same amount) or a multi-element array
     * @param uris     - If no elements, all tokens use the default uri.
     *                   If any element is an empty string, the corresponding token uses the default uri.
     *
     *
     * Requirements: If to is a multi-element array, then uris must be empty or single element array
     *               If to is a multi-element array, then amounts must be a single element array or a multi-element array of the same size
     *               If to is a single element array, uris must be empty or the same length as amounts
     *
     * Examples:
     *    mintBaseNew(['0x....1', '0x....2'], [1], [])
     *        Mints a single new token, and gives 1 each to '0x....1' and '0x....2'.  Token uses default uri.
     *    
     *    mintBaseNew(['0x....1', '0x....2'], [1, 2], [])
     *        Mints a single new token, and gives 1 to '0x....1' and 2 to '0x....2'.  Token uses default uri.
     *    
     *    mintBaseNew(['0x....1'], [1, 2], ["", "http://token2.com"])
     *        Mints two new tokens to '0x....1'. 1 of the first token, 2 of the second.  1st token uses default uri, second uses "http://token2.com".
     *    
     * @return Returns list of tokenIds minted
     */
    function mintBaseNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) external returns (uint256[] memory);

    /**
     * @dev batch mint existing token with no extension. Can only be called by an admin.
     *
     * @param to        - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
     * @param tokenIds  - Can be a single element array (all recipients get the same token) or a multi-element array
     * @param amounts   - Can be a single element array (all recipients get the same amount) or a multi-element array
     *
     * Requirements: If any of the parameters are multi-element arrays, they need to be the same length as other multi-element arrays
     *
     * Examples:
     *    mintBaseExisting(['0x....1', '0x....2'], [1], [10])
     *        Mints 10 of tokenId 1 to each of '0x....1' and '0x....2'.
     *    
     *    mintBaseExisting(['0x....1', '0x....2'], [1, 2], [10, 20])
     *        Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 2 to '0x....2'.
     *    
     *    mintBaseExisting(['0x....1'], [1, 2], [10, 20])
     *        Mints 10 of tokenId 1 and 20 of tokenId 2 to '0x....1'.
     *    
     *    mintBaseExisting(['0x....1', '0x....2'], [1], [10, 20])
     *        Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 1 to '0x....2'.
     *    
     */
    function mintBaseExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) external;

    /**
     * @dev mint a token from an extension. Can only be called by a registered extension.
     *
     * @param to       - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
     * @param amounts  - Can be a single element array (all recipients get the same amount) or a multi-element array
     * @param uris     - If no elements, all tokens use the default uri.
     *                   If any element is an empty string, the corresponding token uses the default uri.
     *
     *
     * Requirements: If to is a multi-element array, then uris must be empty or single element array
     *               If to is a multi-element array, then amounts must be a single element array or a multi-element array of the same size
     *               If to is a single element array, uris must be empty or the same length as amounts
     *
     * Examples:
     *    mintExtensionNew(['0x....1', '0x....2'], [1], [])
     *        Mints a single new token, and gives 1 each to '0x....1' and '0x....2'.  Token uses default uri.
     *    
     *    mintExtensionNew(['0x....1', '0x....2'], [1, 2], [])
     *        Mints a single new token, and gives 1 to '0x....1' and 2 to '0x....2'.  Token uses default uri.
     *    
     *    mintExtensionNew(['0x....1'], [1, 2], ["", "http://token2.com"])
     *        Mints two new tokens to '0x....1'. 1 of the first token, 2 of the second.  1st token uses default uri, second uses "http://token2.com".
     *    
     * @return Returns list of tokenIds minted
     */
    function mintExtensionNew(address[] calldata to, uint256[] calldata amounts, string[] calldata uris) external returns (uint256[] memory);

    /**
     * @dev batch mint existing token from extension. Can only be called by a registered extension.
     *
     * @param to        - Can be a single element array (all tokens go to same address) or multi-element array (single token to many recipients)
     * @param tokenIds  - Can be a single element array (all recipients get the same token) or a multi-element array
     * @param amounts   - Can be a single element array (all recipients get the same amount) or a multi-element array
     *
     * Requirements: If any of the parameters are multi-element arrays, they need to be the same length as other multi-element arrays
     *
     * Examples:
     *    mintExtensionExisting(['0x....1', '0x....2'], [1], [10])
     *        Mints 10 of tokenId 1 to each of '0x....1' and '0x....2'.
     *    
     *    mintExtensionExisting(['0x....1', '0x....2'], [1, 2], [10, 20])
     *        Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 2 to '0x....2'.
     *    
     *    mintExtensionExisting(['0x....1'], [1, 2], [10, 20])
     *        Mints 10 of tokenId 1 and 20 of tokenId 2 to '0x....1'.
     *    
     *    mintExtensionExisting(['0x....1', '0x....2'], [1], [10, 20])
     *        Mints 10 of tokenId 1 to '0x....1' and 20 of tokenId 1 to '0x....2'.
     *    
     */
    function mintExtensionExisting(address[] calldata to, uint256[] calldata tokenIds, uint256[] calldata amounts) external;

    /**
     * @dev burn tokens. Can only be called by token owner or approved address.
     * On burn, calls back to the registered extension's onBurn method
     */
    function burn(address account, uint256[] calldata tokenIds, uint256[] calldata amounts) external;

    /**
     * @dev Total amount of tokens in with a given tokenId.
     */
    function totalSupply(uint256 tokenId) external view returns (uint256);
}

File 5 of 27 : IBurnRedeemCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * Burn Redeem Core interface
 */
interface IBurnRedeemCore is IERC165, IERC721Receiver, IERC1155Receiver  {
    enum StorageProtocol { INVALID, NONE, ARWEAVE, IPFS }

    /**
     * @notice the validation type used for a `BurnItem`
     * CONTRACT                 any token from a specific contract is valid
     * RANGE                    token IDs within a range (inclusive) are valid
     * MERKLE_TREE              various individual token IDs included in a merkle tree are valid
     */
    enum ValidationType { INVALID, CONTRACT, RANGE, MERKLE_TREE }

    enum TokenSpec { INVALID, ERC721, ERC1155 }
    enum BurnSpec { NONE, MANIFOLD, OPENZEPPELIN }

    /**
     * @notice a `BurnItem` indicates which tokens are eligible to be burned
     * @param validationType    which type of validation used to check that the burn item is 
     *                          satisfied
     * @param tokenSpec         whether the token is an ERC721 or ERC1155
     * @param burnSpec          whether the contract for a token has a `burn` function and, if so,
     *                          what interface
     * @param amount            (only for ERC1155 tokens) the amount (value) required to burn
     * @param minTokenId        (only for RANGE validation) the minimum valid token ID
     * @param maxTokenId        (only for RANGE validation) the maximum valid token ID
     * @param merkleRoot        (only for MERKLE_TREE validation) the root of the merkle tree of
     *                          valid token IDs
     */
    struct BurnItem {
        ValidationType validationType;
        address contractAddress;
        TokenSpec tokenSpec;
        BurnSpec burnSpec;
        uint72 amount;
        uint256 minTokenId;
        uint256 maxTokenId;
        bytes32 merkleRoot;
    }

    /**
     * @notice a `BurnGroup` is a group of valid `BurnItem`s
     * @param requiredCount     the number of `BurnItem`s (0 < requiredCount <= items.length) that 
     *                          need to be included in a burn
     * @param items             the list of `BurnItem`s
     */
    struct BurnGroup {
        uint256 requiredCount;
        BurnItem[] items;
    }

    /**
     * @notice parameters for burn redeem intialization/updates
     * @param paymentReceiver   the address to forward proceeds from paid burn redeems
     * @param storageProtocol   the type of storage used for the redeem token URIs
     * @param redeemAmount      the number of redeem tokens to mint for each burn redeem
     * @param totalSupply       the maximum number of redeem tokens to mint (0 for unlimited)
     * @param startDate         the starting time for the burn redeem (0 for immediately)
     * @param endDate           the end time for the burn redeem (0 for never)
     * @param cost              the cost for each burn redeem
     * @param location          used to construct the token URI (Arweave hash, full URI, etc.)
     * @param burnSet           a list of `BurnGroup`s that must each be satisfied for a burn redeem
     */
    struct BurnRedeemParameters {
        address payable paymentReceiver;
        StorageProtocol storageProtocol;
        uint16 redeemAmount;
        uint32 totalSupply;
        uint48 startDate;
        uint48 endDate;
        uint160 cost;
        string location;
        BurnGroup[] burnSet;
    }

    struct BurnRedeem {
        address payable paymentReceiver;
        StorageProtocol storageProtocol;
        uint32 redeemedCount;
        uint16 redeemAmount;
        uint32 totalSupply;
        uint48 startDate;
        uint48 endDate;
        uint160 cost;
        string location;
        BurnGroup[] burnSet;
    }

    /**
     * @notice a pointer to a `BurnItem` in a `BurnGroup` used in calls to `burnRedeem`
     * @param groupIndex        the index of the `BurnGroup` in `BurnRedeem.burnSet`
     * @param itemIndex         the index of the `BurnItem` in `BurnGroup.items`
     * @param contractAddress   the address of the contract for the token
     * @param id                the token ID
     * @param merkleProof       the merkle proof for the token ID (only for MERKLE_TREE validation)
     */
    struct BurnToken {
        uint48 groupIndex;
        uint48 itemIndex;
        address contractAddress;
        uint256 id;
        bytes32[] merkleProof;
    }

    event BurnRedeemInitialized(address indexed creatorContract, uint256 indexed index, address initializer);
    event BurnRedeemMint(address indexed creatorContract, uint256 indexed index, uint256 indexed tokenId);

    /**
     * @notice get a burn redeem corresponding to a creator contract and index
     * @param creatorContractAddress    the address of the creator contract
     * @param index                     the index of the burn redeem
     * @return BurnRedeem               the burn redeem object
     */
    function getBurnRedeem(address creatorContractAddress, uint256 index) external view returns(BurnRedeem memory);
    
    /**
     * @notice burn tokens and mint a redeem token
     * @param creatorContractAddress    the address of the creator contract
     * @param index                     the index of the burn redeem
     * @param burnRedeemCount           the number of burn redeems we want to do
     * @param burnTokens                the tokens to burn with pointers to the corresponding BurnItem requirement
     */
    function burnRedeem(address creatorContractAddress, uint256 index, uint32 burnRedeemCount, BurnToken[] calldata burnTokens) external payable;

    /**
     * @notice burn tokens and mint redeem tokens multiple times in a single transaction
     * @param creatorContractAddresses  the addresses of the creator contracts
     * @param indexes                   the indexes of the burn redeems
     * @param burnRedeemCounts          the burn redeem counts for each burn
     * @param burnTokens                the tokens to burn for each burn redeem with pointers to the corresponding BurnItem requirement
     */
    function burnRedeem(address[] calldata creatorContractAddresses, uint256[] calldata indexes, uint32[] calldata burnRedeemCounts, BurnToken[][] calldata burnTokens) external payable;

    /**
     * @notice allow admin to airdrop arbitrary tokens 
     * @param creatorContractAddress    the creator contract to mint tokens for
     * @param index                     the index of the burn redeem in the list of creatorContractAddress' _burnRedeems
     * @param recipients                addresses to airdrop to
     * @param amounts                   number of redeems to perform for each address in recipients
     */
    function airdrop(address creatorContractAddress, uint256 index, address[] calldata recipients, uint32[] calldata amounts) external;

    /**
     * @notice recover a token that was sent to the contract without safeTransferFrom
     * @param tokenAddress              the address of the token contract
     * @param tokenId                   the id of the token
     * @param destination               the address to send the token to
     */
    function recoverERC721(address tokenAddress, uint256 tokenId, address destination) external;

    /**
     * @notice withdraw Manifold fee proceeds from the contract
     * @param recipient                 recepient of the funds
     * @param amount                    amount to withdraw in Wei
     */
    function withdraw(address payable recipient, uint256 amount) external;

    /**
     * @notice set the Manifold Membership contract address
     * @param addr                      the address of the Manifold Membership contract 
     */
    function setMembershipAddress(address addr) external;
}

File 6 of 27 : Interfaces.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface Burnable721 {
    function burn(uint256 tokenId) external;
}

interface OZBurnable1155 {
    function burn(address account, uint256 id, uint256 value) external;
}

interface Manifold1155 {
    function burn(address account, uint256[] memory tokenIds, uint256[] memory amounts) external;
}

File 7 of 27 : IManifoldMembership.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

/**
 * Manifold Membership interface
 */
interface IManifoldMembership {
   function isActiveMember(address sender) external view returns (bool);
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

File 9 of 27 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 10 of 27 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
     * consuming from one or the other at each step according to the instructions given by
     * `proofFlags`.
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 11 of 27 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 12 of 27 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

    /**
     * @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 have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 14 of 27 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

File 15 of 27 : IAdminControl.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @dev Interface for admin control
 */
interface IAdminControl is IERC165 {

    event AdminApproved(address indexed account, address indexed sender);
    event AdminRevoked(address indexed account, address indexed sender);

    /**
     * @dev gets address of all admins
     */
    function getAdmins() external view returns (address[] memory);

    /**
     * @dev add an admin.  Can only be called by contract owner.
     */
    function approveAdmin(address admin) external;

    /**
     * @dev remove an admin.  Can only be called by contract owner.
     */
    function revokeAdmin(address admin) external;

    /**
     * @dev checks whether or not given address is an admin
     * Returns True if they are
     */
    function isAdmin(address admin) external view returns (bool);

}

File 16 of 27 : AdminControl.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./IAdminControl.sol";

abstract contract AdminControl is Ownable, IAdminControl, ERC165 {
    using EnumerableSet for EnumerableSet.AddressSet;

    // Track registered admins
    EnumerableSet.AddressSet private _admins;

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

    /**
     * @dev Only allows approved admins to call the specified function
     */
    modifier adminRequired() {
        require(owner() == msg.sender || _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
        _;
    }   

    /**
     * @dev See {IAdminControl-getAdmins}.
     */
    function getAdmins() external view override returns (address[] memory admins) {
        admins = new address[](_admins.length());
        for (uint i = 0; i < _admins.length(); i++) {
            admins[i] = _admins.at(i);
        }
        return admins;
    }

    /**
     * @dev See {IAdminControl-approveAdmin}.
     */
    function approveAdmin(address admin) external override onlyOwner {
        if (!_admins.contains(admin)) {
            emit AdminApproved(admin, msg.sender);
            _admins.add(admin);
        }
    }

    /**
     * @dev See {IAdminControl-revokeAdmin}.
     */
    function revokeAdmin(address admin) external override onlyOwner {
        if (_admins.contains(admin)) {
            emit AdminRevoked(admin, msg.sender);
            _admins.remove(admin);
        }
    }

    /**
     * @dev See {IAdminControl-isAdmin}.
     */
    function isAdmin(address admin) public override view returns (bool) {
        return (owner() == admin || _admins.contains(admin));
    }

}

File 17 of 27 : ICreatorExtensionTokenURI.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @dev Implement this if you want your extension to have overloadable URI's
 */
interface ICreatorExtensionTokenURI is IERC165 {

    /**
     * Get the uri for a given creator/tokenId
     */
    function tokenURI(address creator, uint256 tokenId) external view returns (string memory);
}

File 18 of 27 : CreatorCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";

import "../extensions/ICreatorExtensionTokenURI.sol";
import "../extensions/ICreatorExtensionRoyalties.sol";

import "./ICreatorCore.sol";

/**
 * @dev Core creator implementation
 */
abstract contract CreatorCore is ReentrancyGuard, ICreatorCore, ERC165 {
    using Strings for uint256;
    using EnumerableSet for EnumerableSet.AddressSet;
    using AddressUpgradeable for address;

    uint256 internal _tokenCount = 0;

    // Base approve transfers address location
    address internal _approveTransferBase;

    // Track registered extensions data
    EnumerableSet.AddressSet internal _extensions;
    EnumerableSet.AddressSet internal _blacklistedExtensions;
    mapping (address => address) internal _extensionPermissions;
    mapping (address => bool) internal _extensionApproveTransfers;
    
    // For tracking which extension a token was minted by
    mapping (uint256 => address) internal _tokensExtension;

    // The baseURI for a given extension
    mapping (address => string) private _extensionBaseURI;
    mapping (address => bool) private _extensionBaseURIIdentical;

    // The prefix for any tokens with a uri configured
    mapping (address => string) private _extensionURIPrefix;

    // Mapping for individual token URIs
    mapping (uint256 => string) internal _tokenURIs;

    // Royalty configurations
    struct RoyaltyConfig {
        address payable receiver;
        uint16 bps;
    }
    mapping (address => RoyaltyConfig[]) internal _extensionRoyalty;
    mapping (uint256 => RoyaltyConfig[]) internal _tokenRoyalty;

    bytes4 private constant _CREATOR_CORE_V1 = 0x28f10a21;

    /**
     * External interface identifiers for royalties
     */

    /**
     *  @dev CreatorCore
     *
     *  bytes4(keccak256('getRoyalties(uint256)')) == 0xbb3bafd6
     *
     *  => 0xbb3bafd6 = 0xbb3bafd6
     */
    bytes4 private constant _INTERFACE_ID_ROYALTIES_CREATORCORE = 0xbb3bafd6;

    /**
     *  @dev Rarible: RoyaltiesV1
     *
     *  bytes4(keccak256('getFeeRecipients(uint256)')) == 0xb9c4d9fb
     *  bytes4(keccak256('getFeeBps(uint256)')) == 0x0ebd4c7f
     *
     *  => 0xb9c4d9fb ^ 0x0ebd4c7f = 0xb7799584
     */
    bytes4 private constant _INTERFACE_ID_ROYALTIES_RARIBLE = 0xb7799584;

    /**
     *  @dev Foundation
     *
     *  bytes4(keccak256('getFees(uint256)')) == 0xd5a06d4c
     *
     *  => 0xd5a06d4c = 0xd5a06d4c
     */
    bytes4 private constant _INTERFACE_ID_ROYALTIES_FOUNDATION = 0xd5a06d4c;

    /**
     *  @dev EIP-2981
     *
     * bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a
     *
     * => 0x2a55205a = 0x2a55205a
     */
    bytes4 private constant _INTERFACE_ID_ROYALTIES_EIP2981 = 0x2a55205a;

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(ICreatorCore).interfaceId || interfaceId == _CREATOR_CORE_V1 || super.supportsInterface(interfaceId)
            || interfaceId == _INTERFACE_ID_ROYALTIES_CREATORCORE || interfaceId == _INTERFACE_ID_ROYALTIES_RARIBLE
            || interfaceId == _INTERFACE_ID_ROYALTIES_FOUNDATION || interfaceId == _INTERFACE_ID_ROYALTIES_EIP2981;
    }

    /**
     * @dev Only allows registered extensions to call the specified function
     */
    function requireExtension() internal view {
        require(_extensions.contains(msg.sender), "Must be registered extension");
    }

    /**
     * @dev Only allows non-blacklisted extensions
     */
    function requireNonBlacklist(address extension) internal view {
        require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");
    }   

    /**
     * @dev See {ICreatorCore-getExtensions}.
     */
    function getExtensions() external view override returns (address[] memory extensions) {
        extensions = new address[](_extensions.length());
        for (uint i; i < _extensions.length();) {
            extensions[i] = _extensions.at(i);
            unchecked { ++i; }
        }
        return extensions;
    }

    /**
     * @dev Register an extension
     */
    function _registerExtension(address extension, string calldata baseURI, bool baseURIIdentical) internal {
        require(extension != address(this) && extension.isContract(), "Invalid");
        emit ExtensionRegistered(extension, msg.sender);
        _extensionBaseURI[extension] = baseURI;
        _extensionBaseURIIdentical[extension] = baseURIIdentical;
        _extensions.add(extension);
        _setApproveTransferExtension(extension, true);
    }

    /**
     * @dev See {ICreatorCore-setApproveTransferExtension}.
     */
    function setApproveTransferExtension(bool enabled) external override {
        requireExtension();
        _setApproveTransferExtension(msg.sender, enabled);
    }

    /**
     * @dev Set whether or not tokens minted by the extension defers transfer approvals to the extension
     */
    function _setApproveTransferExtension(address extension, bool enabled) internal virtual;

    /**
     * @dev Unregister an extension
     */
    function _unregisterExtension(address extension) internal {
        emit ExtensionUnregistered(extension, msg.sender);
        _extensions.remove(extension);
    }

    /**
     * @dev Blacklist an extension
     */
    function _blacklistExtension(address extension) internal {
       require(extension != address(0) && extension != address(this), "Cannot blacklist yourself");
       if (_extensions.contains(extension)) {
           emit ExtensionUnregistered(extension, msg.sender);
           _extensions.remove(extension);
       }
       if (!_blacklistedExtensions.contains(extension)) {
           emit ExtensionBlacklisted(extension, msg.sender);
           _blacklistedExtensions.add(extension);
       }
    }

    /**
     * @dev Set base token uri for an extension
     */
    function _setBaseTokenURIExtension(string calldata uri, bool identical) internal {
        _extensionBaseURI[msg.sender] = uri;
        _extensionBaseURIIdentical[msg.sender] = identical;
    }

    /**
     * @dev Set token uri prefix for an extension
     */
    function _setTokenURIPrefixExtension(string calldata prefix) internal {
        _extensionURIPrefix[msg.sender] = prefix;
    }

    /**
     * @dev Set token uri for a token of an extension
     */
    function _setTokenURIExtension(uint256 tokenId, string calldata uri) internal {
        require(_tokensExtension[tokenId] == msg.sender, "Invalid token");
        _tokenURIs[tokenId] = uri;
    }

    /**
     * @dev Set base token uri for tokens with no extension
     */
    function _setBaseTokenURI(string memory uri) internal {
        _extensionBaseURI[address(0)] = uri;
    }

    /**
     * @dev Set token uri prefix for tokens with no extension
     */
    function _setTokenURIPrefix(string calldata prefix) internal {
        _extensionURIPrefix[address(0)] = prefix;
    }


    /**
     * @dev Set token uri for a token with no extension
     */
    function _setTokenURI(uint256 tokenId, string calldata uri) internal {
        require(tokenId > 0 && tokenId <= _tokenCount && _tokensExtension[tokenId] == address(0), "Invalid token");
        _tokenURIs[tokenId] = uri;
    }

    /**
     * @dev Retrieve a token's URI
     */
    function _tokenURI(uint256 tokenId) internal view returns (string memory) {
        require(tokenId > 0 && tokenId <= _tokenCount, "Invalid token");

        address extension = _tokensExtension[tokenId];
        require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");

        if (bytes(_tokenURIs[tokenId]).length != 0) {
            if (bytes(_extensionURIPrefix[extension]).length != 0) {
                return string(abi.encodePacked(_extensionURIPrefix[extension],_tokenURIs[tokenId]));
            }
            return _tokenURIs[tokenId];
        }

        if (ERC165Checker.supportsInterface(extension, type(ICreatorExtensionTokenURI).interfaceId)) {
            return ICreatorExtensionTokenURI(extension).tokenURI(address(this), tokenId);
        }

        if (!_extensionBaseURIIdentical[extension]) {
            return string(abi.encodePacked(_extensionBaseURI[extension], tokenId.toString()));
        } else {
            return _extensionBaseURI[extension];
        }
    }

    /**
     * Get token extension
     */
    function _tokenExtension(uint256 tokenId) internal view returns (address extension) {
        extension = _tokensExtension[tokenId];

        require(extension != address(0), "No extension for token");
        require(!_blacklistedExtensions.contains(extension), "Extension blacklisted");

        return extension;
    }

    /**
     * Helper to get royalties for a token
     */
    function _getRoyalties(uint256 tokenId) view internal returns (address payable[] memory receivers, uint256[] memory bps) {

        // Get token level royalties
        RoyaltyConfig[] memory royalties = _tokenRoyalty[tokenId];
        if (royalties.length == 0) {
            // Get extension specific royalties
            address extension = _tokensExtension[tokenId];
            if (extension != address(0)) {
                if (ERC165Checker.supportsInterface(extension, type(ICreatorExtensionRoyalties).interfaceId)) {
                    (receivers, bps) = ICreatorExtensionRoyalties(extension).getRoyalties(address(this), tokenId);
                    // Extension override exists, just return that
                    if (receivers.length > 0) return (receivers, bps);
                }
                royalties = _extensionRoyalty[extension];
            }
        }
        if (royalties.length == 0) {
            // Get the default royalty
            royalties = _extensionRoyalty[address(0)];
        }
        
        if (royalties.length > 0) {
            receivers = new address payable[](royalties.length);
            bps = new uint256[](royalties.length);
            for (uint i; i < royalties.length;) {
                receivers[i] = royalties[i].receiver;
                bps[i] = royalties[i].bps;
                unchecked { ++i; }
            }
        }
    }

    /**
     * Helper to get royalty receivers for a token
     */
    function _getRoyaltyReceivers(uint256 tokenId) view internal returns (address payable[] memory recievers) {
        (recievers, ) = _getRoyalties(tokenId);
    }

    /**
     * Helper to get royalty basis points for a token
     */
    function _getRoyaltyBPS(uint256 tokenId) view internal returns (uint256[] memory bps) {
        (, bps) = _getRoyalties(tokenId);
    }

    function _getRoyaltyInfo(uint256 tokenId, uint256 value) view internal returns (address receiver, uint256 amount){
        (address payable[] memory receivers, uint256[] memory bps) = _getRoyalties(tokenId);
        require(receivers.length <= 1, "More than 1 royalty receiver");
        
        if (receivers.length == 0) {
            return (address(this), 0);
        }
        return (receivers[0], bps[0]*value/10000);
    }

    /**
     * Set royalties for a token
     */
    function _setRoyalties(uint256 tokenId, address payable[] calldata receivers, uint256[] calldata basisPoints) internal {
       _checkRoyalties(receivers, basisPoints);
        delete _tokenRoyalty[tokenId];
        _setRoyalties(receivers, basisPoints, _tokenRoyalty[tokenId]);
        emit RoyaltiesUpdated(tokenId, receivers, basisPoints);
    }

    /**
     * Set royalties for all tokens of an extension
     */
    function _setRoyaltiesExtension(address extension, address payable[] calldata receivers, uint256[] calldata basisPoints) internal {
        _checkRoyalties(receivers, basisPoints);
        delete _extensionRoyalty[extension];
        _setRoyalties(receivers, basisPoints, _extensionRoyalty[extension]);
        if (extension == address(0)) {
            emit DefaultRoyaltiesUpdated(receivers, basisPoints);
        } else {
            emit ExtensionRoyaltiesUpdated(extension, receivers, basisPoints);
        }
    }

    /**
     * Helper function to check that royalties provided are valid
     */
    function _checkRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) private pure {
        require(receivers.length == basisPoints.length, "Invalid input");
        uint256 totalBasisPoints;
        for (uint i; i < basisPoints.length;) {
            totalBasisPoints += basisPoints[i];
            unchecked { ++i; }
        }
        require(totalBasisPoints < 10000, "Invalid total royalties");
    }

    /**
     * Helper function to set royalties
     */
    function _setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints, RoyaltyConfig[] storage royalties) private {
        for (uint i; i < basisPoints.length;) {
            royalties.push(
                RoyaltyConfig(
                    {
                        receiver: receivers[i],
                        bps: uint16(basisPoints[i])
                    }
                )
            );
            unchecked { ++i; }
        }
    }

    /**
     * @dev See {ICreatorCore-getApproveTransfer}.
     */
    function getApproveTransfer() external view override returns (address) {
        return _approveTransferBase;
    }
}

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

pragma solidity ^0.8.0;

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

File 20 of 27 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 21 of 27 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

File 23 of 27 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 24 of 27 : ICreatorCore.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @dev Core creator interface
 */
interface ICreatorCore is IERC165 {

    event ExtensionRegistered(address indexed extension, address indexed sender);
    event ExtensionUnregistered(address indexed extension, address indexed sender);
    event ExtensionBlacklisted(address indexed extension, address indexed sender);
    event MintPermissionsUpdated(address indexed extension, address indexed permissions, address indexed sender);
    event RoyaltiesUpdated(uint256 indexed tokenId, address payable[] receivers, uint256[] basisPoints);
    event DefaultRoyaltiesUpdated(address payable[] receivers, uint256[] basisPoints);
    event ApproveTransferUpdated(address extension);
    event ExtensionRoyaltiesUpdated(address indexed extension, address payable[] receivers, uint256[] basisPoints);
    event ExtensionApproveTransferUpdated(address indexed extension, bool enabled);

    /**
     * @dev gets address of all extensions
     */
    function getExtensions() external view returns (address[] memory);

    /**
     * @dev add an extension.  Can only be called by contract owner or admin.
     * extension address must point to a contract implementing ICreatorExtension.
     * Returns True if newly added, False if already added.
     */
    function registerExtension(address extension, string calldata baseURI) external;

    /**
     * @dev add an extension.  Can only be called by contract owner or admin.
     * extension address must point to a contract implementing ICreatorExtension.
     * Returns True if newly added, False if already added.
     */
    function registerExtension(address extension, string calldata baseURI, bool baseURIIdentical) external;

    /**
     * @dev add an extension.  Can only be called by contract owner or admin.
     * Returns True if removed, False if already removed.
     */
    function unregisterExtension(address extension) external;

    /**
     * @dev blacklist an extension.  Can only be called by contract owner or admin.
     * This function will destroy all ability to reference the metadata of any tokens created
     * by the specified extension. It will also unregister the extension if needed.
     * Returns True if removed, False if already removed.
     */
    function blacklistExtension(address extension) external;

    /**
     * @dev set the baseTokenURI of an extension.  Can only be called by extension.
     */
    function setBaseTokenURIExtension(string calldata uri) external;

    /**
     * @dev set the baseTokenURI of an extension.  Can only be called by extension.
     * For tokens with no uri configured, tokenURI will return "uri+tokenId"
     */
    function setBaseTokenURIExtension(string calldata uri, bool identical) external;

    /**
     * @dev set the common prefix of an extension.  Can only be called by extension.
     * If configured, and a token has a uri set, tokenURI will return "prefixURI+tokenURI"
     * Useful if you want to use ipfs/arweave
     */
    function setTokenURIPrefixExtension(string calldata prefix) external;

    /**
     * @dev set the tokenURI of a token extension.  Can only be called by extension that minted token.
     */
    function setTokenURIExtension(uint256 tokenId, string calldata uri) external;

    /**
     * @dev set the tokenURI of a token extension for multiple tokens.  Can only be called by extension that minted token.
     */
    function setTokenURIExtension(uint256[] memory tokenId, string[] calldata uri) external;

    /**
     * @dev set the baseTokenURI for tokens with no extension.  Can only be called by owner/admin.
     * For tokens with no uri configured, tokenURI will return "uri+tokenId"
     */
    function setBaseTokenURI(string calldata uri) external;

    /**
     * @dev set the common prefix for tokens with no extension.  Can only be called by owner/admin.
     * If configured, and a token has a uri set, tokenURI will return "prefixURI+tokenURI"
     * Useful if you want to use ipfs/arweave
     */
    function setTokenURIPrefix(string calldata prefix) external;

    /**
     * @dev set the tokenURI of a token with no extension.  Can only be called by owner/admin.
     */
    function setTokenURI(uint256 tokenId, string calldata uri) external;

    /**
     * @dev set the tokenURI of multiple tokens with no extension.  Can only be called by owner/admin.
     */
    function setTokenURI(uint256[] memory tokenIds, string[] calldata uris) external;

    /**
     * @dev set a permissions contract for an extension.  Used to control minting.
     */
    function setMintPermissions(address extension, address permissions) external;

    /**
     * @dev Configure so transfers of tokens created by the caller (must be extension) gets approval
     * from the extension before transferring
     */
    function setApproveTransferExtension(bool enabled) external;

    /**
     * @dev get the extension of a given token
     */
    function tokenExtension(uint256 tokenId) external view returns (address);

    /**
     * @dev Set default royalties
     */
    function setRoyalties(address payable[] calldata receivers, uint256[] calldata basisPoints) external;

    /**
     * @dev Set royalties of a token
     */
    function setRoyalties(uint256 tokenId, address payable[] calldata receivers, uint256[] calldata basisPoints) external;

    /**
     * @dev Set royalties of an extension
     */
    function setRoyaltiesExtension(address extension, address payable[] calldata receivers, uint256[] calldata basisPoints) external;

    /**
     * @dev Get royalites of a token.  Returns list of receivers and basisPoints
     */
    function getRoyalties(uint256 tokenId) external view returns (address payable[] memory, uint256[] memory);
    
    // Royalty support for various other standards
    function getFeeRecipients(uint256 tokenId) external view returns (address payable[] memory);
    function getFeeBps(uint256 tokenId) external view returns (uint[] memory);
    function getFees(uint256 tokenId) external view returns (address payable[] memory, uint256[] memory);
    function royaltyInfo(uint256 tokenId, uint256 value) external view returns (address, uint256);

    /**
     * @dev Set the default approve transfer contract location.
     */
    function setApproveTransfer(address extension) external; 

    /**
     * @dev Get the default approve transfer contract location.
     */
    function getApproveTransfer() external view returns (address);
}

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

pragma solidity ^0.8.0;

/// @author: manifold.xyz

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/**
 * @dev Implement this if you want your extension to have overloadable royalties
 */
interface ICreatorExtensionRoyalties is IERC165 {

    /**
     * Get the royalties for a given creator/tokenId
     */
    function getRoyalties(address creator, uint256 tokenId) external view returns (address payable[] memory, uint256[] memory);
}

File 26 of 27 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 27 of 27 : ERC165Checker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/ERC165Checker.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Library used to query support of an interface declared via {IERC165}.
 *
 * Note that these functions return the actual result of the query: they do not
 * `revert` if an interface is not supported. It is up to the caller to decide
 * what to do in these cases.
 */
library ERC165Checker {
    // As per the EIP-165 spec, no interface should ever match 0xffffffff
    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;

    /**
     * @dev Returns true if `account` supports the {IERC165} interface.
     */
    function supportsERC165(address account) internal view returns (bool) {
        // Any contract that implements ERC165 must explicitly indicate support of
        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
        return
            supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&
            !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);
    }

    /**
     * @dev Returns true if `account` supports the interface defined by
     * `interfaceId`. Support for {IERC165} itself is queried automatically.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
        // query support of both ERC165 as per the spec and support of _interfaceId
        return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);
    }

    /**
     * @dev Returns a boolean array where each value corresponds to the
     * interfaces passed in and whether they're supported or not. This allows
     * you to batch check interfaces for a contract where your expectation
     * is that some interfaces may not be supported.
     *
     * See {IERC165-supportsInterface}.
     *
     * _Available since v3.4._
     */
    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
        internal
        view
        returns (bool[] memory)
    {
        // an array of booleans corresponding to interfaceIds and whether they're supported or not
        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);

        // query support of ERC165 itself
        if (supportsERC165(account)) {
            // query support of each interface in interfaceIds
            for (uint256 i = 0; i < interfaceIds.length; i++) {
                interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);
            }
        }

        return interfaceIdsSupported;
    }

    /**
     * @dev Returns true if `account` supports all the interfaces defined in
     * `interfaceIds`. Support for {IERC165} itself is queried automatically.
     *
     * Batch-querying can lead to gas savings by skipping repeated checks for
     * {IERC165} support.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
        // query support of ERC165 itself
        if (!supportsERC165(account)) {
            return false;
        }

        // query support of each interface in interfaceIds
        for (uint256 i = 0; i < interfaceIds.length; i++) {
            if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {
                return false;
            }
        }

        // all interfaces supported
        return true;
    }

    /**
     * @notice Query if a contract implements an interface, does not check ERC165 support
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return true if the contract at account indicates support of the interface with
     * identifier interfaceId, false otherwise
     * @dev Assumes that account contains a contract that supports ERC165, otherwise
     * the behavior of this method is undefined. This precondition can be checked
     * with {supportsERC165}.
     * Interface identification is specified in ERC-165.
     */
    function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {
        // prepare call
        bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);

        // perform static call
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly {
            success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0x00)
        }

        return success && returnSize >= 0x20 && returnValue > 0;
    }
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"AdminApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"AdminRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creatorContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":false,"internalType":"address","name":"initializer","type":"address"}],"name":"BurnRedeemInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creatorContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"index","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"BurnRedeemMint","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"},{"inputs":[],"name":"BURN_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MULTI_BURN_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"address[]","name":"recipients","type":"address[]"},{"internalType":"uint32[]","name":"amounts","type":"uint32[]"}],"name":"airdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"approveAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"creatorContractAddresses","type":"address[]"},{"internalType":"uint256[]","name":"indexes","type":"uint256[]"},{"internalType":"uint32[]","name":"burnRedeemCounts","type":"uint32[]"},{"components":[{"internalType":"uint48","name":"groupIndex","type":"uint48"},{"internalType":"uint48","name":"itemIndex","type":"uint48"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"internalType":"struct IBurnRedeemCore.BurnToken[][]","name":"burnTokens","type":"tuple[][]"}],"name":"burnRedeem","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"uint32","name":"burnRedeemCount","type":"uint32"},{"components":[{"internalType":"uint48","name":"groupIndex","type":"uint48"},{"internalType":"uint48","name":"itemIndex","type":"uint48"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"internalType":"struct IBurnRedeemCore.BurnToken[]","name":"burnTokens","type":"tuple[]"}],"name":"burnRedeem","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getAdmins","outputs":[{"internalType":"address[]","name":"admins","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getBurnRedeem","outputs":[{"components":[{"internalType":"address payable","name":"paymentReceiver","type":"address"},{"internalType":"enum IBurnRedeemCore.StorageProtocol","name":"storageProtocol","type":"uint8"},{"internalType":"uint32","name":"redeemedCount","type":"uint32"},{"internalType":"uint16","name":"redeemAmount","type":"uint16"},{"internalType":"uint32","name":"totalSupply","type":"uint32"},{"internalType":"uint48","name":"startDate","type":"uint48"},{"internalType":"uint48","name":"endDate","type":"uint48"},{"internalType":"uint160","name":"cost","type":"uint160"},{"internalType":"string","name":"location","type":"string"},{"components":[{"internalType":"uint256","name":"requiredCount","type":"uint256"},{"components":[{"internalType":"enum IBurnRedeemCore.ValidationType","name":"validationType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"enum IBurnRedeemCore.TokenSpec","name":"tokenSpec","type":"uint8"},{"internalType":"enum IBurnRedeemCore.BurnSpec","name":"burnSpec","type":"uint8"},{"internalType":"uint72","name":"amount","type":"uint72"},{"internalType":"uint256","name":"minTokenId","type":"uint256"},{"internalType":"uint256","name":"maxTokenId","type":"uint256"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"internalType":"struct IBurnRedeemCore.BurnItem[]","name":"items","type":"tuple[]"}],"internalType":"struct IBurnRedeemCore.BurnGroup[]","name":"burnSet","type":"tuple[]"}],"internalType":"struct IBurnRedeemCore.BurnRedeem","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"components":[{"internalType":"address payable","name":"paymentReceiver","type":"address"},{"internalType":"enum IBurnRedeemCore.StorageProtocol","name":"storageProtocol","type":"uint8"},{"internalType":"uint16","name":"redeemAmount","type":"uint16"},{"internalType":"uint32","name":"totalSupply","type":"uint32"},{"internalType":"uint48","name":"startDate","type":"uint48"},{"internalType":"uint48","name":"endDate","type":"uint48"},{"internalType":"uint160","name":"cost","type":"uint160"},{"internalType":"string","name":"location","type":"string"},{"components":[{"internalType":"uint256","name":"requiredCount","type":"uint256"},{"components":[{"internalType":"enum IBurnRedeemCore.ValidationType","name":"validationType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"enum IBurnRedeemCore.TokenSpec","name":"tokenSpec","type":"uint8"},{"internalType":"enum IBurnRedeemCore.BurnSpec","name":"burnSpec","type":"uint8"},{"internalType":"uint72","name":"amount","type":"uint72"},{"internalType":"uint256","name":"minTokenId","type":"uint256"},{"internalType":"uint256","name":"maxTokenId","type":"uint256"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"internalType":"struct IBurnRedeemCore.BurnItem[]","name":"items","type":"tuple[]"}],"internalType":"struct IBurnRedeemCore.BurnGroup[]","name":"burnSet","type":"tuple[]"}],"internalType":"struct IBurnRedeemCore.BurnRedeemParameters","name":"burnRedeemParameters","type":"tuple"}],"name":"initializeBurnRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manifoldMembershipContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"destination","type":"address"}],"name":"recoverERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"revokeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"setMembershipAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"uri","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"components":[{"internalType":"address payable","name":"paymentReceiver","type":"address"},{"internalType":"enum IBurnRedeemCore.StorageProtocol","name":"storageProtocol","type":"uint8"},{"internalType":"uint16","name":"redeemAmount","type":"uint16"},{"internalType":"uint32","name":"totalSupply","type":"uint32"},{"internalType":"uint48","name":"startDate","type":"uint48"},{"internalType":"uint48","name":"endDate","type":"uint48"},{"internalType":"uint160","name":"cost","type":"uint160"},{"internalType":"string","name":"location","type":"string"},{"components":[{"internalType":"uint256","name":"requiredCount","type":"uint256"},{"components":[{"internalType":"enum IBurnRedeemCore.ValidationType","name":"validationType","type":"uint8"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"enum IBurnRedeemCore.TokenSpec","name":"tokenSpec","type":"uint8"},{"internalType":"enum IBurnRedeemCore.BurnSpec","name":"burnSpec","type":"uint8"},{"internalType":"uint72","name":"amount","type":"uint72"},{"internalType":"uint256","name":"minTokenId","type":"uint256"},{"internalType":"uint256","name":"maxTokenId","type":"uint256"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"internalType":"struct IBurnRedeemCore.BurnItem[]","name":"items","type":"tuple[]"}],"internalType":"struct IBurnRedeemCore.BurnGroup[]","name":"burnSet","type":"tuple[]"}],"internalType":"struct IBurnRedeemCore.BurnRedeemParameters","name":"burnRedeemParameters","type":"tuple"}],"name":"updateBurnRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"enum IBurnRedeemCore.StorageProtocol","name":"storageProtocol","type":"uint8"},{"internalType":"string","name":"location","type":"string"}],"name":"updateURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b506200001d3362000028565b600160035562000078565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b615c4080620000886000396000f3fe6080604052600436106101965760003560e01c8063715018a6116100e1578063c2065c101161008a578063f0e9fcd111610064578063f0e9fcd11461047c578063f23a6e611461049c578063f2fde38b146104bc578063f3fef3a3146104dc57600080fd5b8063c2065c101461041c578063c9dad6961461043c578063e9dc63751461044f57600080fd5b806395bc312b116100bb57806395bc312b146103b4578063b058d2f8146103cf578063bc197c81146103fc57600080fd5b8063715018a6146103615780637ab39392146103765780638da5cb5b1461039657600080fd5b806338ec89951161014357806350d108391161011d57806350d10839146102e9578063625888da146103215780636d73e6691461034157600080fd5b806338ec89951461028d57806342b54fee146102ad578063480df058146102c057600080fd5b806324d7806c1161017457806324d7806c1461022b5780632d3456701461024b57806331ae450b1461026b57600080fd5b806301ffc9a71461019b57806304ea1e90146101d0578063150b7a02146101f2575b600080fd5b3480156101a757600080fd5b506101bb6101b6366004614744565b6104fc565b60405190151581526020015b60405180910390f35b3480156101dc57600080fd5b506101f06101eb3660046147e9565b610527565b005b3480156101fe57600080fd5b5061021261020d36600461485c565b61062c565b6040516001600160e01b031990911681526020016101c7565b34801561023757600080fd5b506101bb6102463660046148b2565b6106a8565b34801561025757600080fd5b506101f06102663660046148b2565b6106e1565b34801561027757600080fd5b5061028061073f565b6040516101c79190614913565b34801561029957600080fd5b506101f06102a8366004614926565b6107ee565b6101f06102bb3660046149cc565b610a4a565b3480156102cc57600080fd5b506102db6602738d24e5200081565b6040519081526020016101c7565b3480156102f557600080fd5b50600554610309906001600160a01b031681565b6040516001600160a01b0390911681526020016101c7565b34801561032d57600080fd5b506101f061033c366004614926565b610bdf565b34801561034d57600080fd5b506101f061035c3660046148b2565b610c9f565b34801561036d57600080fd5b506101f0610cf7565b34801561038257600080fd5b506101f06103913660046148b2565b610d0b565b3480156103a257600080fd5b506000546001600160a01b0316610309565b3480156103c057600080fd5b506102db660384665653e00081565b3480156103db57600080fd5b506103ef6103ea366004614a90565b610db3565b6040516101c79190614c54565b34801561040857600080fd5b50610212610417366004614d41565b61112d565b34801561042857600080fd5b506101f0610437366004614dec565b611292565b6101f061044a366004614e8c565b6114d1565b34801561045b57600080fd5b5061046f61046a366004614a90565b61156d565b6040516101c79190614eec565b34801561048857600080fd5b506101f0610497366004614eff565b6119e8565b3480156104a857600080fd5b506102126104b7366004614f36565b611adb565b3480156104c857600080fd5b506101f06104d73660046148b2565b611bc7565b3480156104e857600080fd5b506101f06104f7366004614a90565b611c3d565b60006001600160e01b03198216635e5e1fdf60e01b1480610521575061052182611d6b565b92915050565b604051630935e01b60e21b815233600482015285906001600160a01b038216906324d7806c90602401602060405180830381865afa15801561056d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105919190614fa0565b6105db5760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064015b60405180910390fd5b60006105e78787611de1565b80549091508590829060ff60a01b1916600160a01b83600381111561060e5761060e614abc565b021790555060028101610622848683615058565b5050505050505050565b60006002600354036106805760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b600260035561069185858585611e6f565b50630a85bd0160e11b600160035595945050505050565b6000816001600160a01b03166106c66000546001600160a01b031690565b6001600160a01b0316148061052157506105216001836121cd565b6106e96121f2565b6106f46001826121cd565b1561073c5760405133906001600160a01b038316907f7c0c3c84c67c85fcac635147348bfe374c24a1a93d0366d1cfe9d8853cbf89d590600090a361073a60018261224c565b505b50565b606061074b6001612261565b67ffffffffffffffff81111561076357610763614fc2565b60405190808252806020026020018201604052801561078c578160200160208202803683370190505b50905060005b61079c6001612261565b8110156107ea576107ae60018261226b565b8282815181106107c0576107c0615118565b6001600160a01b0390921660209283029190910190910152806107e281615144565b915050610792565b5090565b604051630935e01b60e21b815233600482015283906001600160a01b038216906324d7806c90602401602060405180830381865afa158015610834573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108589190614fa0565b61089d5760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064016105d2565b6108a8848484612277565b6040805160018082528183019092526000916020808301908036833701905050905033816000815181106108de576108de615118565b6001600160a01b039290921660209283029190910190910152604080516001808252818301909252600091816020015b606081526020019060019003908161090e57505060408051600180825281830190925291925060009190602080830190803683375050604051634637423960e11b81529192506000916001600160a01b038a169150638c6e84729061097b9087908690889060040161518d565b6000604051808303816000875af115801561099a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109c29190810190615292565b9050806000815181106109d7576109d7615118565b6020908102919091018101516001600160a01b038a1660008181526006845260408082208c835285528082209390935590815260079092528120825189929084908290610a2657610a26615118565b60200260200101518152602001908152602001600020819055505050505050505050565b600260035403610a9c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b60026003558685148015610aaf57508683145b8015610aba57508681145b610af95760405162461bcd60e51b815260206004820152601060248201526f496e76616c69642063616c6c6461746160801b60448201526064016105d2565b6000610b0433612375565b90503460005b89811015610bbd57610ba9828c8c84818110610b2857610b28615118565b9050602002016020810190610b3d91906148b2565b8b8b85818110610b4f57610b4f615118565b905060200201358a8a86818110610b6857610b68615118565b9050602002016020810190610b7d9190615328565b898987818110610b8f57610b8f615118565b9050602002810190610ba19190615343565b8960006123fb565b610bb3908361538d565b9150600101610b0a565b508015610bce57610bce3382611cc3565b505060016003555050505050505050565b604051630935e01b60e21b815233600482015283906001600160a01b038216906324d7806c90602401602060405180830381865afa158015610c25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c499190614fa0565b610c8e5760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064016105d2565b610c99848484612595565b50505050565b610ca76121f2565b610cb26001826121cd565b61073c5760405133906001600160a01b038316907f7e1a1a08d52e4ba0e21554733d66165fd5151f99460116223d9e3a608eec5cb190600090a361073a6001826126ae565b610cff6121f2565b610d0960006126c3565b565b33610d1e6000546001600160a01b031690565b6001600160a01b03161480610d395750610d396001336121cd565b610d915760405162461bcd60e51b8152602060048201526024808201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616044820152633236b4b760e11b60648201526084016105d2565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b604080516101408101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e08201929092526101008101829052610120810191909152610e108383611de1565b60408051610140810190915281546001600160a01b03811682529091906020830190600160a01b900460ff166003811115610e4d57610e4d614abc565b6003811115610e5e57610e5e614abc565b8152815463ffffffff600160a81b82048116602084015261ffff600160c81b8304166040840152600160d81b909104166060820152600182015465ffffffffffff8082166080840152660100000000000082041660a08301526001600160a01b03600160601b9091041660c082015260028201805460e090920191610ee290614fd8565b80601f0160208091040260200160405190810160405280929190818152602001828054610f0e90614fd8565b8015610f5b5780601f10610f3057610100808354040283529160200191610f5b565b820191906000526020600020905b815481529060010190602001808311610f3e57829003601f168201915b5050505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b8282101561111e57838290600052602060002090600202016040518060400160405290816000820154815260200160018201805480602002602001604051908101604052809291908181526020016000905b8282101561110757600084815260209020604080516101008101909152600484029091018054829060ff16600381111561101757611017614abc565b600381111561102857611028614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561106057611060614abc565b600281111561107157611071614abc565b81528154602090910190600160b01b900460ff16600281111561109657611096614abc565b60028111156110a7576110a7614abc565b81526020016000820160179054906101000a90046001600160481b03166001600160481b03166001600160481b03168152602001600182015481526020016002820154815260200160038201548152505081526020019060010190610fdb565b505050508152505081526020019060010190610f89565b50505091525090949350505050565b60006002600354036111815760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b60026003556111916020836153b6565b156111cd5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206461746160a01b60448201526064016105d2565b6000808060606111df8688018861552c565b809450819550829650839750505050506112748c8c8c80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508b8b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508a925089915088905087612713565b505060016003555063bc197c8160e01b9a9950505050505050505050565b604051630935e01b60e21b815233600482015286906001600160a01b038216906324d7806c90602401602060405180830381865afa1580156112d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fc9190614fa0565b6113415760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064016105d2565b8382146113835760405162461bcd60e51b815260206004820152601060248201526f496e76616c69642063616c6c6461746160801b60448201526064016105d2565b600061138f8888611de1565b90506000805b848110156113f5578254600160c81b900461ffff168686838181106113bc576113bc615118565b90506020020160208101906113d19190615328565b6113db91906155aa565b6113eb9063ffffffff16836155d2565b9150600101611395565b50815463ffffffff9061141190600160a81b90048216836155d2565b11156114505760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b60005b868110156114bc576114b48a8a858b8b8681811061147357611473615118565b905060200201602081019061148891906148b2565b8a8a8781811061149a5761149a615118565b90506020020160208101906114af9190615328565b612bc6565b600101611453565b506114c682612df4565b505050505050505050565b6002600354036115235760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b6002600355600061154334878787878761153c33612375565b60016123fb565b905080341115611560576115603361155b833461538d565b611cc3565b5050600160035550505050565b6001600160a01b0382166000908152600760209081526040808320848452909152902054606090806115e15760405162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f7420657869737400000000000000000000000060448201526064016105d2565b6001600160a01b038481166000908152600460209081526040808320858452825280832081516101408101909252805494851682529293909291830190600160a01b900460ff16600381111561163957611639614abc565b600381111561164a5761164a614abc565b8152815463ffffffff600160a81b82048116602084015261ffff600160c81b8304166040840152600160d81b909104166060820152600182015465ffffffffffff8082166080840152660100000000000082041660a08301526001600160a01b03600160601b9091041660c082015260028201805460e0909201916116ce90614fd8565b80601f01602080910402602001604051908101604052809291908181526020018280546116fa90614fd8565b80156117475780601f1061171c57610100808354040283529160200191611747565b820191906000526020600020905b81548152906001019060200180831161172a57829003601f168201915b5050505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b8282101561190a57838290600052602060002090600202016040518060400160405290816000820154815260200160018201805480602002602001604051908101604052809291908181526020016000905b828210156118f357600084815260209020604080516101008101909152600484029091018054829060ff16600381111561180357611803614abc565b600381111561181457611814614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561184c5761184c614abc565b600281111561185d5761185d614abc565b81528154602090910190600160b01b900460ff16600281111561188257611882614abc565b600281111561189357611893614abc565b81526020016000820160179054906101000a90046001600160481b03166001600160481b03166001600160481b031681526020016001820154815260200160028201548152602001600382015481525050815260200190600101906117c7565b505050508152505081526020019060010190611775565b5050509152505060408051602081019091526000815290915060028260200151600381111561193b5761193b614abc565b0361197a575060408051808201909152601481527f68747470733a2f2f617277656176652e6e65742f00000000000000000000000060208201526119b7565b60038260200151600381111561199257611992614abc565b036119b75750604080518082019091526007815266697066733a2f2f60c81b60208201525b6101008201516040516119ce9183916020016155e5565b604051602081830303815290604052935050505092915050565b336119fb6000546001600160a01b031690565b6001600160a01b03161480611a165750611a166001336121cd565b611a6e5760405162461bcd60e51b8152602060048201526024808201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616044820152633236b4b760e11b60648201526084016105d2565b6040516323b872dd60e01b81523060048201526001600160a01b038281166024830152604482018490528416906323b872dd90606401600060405180830381600087803b158015611abe57600080fd5b505af1158015611ad2573d6000803e3d6000fd5b50505050505050565b6000600260035403611b2f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b6002600355611b3f6020836153b6565b15611b7b5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206461746160a01b60448201526064016105d2565b60008080806060611b8e87890189615614565b939850919650945092509050611baa8b8b8b8888888888612e52565b505060016003555063f23a6e6160e01b9998505050505050505050565b611bcf6121f2565b6001600160a01b038116611c345760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105d2565b61073c816126c3565b33611c506000546001600160a01b031690565b6001600160a01b03161480611c6b5750611c6b6001336121cd565b611cc35760405162461bcd60e51b8152602060048201526024808201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616044820152633236b4b760e11b60648201526084016105d2565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611d10576040519150601f19603f3d011682016040523d82523d6000602084013e611d15565b606091505b5050905080611d665760405162461bcd60e51b815260206004820152601f60248201527f4661696c656420746f207472616e7366657220746f20726563697069656e740060448201526064016105d2565b505050565b60006001600160e01b0319821663080958b760e41b1480611d9c57506001600160e01b03198216630a85bd0160e11b145b80611db757506001600160e01b03198216630271189760e51b145b80611dd257506001600160e01b0319821663e9dc637560e01b145b80610521575061052182613220565b6001600160a01b03821660009081526004602090815260408083208484529091528120908154600160a01b900460ff166003811115611e2257611e22614abc565b036105215760405162461bcd60e51b815260206004820152601b60248201527f4275726e2072656465656d206e6f7420696e697469616c697a6564000000000060448201526064016105d2565b611e7a6020826153b6565b15611eb65760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206461746160a01b60448201526064016105d2565b600080806060611ec885870187615688565b929650909450925090506000611ede8585613255565b6001810154909150600160601b90046001600160a01b0316158015611f07575060038101546001145b8015611f3a575080600301600081548110611f2457611f24615118565b9060005260206000209060020201600001546001145b8015611f4a5750611f4a89612375565b611f865760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8054600090611fbc9063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b909104166001613380565b63ffffffff1690508060000361200a5760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b60008260030160008154811061202257612022615118565b9060005260206000209060020201600101858154811061204457612044615118565b600091825260209091206040805161010081019091526004909202018054829060ff16600381111561207857612078614abc565b600381111561208957612089614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff1660028111156120c1576120c1614abc565b60028111156120d2576120d2614abc565b81528154602090910190600160b01b900460ff1660028111156120f7576120f7614abc565b600281111561210857612108614abc565b81528154600160b81b90046001600160481b031660208201526001808301546040830152600283015460608301526003909201546080909101529091508160400151600281111561215b5761215b614abc565b146121985760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b6121a481338c876133da565b6121b28130338d60016135cc565b6121c08787858e6001612bc6565b5050505050505050505050565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6000546001600160a01b03163314610d095760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105d2565b60006121eb836001600160a01b038416613aef565b6000610521825490565b60006121eb8383613be9565b6001600160a01b03831660009081526004602090815260408083208584529091528120908154600160a01b900460ff1660038111156122b8576122b8614abc565b146123055760405162461bcd60e51b815260206004820152601f60248201527f4275726e2072656465656d20616c726561647920696e697469616c697a65640060448201526064016105d2565b61230e82613c13565b6123188183613e06565b61232f8161232a610100850185615343565b613f92565b60405133815283906001600160a01b038616907ff4d614881eb59d4bcd5ea596b177a55b560306371604a9490ca2a5c2f24df14d9060200160405180910390a350505050565b6005546000906001600160a01b03161580159061052157506005546040516345ecd02f60e01b81526001600160a01b038481166004830152909116906345ecd02f90602401602060405180830381865afa1580156123d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105219190614fa0565b6000806124088989613255565b805490915061243d9063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b909104168a613380565b96508663ffffffff1660000361249b5782156124915760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b6000915050612589565b6001810154600160601b90046001600160a01b031680856124cc576124bf876142b7565b6124c990836155d2565b91505b60018963ffffffff161115612500576124eb63ffffffff8a16836156df565b91506124fd63ffffffff8a16826156df565b90505b818c10156125415760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b801561255c57825461255c906001600160a01b031682611cc3565b6125778361256a898b6156f6565b8b63ffffffff16336142dd565b6125848b8b85338d612bc6565b509150505b98975050505050505050565b60006125a18484611de1565b905060008154600160a01b900460ff1660038111156125c2576125c2614abc565b0361260f5760405162461bcd60e51b815260206004820152601b60248201527f4275726e2072656465656d206e6f7420696e697469616c697a6564000000000060448201526064016105d2565b61261882613c13565b6126286060830160408401615703565b81546126459161ffff1690600160a81b900463ffffffff16615727565b63ffffffff16156126895760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b6126938183613e06565b6126a58161232a610100850185615343565b610c9981612df4565b60006121eb836001600160a01b0384166145de565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061271f8585613255565b6001810154909150600160601b90046001600160a01b0316158015612745575086518251145b8015612755575061275588612375565b6127915760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b80546000906127c69063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b9091041687613380565b90508063ffffffff166000036128145760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b6000885167ffffffffffffffff81111561283057612830614fc2565b604051908082528060200260200182016040528015612859578160200160208202803683370190505b50905060005b8451811015612b2b57600085828151811061287c5761287c615118565b60200260200101519050600085600301826000015165ffffffffffff16815481106128a9576128a9615118565b9060005260206000209060020201600101826020015165ffffffffffff16815481106128d7576128d7615118565b600091825260209091206040805161010081019091526004909202018054829060ff16600381111561290b5761290b614abc565b600381111561291c5761291c614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561295457612954614abc565b600281111561296557612965614abc565b81528154602090910190600160b01b900460ff16600281111561298a5761298a614abc565b600281111561299b5761299b614abc565b81528154600160b81b90046001600160481b0316602082015260018201546040820152600282015460608201526003909101546080909101528c519091508c90849081106129eb576129eb615118565b6020026020010151826060015114612a355760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b2103a37b5b2b760991b60448201526064016105d2565b8a8381518110612a4757612a47615118565b60200260200101518863ffffffff168260800151612a65919061574a565b6001600160481b031614612aac5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b8763ffffffff168563ffffffff1614612b21578463ffffffff168160800151612ad5919061574a565b6001600160481b03168b8481518110612af057612af0615118565b6020026020010151612b02919061538d565b848481518110612b1457612b14615118565b6020026020010181815250505b505060010161285f565b50612b3e83858463ffffffff16306142dd565b612b4b8787858d86612bc6565b8463ffffffff168263ffffffff1614612bba57604051631759616b60e11b81523390632eb2c2d690612b879030908e908e90879060040161576d565b600060405180830381600087803b158015612ba157600080fd5b505af1158015612bb5573d6000803e3d6000fd5b505050505b50505050505050505050565b604080516001808252818301909252600091602080830190803683370190505090508281600081518110612bfc57612bfc615118565b6001600160a01b0392909216602092830291909101909101526040805160018082528183019092526000918160200160208202803683375050506001600160a01b03881660009081526006602090815260408083208a8452909152812054825192935091839190612c6f57612c6f615118565b6020908102919091010152604080516001808252818301909252600091816020016020820280368337019050508654909150612cb7908590600160c81b900461ffff166155aa565b63ffffffff1681600081518110612cd057612cd0615118565b60209081029190910101526040516339b2213760e21b81526001600160a01b0389169063e6c884dc90612d0b908690869086906004016157c8565b600060405180830381600087803b158015612d2557600080fd5b505af1158015612d39573d6000803e3d6000fd5b5050505080600081518110612d5057612d50615118565b60200260200101518660000160158282829054906101000a900463ffffffff16612d7a9190615801565b92506101000a81548163ffffffff021916908363ffffffff16021790555081600081518110612dab57612dab615118565b602002602001015187896001600160a01b03167fe728850e46a56a3fba2c081f2fd18bf58c36ed66ee183389e92b075910f2da0960405160405180910390a45050505050505050565b8054600160d81b900463ffffffff1615801590612e275750805463ffffffff600160d81b82048116600160a81b90920416115b1561073c57805463ffffffff60d81b198116600160a81b90910463ffffffff16600160d81b02179055565b6000612e5e8686613255565b6001810154909150600160601b90046001600160a01b0316158015612e87575060038101546001145b8015612eba575080600301600081548110612ea457612ea4615118565b9060005260206000209060020201600001546001145b8015612eca5750612eca89612375565b612f065760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8054600090612f3b9063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b9091041688613380565b90508063ffffffff16600003612f895760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b600082600301600081548110612fa157612fa1615118565b90600052602060002090600202016001018581548110612fc357612fc3615118565b600091825260209091206040805161010081019091526004909202018054829060ff166003811115612ff757612ff7614abc565b600381111561300857613008614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561304057613040614abc565b600281111561305157613051614abc565b81528154602090910190600160b01b900460ff16600281111561307657613076614abc565b600281111561308757613087614abc565b81528154600160b81b90046001600160481b0316602082015260018201546040820152600282015460608201526003909101546080918201528101519091506130d79063ffffffff88169061574a565b6001600160481b0316891461311e5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b61312a81338c876133da565b61313d8130338d8663ffffffff166135cc565b61314a8888858e86612bc6565b8563ffffffff168263ffffffff16146121c057336001600160a01b031663f242432a308d8d8560800151878c613180919061581e565b63ffffffff16613190919061574a565b6040516001600160e01b031960e087901b1681526001600160a01b03948516600482015293909216602484015260448301526001600160481b0316606482015260a06084820152600060a482015260c401600060405180830381600087803b1580156131fb57600080fd5b505af115801561320f573d6000803e3d6000fd5b505050505050505050505050505050565b60006001600160e01b03198216632a9f3abf60e11b148061052157506301ffc9a760e01b6001600160e01b0319831614610521565b6001600160a01b03821660009081526004602090815260408083208484529091528120908154600160a01b900460ff16600381111561329657613296614abc565b036132e35760405162461bcd60e51b815260206004820152601b60248201527f4275726e2072656465656d206e6f7420696e697469616c697a6564000000000060448201526064016105d2565b60018101544265ffffffffffff90911611801590613334575060018101546601000000000000900465ffffffffffff16421080613334575060018101546601000000000000900465ffffffffffff16155b6105215760405162461bcd60e51b815260206004820152601660248201527f4275726e2072656465656d206e6f74206163746976650000000000000000000060448201526064016105d2565b60008463ffffffff166000036133975750806133d2565b6000836133a4868861581e565b6133ae919061583b565b90508263ffffffff168163ffffffff1611156133cc578291506133d0565b8091505b505b949350505050565b83602001516001600160a01b0316836001600160a01b03161461343f5760405162461bcd60e51b815260206004820152601260248201527f496e76616c6964206275726e20746f6b656e000000000000000000000000000060448201526064016105d2565b60018451600381111561345457613454614abc565b14610c995760028451600381111561346e5761346e614abc565b036134dc578360a00151821015801561348b57508360c001518211155b6134d75760405162461bcd60e51b815260206004820152601060248201527f496e76616c696420746f6b656e2049440000000000000000000000000000000060448201526064016105d2565b610c99565b6003845160038111156134f1576134f1614abc565b036135845760008260405160200161350b91815260200190565b604051602081830303815290604052805190602001209050613532828660e001518361462d565b61357e5760405162461bcd60e51b815260206004820152601460248201527f496e76616c6964206d65726b6c652070726f6f6600000000000000000000000060448201526064016105d2565b50610c99565b60405162461bcd60e51b815260206004820152601160248201527f496e76616c6964206275726e206974656d00000000000000000000000000000060448201526064016105d2565b6002856040015160028111156135e4576135e4614abc565b036138595760008186608001516001600160481b031661360491906156df565b905060008660600151600281111561361e5761361e614abc565b036136a857604051637921219560e11b81526001600160a01b03868116600483015261dead6024830152604482018590526064820183905260a06084830152600060a483015285169063f242432a9060c4015b600060405180830381600087803b15801561368b57600080fd5b505af115801561369f573d6000803e3d6000fd5b50505050613853565b6001866060015160028111156136c0576136c0614abc565b036137b2576040805160018082528183019092526000916020808301908036833701905050905083816000815181106136fb576136fb615118565b6020908102919091010152604080516001808252818301909252600091816020016020820280368337019050509050828160008151811061373e5761373e615118565b6020908102919091010152604051633db0f8ab60e01b81526001600160a01b03871690633db0f8ab90613779908a908690869060040161585e565b600060405180830381600087803b15801561379357600080fd5b505af11580156137a7573d6000803e3d6000fd5b505050505050613853565b6002866060015160028111156137ca576137ca614abc565b0361380b57604051637a94c56560e11b81526001600160a01b038681166004830152602482018590526044820183905285169063f5298aca90606401613671565b60405162461bcd60e51b815260206004820152601160248201527f496e76616c6964206275726e207370656300000000000000000000000000000060448201526064016105d2565b50613ae8565b60018560400151600281111561387157613871614abc565b03613aa057806001146138c65760405162461bcd60e51b815260206004820152601260248201527f496e76616c6964206275726e20636f756e74000000000000000000000000000060448201526064016105d2565b6000856060015160028111156138de576138de614abc565b0361396157604051635c46a7ef60e11b81526001600160a01b03858116600483015261dead602483015260448201849052608060648301526000608483015284169063b88d4fde9060a4015b600060405180830381600087803b15801561394457600080fd5b505af1158015613958573d6000803e3d6000fd5b50505050613ae8565b60018560600151600281111561397957613979614abc565b148061399a575060028560600151600281111561399857613998614abc565b145b1561380b576001600160a01b0384163014613a73576040516331a9108f60e11b8152600481018390526001600160a01b038086169190851690636352211e90602401602060405180830381865afa1580156139f9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a1d9190615892565b6001600160a01b031614613a735760405162461bcd60e51b815260206004820152601360248201527f53656e646572206973206e6f74206f776e65720000000000000000000000000060448201526064016105d2565b604051630852cd8d60e31b8152600481018390526001600160a01b038416906342966c689060240161392a565b60405162461bcd60e51b815260206004820152601260248201527f496e76616c696420746f6b656e2073706563000000000000000000000000000060448201526064016105d2565b5050505050565b60008181526001830160205260408120548015613bd8576000613b1360018361538d565b8554909150600090613b279060019061538d565b9050818114613b8c576000866000018281548110613b4757613b47615118565b9060005260206000200154905080876000018481548110613b6a57613b6a615118565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613b9d57613b9d6158af565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610521565b6000915050610521565b5092915050565b6000826000018281548110613c0057613c00615118565b9060005260206000200154905092915050565b6000613c2560408301602084016158c5565b6003811115613c3657613c36614abc565b03613c835760405162461bcd60e51b815260206004820152601860248201527f53746f726167652070726f746f636f6c20696e76616c6964000000000000000060448201526064016105d2565b6000613c9260208301836148b2565b6001600160a01b031603613ce85760405162461bcd60e51b815260206004820152601960248201527f5061796d656e742072656365697665722072657175697265640000000000000060448201526064016105d2565b613cf860c0820160a083016158e2565b65ffffffffffff161580613d395750613d1760c0820160a083016158e2565b65ffffffffffff16613d2f60a08301608084016158e2565b65ffffffffffff16105b613d855760405162461bcd60e51b815260206004820152601760248201527f73746172744461746520616674657220656e644461746500000000000000000060448201526064016105d2565b613d956060820160408301615703565b61ffff16613da96080830160608401615328565b613db39190615727565b63ffffffff161561073c5760405162461bcd60e51b815260206004820152601f60248201527f52656d61696e646572206c6566742066726f6d20746f74616c537570706c790060448201526064016105d2565b613e1660a08201608083016158e2565b60018301805465ffffffffffff191665ffffffffffff92909216919091179055613e4660c0820160a083016158e2565b60018301805465ffffffffffff929092166601000000000000026bffffffffffff00000000000019909216919091179055613e876060820160408301615703565b825461ffff91909116600160c81b0261ffff60c81b19909116178255613eb36080820160608301615328565b825463ffffffff91909116600160d81b0263ffffffff60d81b19909116178255613ee360408201602083016158c5565b8254839060ff60a01b1916600160a01b836003811115613f0557613f05614abc565b0217905550613f1760e08201826158fd565b6002840191613f27919083615058565b50613f3860e0820160c083016148b2565b6001830180546001600160a01b0392909216600160601b026bffffffffffffffffffffffff909216919091179055613f7360208201826148b2565b82546001600160a01b0319166001600160a01b03919091161790915550565b613fa06003840160006146bf565b60005b81811015610c99576003840180546001018082556000828152919083908110613fce57613fce615118565b906000526020600020906002020190506000848484818110613ff257613ff2615118565b90506020028101906140049190615944565b35118015614069575083838381811061401f5761401f615118565b90506020028101906140319190615944565b61403f906020810190615964565b905084848481811061405357614053615118565b90506020028101906140659190615944565b3511155b6140a55760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8383838181106140b7576140b7615118565b90506020028101906140c99190615944565b35815560005b8484848181106140e1576140e1615118565b90506020028101906140f39190615944565b614101906020810190615964565b90508110156142ad57600085858581811061411e5761411e615118565b90506020028101906141309190615944565b61413e906020810190615964565b8381811061414e5761414e615118565b9050610100020180360381019061416591906159e6565b905060028160400151600281111561417f5761417f614abc565b1480156141995750600081608001516001600160481b0316115b806141cf57506001816040015160028111156141b7576141b7614abc565b1480156141cf575060808101516001600160481b0316155b80156141ee57506000815160038111156141eb576141eb614abc565b14155b61422a5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8260010186868681811061424057614240615118565b90506020028101906142529190615944565b614260906020810190615964565b8481811061427057614270615118565b8354600181018555600094855260209094206101009091029290920192600402909101905061429f8282615b04565b5050816001019150506140cf565b5050600101613fa3565b600060018211156142cf57660384665653e000610521565b6602738d24e5200092915050565b600384015460009067ffffffffffffffff8111156142fd576142fd614fc2565b604051908082528060200260200182016040528015614326578160200160208202803683370190505b50905060005b845181101561452857600085828151811061434957614349615118565b60200260200101519050600087600301826000015165ffffffffffff168154811061437657614376615118565b9060005260206000209060020201600101826020015165ffffffffffff16815481106143a4576143a4615118565b600091825260209091206040805161010081019091526004909202018054829060ff1660038111156143d8576143d8614abc565b60038111156143e9576143e9614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561442157614421614abc565b600281111561443257614432614abc565b81528154602090910190600160b01b900460ff16600281111561445757614457614abc565b600281111561446857614468614abc565b81526020016000820160179054906101000a90046001600160481b03166001600160481b03166001600160481b03168152602001600182015481526020016002820154815260200160038201548152505090506144d3818360400151846060015185608001516133da565b6144e88186846040015185606001518a6135cc565b8584836000015165ffffffffffff168151811061450757614507615118565b6020026020010181815161451b91906155d2565b905250505060010161432c565b5060005b81518110156145d6578386600301828154811061454b5761454b615118565b90600052602060002090600202016000015461456791906156df565b82828151811061457957614579615118565b6020026020010151146145ce5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206e756d626572206f6620746f6b656e73000000000000000060448201526064016105d2565b60010161452c565b505050505050565b600081815260018301602052604081205461462557508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610521565b506000610521565b60008261463a8584614643565b14949350505050565b600081815b8451811015614688576146748286838151811061466757614667615118565b6020026020010151614690565b91508061468081615144565b915050614648565b509392505050565b60008183106146ac5760008281526020849052604090206121eb565b60008381526020839052604090206121eb565b508054600082556002029060005260206000209081019061073c91905b808211156107ea5760008082556146f660018301826146ff565b506002016146dc565b508054600082556004029060005260206000209081019061073c91905b808211156107ea5760008082556001820181905560028201819055600382015560040161471c565b60006020828403121561475657600080fd5b81356001600160e01b0319811681146121eb57600080fd5b6001600160a01b038116811461073c57600080fd5b803561478e8161476e565b919050565b6004811061073c57600080fd5b60008083601f8401126147b257600080fd5b50813567ffffffffffffffff8111156147ca57600080fd5b6020830191508360208285010111156147e257600080fd5b9250929050565b60008060008060006080868803121561480157600080fd5b853561480c8161476e565b945060208601359350604086013561482381614793565b9250606086013567ffffffffffffffff81111561483f57600080fd5b61484b888289016147a0565b969995985093965092949392505050565b60008060008060006080868803121561487457600080fd5b853561487f8161476e565b9450602086013561488f8161476e565b935060408601359250606086013567ffffffffffffffff81111561483f57600080fd5b6000602082840312156148c457600080fd5b81356121eb8161476e565b600081518084526020808501945080840160005b838110156149085781516001600160a01b0316875295820195908201906001016148e3565b509495945050505050565b6020815260006121eb60208301846148cf565b60008060006060848603121561493b57600080fd5b83356149468161476e565b925060208401359150604084013567ffffffffffffffff81111561496957600080fd5b8401610120818703121561497c57600080fd5b809150509250925092565b60008083601f84011261499957600080fd5b50813567ffffffffffffffff8111156149b157600080fd5b6020830191508360208260051b85010111156147e257600080fd5b6000806000806000806000806080898b0312156149e857600080fd5b883567ffffffffffffffff80821115614a0057600080fd5b614a0c8c838d01614987565b909a50985060208b0135915080821115614a2557600080fd5b614a318c838d01614987565b909850965060408b0135915080821115614a4a57600080fd5b614a568c838d01614987565b909650945060608b0135915080821115614a6f57600080fd5b50614a7c8b828c01614987565b999c989b5096995094979396929594505050565b60008060408385031215614aa357600080fd5b8235614aae8161476e565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6004811061073c5761073c614abc565b614aeb81614ad2565b9052565b60005b83811015614b0a578181015183820152602001614af2565b50506000910152565b60008151808452614b2b816020860160208601614aef565b601f01601f19169290920160200192915050565b6003811061073c5761073c614abc565b600081518084526020808501808196508360051b810191508286016000805b86811015614c46578385038a52825180518652860151604087870181905281518188018190529188019160609081890190865b81811015614c2f5785518051614bb681614ad2565b8452808d01516001600160a01b03168d85015285810151614bd681614b3f565b8487015280850151614be781614b3f565b848601526080818101516001600160481b03169085015260a0808201519085015260c0808201519085015260e09081015190840152948b019461010090920191600101614ba1565b50509c89019c975050509286019250600101614b6e565b509298975050505050505050565b60208152614c6e6020820183516001600160a01b03169052565b60006020830151614c826040840182614ae2565b50604083015163ffffffff8116606084015250606083015161ffff8116608084015250608083015163ffffffff811660a08401525060a083015165ffffffffffff811660c08401525060c083015165ffffffffffff811660e08401525060e0830151610100614cfb818501836001600160a01b03169052565b808501519150506101406101208181860152614d1b610160860184614b13565b90860151858203601f190183870152909250614d378382614b4f565b9695505050505050565b60008060008060008060008060a0898b031215614d5d57600080fd5b8835614d688161476e565b97506020890135614d788161476e565b9650604089013567ffffffffffffffff80821115614d9557600080fd5b614da18c838d01614987565b909850965060608b0135915080821115614dba57600080fd5b614dc68c838d01614987565b909650945060808b0135915080821115614ddf57600080fd5b50614a7c8b828c016147a0565b60008060008060008060808789031215614e0557600080fd5b8635614e108161476e565b955060208701359450604087013567ffffffffffffffff80821115614e3457600080fd5b614e408a838b01614987565b90965094506060890135915080821115614e5957600080fd5b50614e6689828a01614987565b979a9699509497509295939492505050565b803563ffffffff8116811461478e57600080fd5b600080600080600060808688031215614ea457600080fd5b8535614eaf8161476e565b945060208601359350614ec460408701614e78565b9250606086013567ffffffffffffffff811115614ee057600080fd5b61484b88828901614987565b6020815260006121eb6020830184614b13565b600080600060608486031215614f1457600080fd5b8335614f1f8161476e565b925060208401359150604084013561497c8161476e565b60008060008060008060a08789031215614f4f57600080fd5b8635614f5a8161476e565b95506020870135614f6a8161476e565b94506040870135935060608701359250608087013567ffffffffffffffff811115614f9457600080fd5b614e6689828a016147a0565b600060208284031215614fb257600080fd5b815180151581146121eb57600080fd5b634e487b7160e01b600052604160045260246000fd5b600181811c90821680614fec57607f821691505b60208210810361500c57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115611d6657600081815260208120601f850160051c810160208610156150395750805b601f850160051c820191505b818110156145d657828155600101615045565b67ffffffffffffffff83111561507057615070614fc2565b6150848361507e8354614fd8565b83615012565b6000601f8411600181146150b857600085156150a05750838201355b600019600387901b1c1916600186901b178355613ae8565b600083815260209020601f19861690835b828110156150e957868501358255602094850194600190920191016150c9565b50868210156151065760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016151565761515661512e565b5060010190565b600081518084526020808501945080840160005b8381101561490857815187529582019590820190600101615171565b6060815260006151a060608301866148cf565b6020838203818501526151b3828761515d565b915083820360408501528185518084528284019150828160051b85010183880160005b8381101561520457601f198784030185526151f2838351614b13565b948601949250908501906001016151d6565b50909a9950505050505050505050565b60405160a0810167ffffffffffffffff8111828210171561523757615237614fc2565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561526657615266614fc2565b604052919050565b600067ffffffffffffffff82111561528857615288614fc2565b5060051b60200190565b600060208083850312156152a557600080fd5b825167ffffffffffffffff8111156152bc57600080fd5b8301601f810185136152cd57600080fd5b80516152e06152db8261526e565b61523d565b81815260059190911b820183019083810190878311156152ff57600080fd5b928401925b8284101561531d57835182529284019290840190615304565b979650505050505050565b60006020828403121561533a57600080fd5b6121eb82614e78565b6000808335601e1984360301811261535a57600080fd5b83018035915067ffffffffffffffff82111561537557600080fd5b6020019150600581901b36038213156147e257600080fd5b818103818111156105215761052161512e565b634e487b7160e01b600052601260045260246000fd5b6000826153c5576153c56153a0565b500690565b803565ffffffffffff8116811461478e57600080fd5b600082601f8301126153f157600080fd5b813560206154016152db8361526e565b82815260059290921b8401810191818101908684111561542057600080fd5b8286015b8481101561543b5780358352918301918301615424565b509695505050505050565b60006154546152db8461526e565b8381529050602080820190600585901b84018681111561547357600080fd5b845b8181101561552157803567ffffffffffffffff808211156154965760008081fd5b9087019060a0828b0312156154ab5760008081fd5b6154b3615214565b6154bc836153ca565b81526154c98684016153ca565b868201526040808401356154dc8161476e565b9082015260608381013590820152608080840135838111156154fe5760008081fd5b61550a8d8287016153e0565b918301919091525086525050928201928201615475565b505050509392505050565b6000806000806080858703121561554257600080fd5b843561554d8161476e565b93506020850135925061556260408601614e78565b9150606085013567ffffffffffffffff81111561557e57600080fd5b8501601f8101871361558f57600080fd5b61559e87823560208401615446565b91505092959194509250565b63ffffffff8181168382160280821691908281146155ca576155ca61512e565b505092915050565b808201808211156105215761052161512e565b600083516155f7818460208801614aef565b83519083019061560b818360208801614aef565b01949350505050565b600080600080600060a0868803121561562c57600080fd5b85356156378161476e565b94506020860135935061564c60408701614e78565b925060608601359150608086013567ffffffffffffffff81111561566f57600080fd5b61567b888289016153e0565b9150509295509295909350565b6000806000806080858703121561569e57600080fd5b84356156a98161476e565b93506020850135925060408501359150606085013567ffffffffffffffff8111156156d357600080fd5b61559e878288016153e0565b80820281158282048414176105215761052161512e565b60006121eb368484615446565b60006020828403121561571557600080fd5b813561ffff811681146121eb57600080fd5b600063ffffffff8084168061573e5761573e6153a0565b92169190910692915050565b6001600160481b038181168382160280821691908281146155ca576155ca61512e565b60006001600160a01b03808716835280861660208401525060a0604083015261579960a083018561515d565b82810360608401526157ab818561515d565b838103608090940193909352505060008152602001949350505050565b6060815260006157db60608301866148cf565b82810360208401526157ed818661515d565b90508281036040840152614d37818561515d565b63ffffffff818116838216019080821115613be257613be261512e565b63ffffffff828116828216039080821115613be257613be261512e565b600063ffffffff80841680615852576158526153a0565b92169190910492915050565b6001600160a01b0384168152606060208201526000615880606083018561515d565b8281036040840152614d37818561515d565b6000602082840312156158a457600080fd5b81516121eb8161476e565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156158d757600080fd5b81356121eb81614793565b6000602082840312156158f457600080fd5b6121eb826153ca565b6000808335601e1984360301811261591457600080fd5b83018035915067ffffffffffffffff82111561592f57600080fd5b6020019150368190038213156147e257600080fd5b60008235603e1983360301811261595a57600080fd5b9190910192915050565b6000808335601e1984360301811261597b57600080fd5b83018035915067ffffffffffffffff82111561599657600080fd5b6020019150600881901b36038213156147e257600080fd5b6003811061073c57600080fd5b803561478e816159ae565b6001600160481b038116811461073c57600080fd5b803561478e816159c6565b60006101008083850312156159fa57600080fd5b6040519081019067ffffffffffffffff82118183101715615a1d57615a1d614fc2565b8160405283359150615a2e82614793565b818152615a3d60208501614783565b6020820152615a4e604085016159bb565b6040820152615a5f606085016159bb565b6060820152615a70608085016159db565b608082015260a084013560a082015260c084013560c082015260e084013560e0820152809250505092915050565b60008135610521816159ae565b615ab482614b3f565b805460ff60a81b191660a89290921b60ff60a81b16919091179055565b615ada82614b3f565b805460ff60b01b191660b09290921b60ff60b01b16919091179055565b60008135610521816159c6565b8135615b0f81614793565b615b1881614ad2565b815460ff821691508160ff1982161783556020840135615b378161476e565b74ffffffffffffffffffffffffffffffffffffffff008160081b16836affffffffffffffffffffff60a81b841617178455505050615b80615b7a60408401615a9e565b82615aab565b615b95615b8f60608401615a9e565b82615ad1565b615be8615ba460808401615af7565b82805476ffffffffffffffffffffffffffffffffffffffffffffff1660b89290921b76ffffffffffffffffffffffffffffffffffffffffffffff1916919091179055565b60a0820135600182015560c0820135600282015560e08201356003820155505056fea2646970667358221220adffae1746ea7108eb08998f045791bb46645ee4bf987fcbe6da5c8e80170c0864736f6c63430008110033

Deployed Bytecode

0x6080604052600436106101965760003560e01c8063715018a6116100e1578063c2065c101161008a578063f0e9fcd111610064578063f0e9fcd11461047c578063f23a6e611461049c578063f2fde38b146104bc578063f3fef3a3146104dc57600080fd5b8063c2065c101461041c578063c9dad6961461043c578063e9dc63751461044f57600080fd5b806395bc312b116100bb57806395bc312b146103b4578063b058d2f8146103cf578063bc197c81146103fc57600080fd5b8063715018a6146103615780637ab39392146103765780638da5cb5b1461039657600080fd5b806338ec89951161014357806350d108391161011d57806350d10839146102e9578063625888da146103215780636d73e6691461034157600080fd5b806338ec89951461028d57806342b54fee146102ad578063480df058146102c057600080fd5b806324d7806c1161017457806324d7806c1461022b5780632d3456701461024b57806331ae450b1461026b57600080fd5b806301ffc9a71461019b57806304ea1e90146101d0578063150b7a02146101f2575b600080fd5b3480156101a757600080fd5b506101bb6101b6366004614744565b6104fc565b60405190151581526020015b60405180910390f35b3480156101dc57600080fd5b506101f06101eb3660046147e9565b610527565b005b3480156101fe57600080fd5b5061021261020d36600461485c565b61062c565b6040516001600160e01b031990911681526020016101c7565b34801561023757600080fd5b506101bb6102463660046148b2565b6106a8565b34801561025757600080fd5b506101f06102663660046148b2565b6106e1565b34801561027757600080fd5b5061028061073f565b6040516101c79190614913565b34801561029957600080fd5b506101f06102a8366004614926565b6107ee565b6101f06102bb3660046149cc565b610a4a565b3480156102cc57600080fd5b506102db6602738d24e5200081565b6040519081526020016101c7565b3480156102f557600080fd5b50600554610309906001600160a01b031681565b6040516001600160a01b0390911681526020016101c7565b34801561032d57600080fd5b506101f061033c366004614926565b610bdf565b34801561034d57600080fd5b506101f061035c3660046148b2565b610c9f565b34801561036d57600080fd5b506101f0610cf7565b34801561038257600080fd5b506101f06103913660046148b2565b610d0b565b3480156103a257600080fd5b506000546001600160a01b0316610309565b3480156103c057600080fd5b506102db660384665653e00081565b3480156103db57600080fd5b506103ef6103ea366004614a90565b610db3565b6040516101c79190614c54565b34801561040857600080fd5b50610212610417366004614d41565b61112d565b34801561042857600080fd5b506101f0610437366004614dec565b611292565b6101f061044a366004614e8c565b6114d1565b34801561045b57600080fd5b5061046f61046a366004614a90565b61156d565b6040516101c79190614eec565b34801561048857600080fd5b506101f0610497366004614eff565b6119e8565b3480156104a857600080fd5b506102126104b7366004614f36565b611adb565b3480156104c857600080fd5b506101f06104d73660046148b2565b611bc7565b3480156104e857600080fd5b506101f06104f7366004614a90565b611c3d565b60006001600160e01b03198216635e5e1fdf60e01b1480610521575061052182611d6b565b92915050565b604051630935e01b60e21b815233600482015285906001600160a01b038216906324d7806c90602401602060405180830381865afa15801561056d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105919190614fa0565b6105db5760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064015b60405180910390fd5b60006105e78787611de1565b80549091508590829060ff60a01b1916600160a01b83600381111561060e5761060e614abc565b021790555060028101610622848683615058565b5050505050505050565b60006002600354036106805760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b600260035561069185858585611e6f565b50630a85bd0160e11b600160035595945050505050565b6000816001600160a01b03166106c66000546001600160a01b031690565b6001600160a01b0316148061052157506105216001836121cd565b6106e96121f2565b6106f46001826121cd565b1561073c5760405133906001600160a01b038316907f7c0c3c84c67c85fcac635147348bfe374c24a1a93d0366d1cfe9d8853cbf89d590600090a361073a60018261224c565b505b50565b606061074b6001612261565b67ffffffffffffffff81111561076357610763614fc2565b60405190808252806020026020018201604052801561078c578160200160208202803683370190505b50905060005b61079c6001612261565b8110156107ea576107ae60018261226b565b8282815181106107c0576107c0615118565b6001600160a01b0390921660209283029190910190910152806107e281615144565b915050610792565b5090565b604051630935e01b60e21b815233600482015283906001600160a01b038216906324d7806c90602401602060405180830381865afa158015610834573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108589190614fa0565b61089d5760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064016105d2565b6108a8848484612277565b6040805160018082528183019092526000916020808301908036833701905050905033816000815181106108de576108de615118565b6001600160a01b039290921660209283029190910190910152604080516001808252818301909252600091816020015b606081526020019060019003908161090e57505060408051600180825281830190925291925060009190602080830190803683375050604051634637423960e11b81529192506000916001600160a01b038a169150638c6e84729061097b9087908690889060040161518d565b6000604051808303816000875af115801561099a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526109c29190810190615292565b9050806000815181106109d7576109d7615118565b6020908102919091018101516001600160a01b038a1660008181526006845260408082208c835285528082209390935590815260079092528120825189929084908290610a2657610a26615118565b60200260200101518152602001908152602001600020819055505050505050505050565b600260035403610a9c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b60026003558685148015610aaf57508683145b8015610aba57508681145b610af95760405162461bcd60e51b815260206004820152601060248201526f496e76616c69642063616c6c6461746160801b60448201526064016105d2565b6000610b0433612375565b90503460005b89811015610bbd57610ba9828c8c84818110610b2857610b28615118565b9050602002016020810190610b3d91906148b2565b8b8b85818110610b4f57610b4f615118565b905060200201358a8a86818110610b6857610b68615118565b9050602002016020810190610b7d9190615328565b898987818110610b8f57610b8f615118565b9050602002810190610ba19190615343565b8960006123fb565b610bb3908361538d565b9150600101610b0a565b508015610bce57610bce3382611cc3565b505060016003555050505050505050565b604051630935e01b60e21b815233600482015283906001600160a01b038216906324d7806c90602401602060405180830381865afa158015610c25573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c499190614fa0565b610c8e5760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064016105d2565b610c99848484612595565b50505050565b610ca76121f2565b610cb26001826121cd565b61073c5760405133906001600160a01b038316907f7e1a1a08d52e4ba0e21554733d66165fd5151f99460116223d9e3a608eec5cb190600090a361073a6001826126ae565b610cff6121f2565b610d0960006126c3565b565b33610d1e6000546001600160a01b031690565b6001600160a01b03161480610d395750610d396001336121cd565b610d915760405162461bcd60e51b8152602060048201526024808201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616044820152633236b4b760e11b60648201526084016105d2565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b604080516101408101825260008082526020820181905291810182905260608082018390526080820183905260a0820183905260c0820183905260e08201929092526101008101829052610120810191909152610e108383611de1565b60408051610140810190915281546001600160a01b03811682529091906020830190600160a01b900460ff166003811115610e4d57610e4d614abc565b6003811115610e5e57610e5e614abc565b8152815463ffffffff600160a81b82048116602084015261ffff600160c81b8304166040840152600160d81b909104166060820152600182015465ffffffffffff8082166080840152660100000000000082041660a08301526001600160a01b03600160601b9091041660c082015260028201805460e090920191610ee290614fd8565b80601f0160208091040260200160405190810160405280929190818152602001828054610f0e90614fd8565b8015610f5b5780601f10610f3057610100808354040283529160200191610f5b565b820191906000526020600020905b815481529060010190602001808311610f3e57829003601f168201915b5050505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b8282101561111e57838290600052602060002090600202016040518060400160405290816000820154815260200160018201805480602002602001604051908101604052809291908181526020016000905b8282101561110757600084815260209020604080516101008101909152600484029091018054829060ff16600381111561101757611017614abc565b600381111561102857611028614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561106057611060614abc565b600281111561107157611071614abc565b81528154602090910190600160b01b900460ff16600281111561109657611096614abc565b60028111156110a7576110a7614abc565b81526020016000820160179054906101000a90046001600160481b03166001600160481b03166001600160481b03168152602001600182015481526020016002820154815260200160038201548152505081526020019060010190610fdb565b505050508152505081526020019060010190610f89565b50505091525090949350505050565b60006002600354036111815760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b60026003556111916020836153b6565b156111cd5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206461746160a01b60448201526064016105d2565b6000808060606111df8688018861552c565b809450819550829650839750505050506112748c8c8c80806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050508b8b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508a925089915088905087612713565b505060016003555063bc197c8160e01b9a9950505050505050505050565b604051630935e01b60e21b815233600482015286906001600160a01b038216906324d7806c90602401602060405180830381865afa1580156112d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fc9190614fa0565b6113415760405162461bcd60e51b81526020600482015260166024820152752bb0b63632ba1034b9903737ba1030b71030b236b4b760511b60448201526064016105d2565b8382146113835760405162461bcd60e51b815260206004820152601060248201526f496e76616c69642063616c6c6461746160801b60448201526064016105d2565b600061138f8888611de1565b90506000805b848110156113f5578254600160c81b900461ffff168686838181106113bc576113bc615118565b90506020020160208101906113d19190615328565b6113db91906155aa565b6113eb9063ffffffff16836155d2565b9150600101611395565b50815463ffffffff9061141190600160a81b90048216836155d2565b11156114505760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b60005b868110156114bc576114b48a8a858b8b8681811061147357611473615118565b905060200201602081019061148891906148b2565b8a8a8781811061149a5761149a615118565b90506020020160208101906114af9190615328565b612bc6565b600101611453565b506114c682612df4565b505050505050505050565b6002600354036115235760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b6002600355600061154334878787878761153c33612375565b60016123fb565b905080341115611560576115603361155b833461538d565b611cc3565b5050600160035550505050565b6001600160a01b0382166000908152600760209081526040808320848452909152902054606090806115e15760405162461bcd60e51b815260206004820152601460248201527f546f6b656e20646f6573206e6f7420657869737400000000000000000000000060448201526064016105d2565b6001600160a01b038481166000908152600460209081526040808320858452825280832081516101408101909252805494851682529293909291830190600160a01b900460ff16600381111561163957611639614abc565b600381111561164a5761164a614abc565b8152815463ffffffff600160a81b82048116602084015261ffff600160c81b8304166040840152600160d81b909104166060820152600182015465ffffffffffff8082166080840152660100000000000082041660a08301526001600160a01b03600160601b9091041660c082015260028201805460e0909201916116ce90614fd8565b80601f01602080910402602001604051908101604052809291908181526020018280546116fa90614fd8565b80156117475780601f1061171c57610100808354040283529160200191611747565b820191906000526020600020905b81548152906001019060200180831161172a57829003601f168201915b5050505050815260200160038201805480602002602001604051908101604052809291908181526020016000905b8282101561190a57838290600052602060002090600202016040518060400160405290816000820154815260200160018201805480602002602001604051908101604052809291908181526020016000905b828210156118f357600084815260209020604080516101008101909152600484029091018054829060ff16600381111561180357611803614abc565b600381111561181457611814614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561184c5761184c614abc565b600281111561185d5761185d614abc565b81528154602090910190600160b01b900460ff16600281111561188257611882614abc565b600281111561189357611893614abc565b81526020016000820160179054906101000a90046001600160481b03166001600160481b03166001600160481b031681526020016001820154815260200160028201548152602001600382015481525050815260200190600101906117c7565b505050508152505081526020019060010190611775565b5050509152505060408051602081019091526000815290915060028260200151600381111561193b5761193b614abc565b0361197a575060408051808201909152601481527f68747470733a2f2f617277656176652e6e65742f00000000000000000000000060208201526119b7565b60038260200151600381111561199257611992614abc565b036119b75750604080518082019091526007815266697066733a2f2f60c81b60208201525b6101008201516040516119ce9183916020016155e5565b604051602081830303815290604052935050505092915050565b336119fb6000546001600160a01b031690565b6001600160a01b03161480611a165750611a166001336121cd565b611a6e5760405162461bcd60e51b8152602060048201526024808201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616044820152633236b4b760e11b60648201526084016105d2565b6040516323b872dd60e01b81523060048201526001600160a01b038281166024830152604482018490528416906323b872dd90606401600060405180830381600087803b158015611abe57600080fd5b505af1158015611ad2573d6000803e3d6000fd5b50505050505050565b6000600260035403611b2f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105d2565b6002600355611b3f6020836153b6565b15611b7b5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206461746160a01b60448201526064016105d2565b60008080806060611b8e87890189615614565b939850919650945092509050611baa8b8b8b8888888888612e52565b505060016003555063f23a6e6160e01b9998505050505050505050565b611bcf6121f2565b6001600160a01b038116611c345760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105d2565b61073c816126c3565b33611c506000546001600160a01b031690565b6001600160a01b03161480611c6b5750611c6b6001336121cd565b611cc35760405162461bcd60e51b8152602060048201526024808201527f41646d696e436f6e74726f6c3a204d757374206265206f776e6572206f7220616044820152633236b4b760e11b60648201526084016105d2565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611d10576040519150601f19603f3d011682016040523d82523d6000602084013e611d15565b606091505b5050905080611d665760405162461bcd60e51b815260206004820152601f60248201527f4661696c656420746f207472616e7366657220746f20726563697069656e740060448201526064016105d2565b505050565b60006001600160e01b0319821663080958b760e41b1480611d9c57506001600160e01b03198216630a85bd0160e11b145b80611db757506001600160e01b03198216630271189760e51b145b80611dd257506001600160e01b0319821663e9dc637560e01b145b80610521575061052182613220565b6001600160a01b03821660009081526004602090815260408083208484529091528120908154600160a01b900460ff166003811115611e2257611e22614abc565b036105215760405162461bcd60e51b815260206004820152601b60248201527f4275726e2072656465656d206e6f7420696e697469616c697a6564000000000060448201526064016105d2565b611e7a6020826153b6565b15611eb65760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206461746160a01b60448201526064016105d2565b600080806060611ec885870187615688565b929650909450925090506000611ede8585613255565b6001810154909150600160601b90046001600160a01b0316158015611f07575060038101546001145b8015611f3a575080600301600081548110611f2457611f24615118565b9060005260206000209060020201600001546001145b8015611f4a5750611f4a89612375565b611f865760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8054600090611fbc9063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b909104166001613380565b63ffffffff1690508060000361200a5760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b60008260030160008154811061202257612022615118565b9060005260206000209060020201600101858154811061204457612044615118565b600091825260209091206040805161010081019091526004909202018054829060ff16600381111561207857612078614abc565b600381111561208957612089614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff1660028111156120c1576120c1614abc565b60028111156120d2576120d2614abc565b81528154602090910190600160b01b900460ff1660028111156120f7576120f7614abc565b600281111561210857612108614abc565b81528154600160b81b90046001600160481b031660208201526001808301546040830152600283015460608301526003909201546080909101529091508160400151600281111561215b5761215b614abc565b146121985760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b6121a481338c876133da565b6121b28130338d60016135cc565b6121c08787858e6001612bc6565b5050505050505050505050565b6001600160a01b038116600090815260018301602052604081205415155b9392505050565b6000546001600160a01b03163314610d095760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105d2565b60006121eb836001600160a01b038416613aef565b6000610521825490565b60006121eb8383613be9565b6001600160a01b03831660009081526004602090815260408083208584529091528120908154600160a01b900460ff1660038111156122b8576122b8614abc565b146123055760405162461bcd60e51b815260206004820152601f60248201527f4275726e2072656465656d20616c726561647920696e697469616c697a65640060448201526064016105d2565b61230e82613c13565b6123188183613e06565b61232f8161232a610100850185615343565b613f92565b60405133815283906001600160a01b038616907ff4d614881eb59d4bcd5ea596b177a55b560306371604a9490ca2a5c2f24df14d9060200160405180910390a350505050565b6005546000906001600160a01b03161580159061052157506005546040516345ecd02f60e01b81526001600160a01b038481166004830152909116906345ecd02f90602401602060405180830381865afa1580156123d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105219190614fa0565b6000806124088989613255565b805490915061243d9063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b909104168a613380565b96508663ffffffff1660000361249b5782156124915760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b6000915050612589565b6001810154600160601b90046001600160a01b031680856124cc576124bf876142b7565b6124c990836155d2565b91505b60018963ffffffff161115612500576124eb63ffffffff8a16836156df565b91506124fd63ffffffff8a16826156df565b90505b818c10156125415760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b801561255c57825461255c906001600160a01b031682611cc3565b6125778361256a898b6156f6565b8b63ffffffff16336142dd565b6125848b8b85338d612bc6565b509150505b98975050505050505050565b60006125a18484611de1565b905060008154600160a01b900460ff1660038111156125c2576125c2614abc565b0361260f5760405162461bcd60e51b815260206004820152601b60248201527f4275726e2072656465656d206e6f7420696e697469616c697a6564000000000060448201526064016105d2565b61261882613c13565b6126286060830160408401615703565b81546126459161ffff1690600160a81b900463ffffffff16615727565b63ffffffff16156126895760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b6126938183613e06565b6126a58161232a610100850185615343565b610c9981612df4565b60006121eb836001600160a01b0384166145de565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600061271f8585613255565b6001810154909150600160601b90046001600160a01b0316158015612745575086518251145b8015612755575061275588612375565b6127915760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b80546000906127c69063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b9091041687613380565b90508063ffffffff166000036128145760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b6000885167ffffffffffffffff81111561283057612830614fc2565b604051908082528060200260200182016040528015612859578160200160208202803683370190505b50905060005b8451811015612b2b57600085828151811061287c5761287c615118565b60200260200101519050600085600301826000015165ffffffffffff16815481106128a9576128a9615118565b9060005260206000209060020201600101826020015165ffffffffffff16815481106128d7576128d7615118565b600091825260209091206040805161010081019091526004909202018054829060ff16600381111561290b5761290b614abc565b600381111561291c5761291c614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561295457612954614abc565b600281111561296557612965614abc565b81528154602090910190600160b01b900460ff16600281111561298a5761298a614abc565b600281111561299b5761299b614abc565b81528154600160b81b90046001600160481b0316602082015260018201546040820152600282015460608201526003909101546080909101528c519091508c90849081106129eb576129eb615118565b6020026020010151826060015114612a355760405162461bcd60e51b815260206004820152600d60248201526c24b73b30b634b2103a37b5b2b760991b60448201526064016105d2565b8a8381518110612a4757612a47615118565b60200260200101518863ffffffff168260800151612a65919061574a565b6001600160481b031614612aac5760405162461bcd60e51b815260206004820152600e60248201526d125b9d985b1a5908185b5bdd5b9d60921b60448201526064016105d2565b8763ffffffff168563ffffffff1614612b21578463ffffffff168160800151612ad5919061574a565b6001600160481b03168b8481518110612af057612af0615118565b6020026020010151612b02919061538d565b848481518110612b1457612b14615118565b6020026020010181815250505b505060010161285f565b50612b3e83858463ffffffff16306142dd565b612b4b8787858d86612bc6565b8463ffffffff168263ffffffff1614612bba57604051631759616b60e11b81523390632eb2c2d690612b879030908e908e90879060040161576d565b600060405180830381600087803b158015612ba157600080fd5b505af1158015612bb5573d6000803e3d6000fd5b505050505b50505050505050505050565b604080516001808252818301909252600091602080830190803683370190505090508281600081518110612bfc57612bfc615118565b6001600160a01b0392909216602092830291909101909101526040805160018082528183019092526000918160200160208202803683375050506001600160a01b03881660009081526006602090815260408083208a8452909152812054825192935091839190612c6f57612c6f615118565b6020908102919091010152604080516001808252818301909252600091816020016020820280368337019050508654909150612cb7908590600160c81b900461ffff166155aa565b63ffffffff1681600081518110612cd057612cd0615118565b60209081029190910101526040516339b2213760e21b81526001600160a01b0389169063e6c884dc90612d0b908690869086906004016157c8565b600060405180830381600087803b158015612d2557600080fd5b505af1158015612d39573d6000803e3d6000fd5b5050505080600081518110612d5057612d50615118565b60200260200101518660000160158282829054906101000a900463ffffffff16612d7a9190615801565b92506101000a81548163ffffffff021916908363ffffffff16021790555081600081518110612dab57612dab615118565b602002602001015187896001600160a01b03167fe728850e46a56a3fba2c081f2fd18bf58c36ed66ee183389e92b075910f2da0960405160405180910390a45050505050505050565b8054600160d81b900463ffffffff1615801590612e275750805463ffffffff600160d81b82048116600160a81b90920416115b1561073c57805463ffffffff60d81b198116600160a81b90910463ffffffff16600160d81b02179055565b6000612e5e8686613255565b6001810154909150600160601b90046001600160a01b0316158015612e87575060038101546001145b8015612eba575080600301600081548110612ea457612ea4615118565b9060005260206000209060020201600001546001145b8015612eca5750612eca89612375565b612f065760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8054600090612f3b9063ffffffff600160d81b8204811691600160a81b81049091169061ffff600160c81b9091041688613380565b90508063ffffffff16600003612f895760405162461bcd60e51b81526020600482015260136024820152724e6f20746f6b656e7320617661696c61626c6560681b60448201526064016105d2565b600082600301600081548110612fa157612fa1615118565b90600052602060002090600202016001018581548110612fc357612fc3615118565b600091825260209091206040805161010081019091526004909202018054829060ff166003811115612ff757612ff7614abc565b600381111561300857613008614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561304057613040614abc565b600281111561305157613051614abc565b81528154602090910190600160b01b900460ff16600281111561307657613076614abc565b600281111561308757613087614abc565b81528154600160b81b90046001600160481b0316602082015260018201546040820152600282015460608201526003909101546080918201528101519091506130d79063ffffffff88169061574a565b6001600160481b0316891461311e5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b61312a81338c876133da565b61313d8130338d8663ffffffff166135cc565b61314a8888858e86612bc6565b8563ffffffff168263ffffffff16146121c057336001600160a01b031663f242432a308d8d8560800151878c613180919061581e565b63ffffffff16613190919061574a565b6040516001600160e01b031960e087901b1681526001600160a01b03948516600482015293909216602484015260448301526001600160481b0316606482015260a06084820152600060a482015260c401600060405180830381600087803b1580156131fb57600080fd5b505af115801561320f573d6000803e3d6000fd5b505050505050505050505050505050565b60006001600160e01b03198216632a9f3abf60e11b148061052157506301ffc9a760e01b6001600160e01b0319831614610521565b6001600160a01b03821660009081526004602090815260408083208484529091528120908154600160a01b900460ff16600381111561329657613296614abc565b036132e35760405162461bcd60e51b815260206004820152601b60248201527f4275726e2072656465656d206e6f7420696e697469616c697a6564000000000060448201526064016105d2565b60018101544265ffffffffffff90911611801590613334575060018101546601000000000000900465ffffffffffff16421080613334575060018101546601000000000000900465ffffffffffff16155b6105215760405162461bcd60e51b815260206004820152601660248201527f4275726e2072656465656d206e6f74206163746976650000000000000000000060448201526064016105d2565b60008463ffffffff166000036133975750806133d2565b6000836133a4868861581e565b6133ae919061583b565b90508263ffffffff168163ffffffff1611156133cc578291506133d0565b8091505b505b949350505050565b83602001516001600160a01b0316836001600160a01b03161461343f5760405162461bcd60e51b815260206004820152601260248201527f496e76616c6964206275726e20746f6b656e000000000000000000000000000060448201526064016105d2565b60018451600381111561345457613454614abc565b14610c995760028451600381111561346e5761346e614abc565b036134dc578360a00151821015801561348b57508360c001518211155b6134d75760405162461bcd60e51b815260206004820152601060248201527f496e76616c696420746f6b656e2049440000000000000000000000000000000060448201526064016105d2565b610c99565b6003845160038111156134f1576134f1614abc565b036135845760008260405160200161350b91815260200190565b604051602081830303815290604052805190602001209050613532828660e001518361462d565b61357e5760405162461bcd60e51b815260206004820152601460248201527f496e76616c6964206d65726b6c652070726f6f6600000000000000000000000060448201526064016105d2565b50610c99565b60405162461bcd60e51b815260206004820152601160248201527f496e76616c6964206275726e206974656d00000000000000000000000000000060448201526064016105d2565b6002856040015160028111156135e4576135e4614abc565b036138595760008186608001516001600160481b031661360491906156df565b905060008660600151600281111561361e5761361e614abc565b036136a857604051637921219560e11b81526001600160a01b03868116600483015261dead6024830152604482018590526064820183905260a06084830152600060a483015285169063f242432a9060c4015b600060405180830381600087803b15801561368b57600080fd5b505af115801561369f573d6000803e3d6000fd5b50505050613853565b6001866060015160028111156136c0576136c0614abc565b036137b2576040805160018082528183019092526000916020808301908036833701905050905083816000815181106136fb576136fb615118565b6020908102919091010152604080516001808252818301909252600091816020016020820280368337019050509050828160008151811061373e5761373e615118565b6020908102919091010152604051633db0f8ab60e01b81526001600160a01b03871690633db0f8ab90613779908a908690869060040161585e565b600060405180830381600087803b15801561379357600080fd5b505af11580156137a7573d6000803e3d6000fd5b505050505050613853565b6002866060015160028111156137ca576137ca614abc565b0361380b57604051637a94c56560e11b81526001600160a01b038681166004830152602482018590526044820183905285169063f5298aca90606401613671565b60405162461bcd60e51b815260206004820152601160248201527f496e76616c6964206275726e207370656300000000000000000000000000000060448201526064016105d2565b50613ae8565b60018560400151600281111561387157613871614abc565b03613aa057806001146138c65760405162461bcd60e51b815260206004820152601260248201527f496e76616c6964206275726e20636f756e74000000000000000000000000000060448201526064016105d2565b6000856060015160028111156138de576138de614abc565b0361396157604051635c46a7ef60e11b81526001600160a01b03858116600483015261dead602483015260448201849052608060648301526000608483015284169063b88d4fde9060a4015b600060405180830381600087803b15801561394457600080fd5b505af1158015613958573d6000803e3d6000fd5b50505050613ae8565b60018560600151600281111561397957613979614abc565b148061399a575060028560600151600281111561399857613998614abc565b145b1561380b576001600160a01b0384163014613a73576040516331a9108f60e11b8152600481018390526001600160a01b038086169190851690636352211e90602401602060405180830381865afa1580156139f9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a1d9190615892565b6001600160a01b031614613a735760405162461bcd60e51b815260206004820152601360248201527f53656e646572206973206e6f74206f776e65720000000000000000000000000060448201526064016105d2565b604051630852cd8d60e31b8152600481018390526001600160a01b038416906342966c689060240161392a565b60405162461bcd60e51b815260206004820152601260248201527f496e76616c696420746f6b656e2073706563000000000000000000000000000060448201526064016105d2565b5050505050565b60008181526001830160205260408120548015613bd8576000613b1360018361538d565b8554909150600090613b279060019061538d565b9050818114613b8c576000866000018281548110613b4757613b47615118565b9060005260206000200154905080876000018481548110613b6a57613b6a615118565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613b9d57613b9d6158af565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610521565b6000915050610521565b5092915050565b6000826000018281548110613c0057613c00615118565b9060005260206000200154905092915050565b6000613c2560408301602084016158c5565b6003811115613c3657613c36614abc565b03613c835760405162461bcd60e51b815260206004820152601860248201527f53746f726167652070726f746f636f6c20696e76616c6964000000000000000060448201526064016105d2565b6000613c9260208301836148b2565b6001600160a01b031603613ce85760405162461bcd60e51b815260206004820152601960248201527f5061796d656e742072656365697665722072657175697265640000000000000060448201526064016105d2565b613cf860c0820160a083016158e2565b65ffffffffffff161580613d395750613d1760c0820160a083016158e2565b65ffffffffffff16613d2f60a08301608084016158e2565b65ffffffffffff16105b613d855760405162461bcd60e51b815260206004820152601760248201527f73746172744461746520616674657220656e644461746500000000000000000060448201526064016105d2565b613d956060820160408301615703565b61ffff16613da96080830160608401615328565b613db39190615727565b63ffffffff161561073c5760405162461bcd60e51b815260206004820152601f60248201527f52656d61696e646572206c6566742066726f6d20746f74616c537570706c790060448201526064016105d2565b613e1660a08201608083016158e2565b60018301805465ffffffffffff191665ffffffffffff92909216919091179055613e4660c0820160a083016158e2565b60018301805465ffffffffffff929092166601000000000000026bffffffffffff00000000000019909216919091179055613e876060820160408301615703565b825461ffff91909116600160c81b0261ffff60c81b19909116178255613eb36080820160608301615328565b825463ffffffff91909116600160d81b0263ffffffff60d81b19909116178255613ee360408201602083016158c5565b8254839060ff60a01b1916600160a01b836003811115613f0557613f05614abc565b0217905550613f1760e08201826158fd565b6002840191613f27919083615058565b50613f3860e0820160c083016148b2565b6001830180546001600160a01b0392909216600160601b026bffffffffffffffffffffffff909216919091179055613f7360208201826148b2565b82546001600160a01b0319166001600160a01b03919091161790915550565b613fa06003840160006146bf565b60005b81811015610c99576003840180546001018082556000828152919083908110613fce57613fce615118565b906000526020600020906002020190506000848484818110613ff257613ff2615118565b90506020028101906140049190615944565b35118015614069575083838381811061401f5761401f615118565b90506020028101906140319190615944565b61403f906020810190615964565b905084848481811061405357614053615118565b90506020028101906140659190615944565b3511155b6140a55760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8383838181106140b7576140b7615118565b90506020028101906140c99190615944565b35815560005b8484848181106140e1576140e1615118565b90506020028101906140f39190615944565b614101906020810190615964565b90508110156142ad57600085858581811061411e5761411e615118565b90506020028101906141309190615944565b61413e906020810190615964565b8381811061414e5761414e615118565b9050610100020180360381019061416591906159e6565b905060028160400151600281111561417f5761417f614abc565b1480156141995750600081608001516001600160481b0316115b806141cf57506001816040015160028111156141b7576141b7614abc565b1480156141cf575060808101516001600160481b0316155b80156141ee57506000815160038111156141eb576141eb614abc565b14155b61422a5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b60448201526064016105d2565b8260010186868681811061424057614240615118565b90506020028101906142529190615944565b614260906020810190615964565b8481811061427057614270615118565b8354600181018555600094855260209094206101009091029290920192600402909101905061429f8282615b04565b5050816001019150506140cf565b5050600101613fa3565b600060018211156142cf57660384665653e000610521565b6602738d24e5200092915050565b600384015460009067ffffffffffffffff8111156142fd576142fd614fc2565b604051908082528060200260200182016040528015614326578160200160208202803683370190505b50905060005b845181101561452857600085828151811061434957614349615118565b60200260200101519050600087600301826000015165ffffffffffff168154811061437657614376615118565b9060005260206000209060020201600101826020015165ffffffffffff16815481106143a4576143a4615118565b600091825260209091206040805161010081019091526004909202018054829060ff1660038111156143d8576143d8614abc565b60038111156143e9576143e9614abc565b8152815461010081046001600160a01b03166020830152604090910190600160a81b900460ff16600281111561442157614421614abc565b600281111561443257614432614abc565b81528154602090910190600160b01b900460ff16600281111561445757614457614abc565b600281111561446857614468614abc565b81526020016000820160179054906101000a90046001600160481b03166001600160481b03166001600160481b03168152602001600182015481526020016002820154815260200160038201548152505090506144d3818360400151846060015185608001516133da565b6144e88186846040015185606001518a6135cc565b8584836000015165ffffffffffff168151811061450757614507615118565b6020026020010181815161451b91906155d2565b905250505060010161432c565b5060005b81518110156145d6578386600301828154811061454b5761454b615118565b90600052602060002090600202016000015461456791906156df565b82828151811061457957614579615118565b6020026020010151146145ce5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206e756d626572206f6620746f6b656e73000000000000000060448201526064016105d2565b60010161452c565b505050505050565b600081815260018301602052604081205461462557508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610521565b506000610521565b60008261463a8584614643565b14949350505050565b600081815b8451811015614688576146748286838151811061466757614667615118565b6020026020010151614690565b91508061468081615144565b915050614648565b509392505050565b60008183106146ac5760008281526020849052604090206121eb565b60008381526020839052604090206121eb565b508054600082556002029060005260206000209081019061073c91905b808211156107ea5760008082556146f660018301826146ff565b506002016146dc565b508054600082556004029060005260206000209081019061073c91905b808211156107ea5760008082556001820181905560028201819055600382015560040161471c565b60006020828403121561475657600080fd5b81356001600160e01b0319811681146121eb57600080fd5b6001600160a01b038116811461073c57600080fd5b803561478e8161476e565b919050565b6004811061073c57600080fd5b60008083601f8401126147b257600080fd5b50813567ffffffffffffffff8111156147ca57600080fd5b6020830191508360208285010111156147e257600080fd5b9250929050565b60008060008060006080868803121561480157600080fd5b853561480c8161476e565b945060208601359350604086013561482381614793565b9250606086013567ffffffffffffffff81111561483f57600080fd5b61484b888289016147a0565b969995985093965092949392505050565b60008060008060006080868803121561487457600080fd5b853561487f8161476e565b9450602086013561488f8161476e565b935060408601359250606086013567ffffffffffffffff81111561483f57600080fd5b6000602082840312156148c457600080fd5b81356121eb8161476e565b600081518084526020808501945080840160005b838110156149085781516001600160a01b0316875295820195908201906001016148e3565b509495945050505050565b6020815260006121eb60208301846148cf565b60008060006060848603121561493b57600080fd5b83356149468161476e565b925060208401359150604084013567ffffffffffffffff81111561496957600080fd5b8401610120818703121561497c57600080fd5b809150509250925092565b60008083601f84011261499957600080fd5b50813567ffffffffffffffff8111156149b157600080fd5b6020830191508360208260051b85010111156147e257600080fd5b6000806000806000806000806080898b0312156149e857600080fd5b883567ffffffffffffffff80821115614a0057600080fd5b614a0c8c838d01614987565b909a50985060208b0135915080821115614a2557600080fd5b614a318c838d01614987565b909850965060408b0135915080821115614a4a57600080fd5b614a568c838d01614987565b909650945060608b0135915080821115614a6f57600080fd5b50614a7c8b828c01614987565b999c989b5096995094979396929594505050565b60008060408385031215614aa357600080fd5b8235614aae8161476e565b946020939093013593505050565b634e487b7160e01b600052602160045260246000fd5b6004811061073c5761073c614abc565b614aeb81614ad2565b9052565b60005b83811015614b0a578181015183820152602001614af2565b50506000910152565b60008151808452614b2b816020860160208601614aef565b601f01601f19169290920160200192915050565b6003811061073c5761073c614abc565b600081518084526020808501808196508360051b810191508286016000805b86811015614c46578385038a52825180518652860151604087870181905281518188018190529188019160609081890190865b81811015614c2f5785518051614bb681614ad2565b8452808d01516001600160a01b03168d85015285810151614bd681614b3f565b8487015280850151614be781614b3f565b848601526080818101516001600160481b03169085015260a0808201519085015260c0808201519085015260e09081015190840152948b019461010090920191600101614ba1565b50509c89019c975050509286019250600101614b6e565b509298975050505050505050565b60208152614c6e6020820183516001600160a01b03169052565b60006020830151614c826040840182614ae2565b50604083015163ffffffff8116606084015250606083015161ffff8116608084015250608083015163ffffffff811660a08401525060a083015165ffffffffffff811660c08401525060c083015165ffffffffffff811660e08401525060e0830151610100614cfb818501836001600160a01b03169052565b808501519150506101406101208181860152614d1b610160860184614b13565b90860151858203601f190183870152909250614d378382614b4f565b9695505050505050565b60008060008060008060008060a0898b031215614d5d57600080fd5b8835614d688161476e565b97506020890135614d788161476e565b9650604089013567ffffffffffffffff80821115614d9557600080fd5b614da18c838d01614987565b909850965060608b0135915080821115614dba57600080fd5b614dc68c838d01614987565b909650945060808b0135915080821115614ddf57600080fd5b50614a7c8b828c016147a0565b60008060008060008060808789031215614e0557600080fd5b8635614e108161476e565b955060208701359450604087013567ffffffffffffffff80821115614e3457600080fd5b614e408a838b01614987565b90965094506060890135915080821115614e5957600080fd5b50614e6689828a01614987565b979a9699509497509295939492505050565b803563ffffffff8116811461478e57600080fd5b600080600080600060808688031215614ea457600080fd5b8535614eaf8161476e565b945060208601359350614ec460408701614e78565b9250606086013567ffffffffffffffff811115614ee057600080fd5b61484b88828901614987565b6020815260006121eb6020830184614b13565b600080600060608486031215614f1457600080fd5b8335614f1f8161476e565b925060208401359150604084013561497c8161476e565b60008060008060008060a08789031215614f4f57600080fd5b8635614f5a8161476e565b95506020870135614f6a8161476e565b94506040870135935060608701359250608087013567ffffffffffffffff811115614f9457600080fd5b614e6689828a016147a0565b600060208284031215614fb257600080fd5b815180151581146121eb57600080fd5b634e487b7160e01b600052604160045260246000fd5b600181811c90821680614fec57607f821691505b60208210810361500c57634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115611d6657600081815260208120601f850160051c810160208610156150395750805b601f850160051c820191505b818110156145d657828155600101615045565b67ffffffffffffffff83111561507057615070614fc2565b6150848361507e8354614fd8565b83615012565b6000601f8411600181146150b857600085156150a05750838201355b600019600387901b1c1916600186901b178355613ae8565b600083815260209020601f19861690835b828110156150e957868501358255602094850194600190920191016150c9565b50868210156151065760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016151565761515661512e565b5060010190565b600081518084526020808501945080840160005b8381101561490857815187529582019590820190600101615171565b6060815260006151a060608301866148cf565b6020838203818501526151b3828761515d565b915083820360408501528185518084528284019150828160051b85010183880160005b8381101561520457601f198784030185526151f2838351614b13565b948601949250908501906001016151d6565b50909a9950505050505050505050565b60405160a0810167ffffffffffffffff8111828210171561523757615237614fc2565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561526657615266614fc2565b604052919050565b600067ffffffffffffffff82111561528857615288614fc2565b5060051b60200190565b600060208083850312156152a557600080fd5b825167ffffffffffffffff8111156152bc57600080fd5b8301601f810185136152cd57600080fd5b80516152e06152db8261526e565b61523d565b81815260059190911b820183019083810190878311156152ff57600080fd5b928401925b8284101561531d57835182529284019290840190615304565b979650505050505050565b60006020828403121561533a57600080fd5b6121eb82614e78565b6000808335601e1984360301811261535a57600080fd5b83018035915067ffffffffffffffff82111561537557600080fd5b6020019150600581901b36038213156147e257600080fd5b818103818111156105215761052161512e565b634e487b7160e01b600052601260045260246000fd5b6000826153c5576153c56153a0565b500690565b803565ffffffffffff8116811461478e57600080fd5b600082601f8301126153f157600080fd5b813560206154016152db8361526e565b82815260059290921b8401810191818101908684111561542057600080fd5b8286015b8481101561543b5780358352918301918301615424565b509695505050505050565b60006154546152db8461526e565b8381529050602080820190600585901b84018681111561547357600080fd5b845b8181101561552157803567ffffffffffffffff808211156154965760008081fd5b9087019060a0828b0312156154ab5760008081fd5b6154b3615214565b6154bc836153ca565b81526154c98684016153ca565b868201526040808401356154dc8161476e565b9082015260608381013590820152608080840135838111156154fe5760008081fd5b61550a8d8287016153e0565b918301919091525086525050928201928201615475565b505050509392505050565b6000806000806080858703121561554257600080fd5b843561554d8161476e565b93506020850135925061556260408601614e78565b9150606085013567ffffffffffffffff81111561557e57600080fd5b8501601f8101871361558f57600080fd5b61559e87823560208401615446565b91505092959194509250565b63ffffffff8181168382160280821691908281146155ca576155ca61512e565b505092915050565b808201808211156105215761052161512e565b600083516155f7818460208801614aef565b83519083019061560b818360208801614aef565b01949350505050565b600080600080600060a0868803121561562c57600080fd5b85356156378161476e565b94506020860135935061564c60408701614e78565b925060608601359150608086013567ffffffffffffffff81111561566f57600080fd5b61567b888289016153e0565b9150509295509295909350565b6000806000806080858703121561569e57600080fd5b84356156a98161476e565b93506020850135925060408501359150606085013567ffffffffffffffff8111156156d357600080fd5b61559e878288016153e0565b80820281158282048414176105215761052161512e565b60006121eb368484615446565b60006020828403121561571557600080fd5b813561ffff811681146121eb57600080fd5b600063ffffffff8084168061573e5761573e6153a0565b92169190910692915050565b6001600160481b038181168382160280821691908281146155ca576155ca61512e565b60006001600160a01b03808716835280861660208401525060a0604083015261579960a083018561515d565b82810360608401526157ab818561515d565b838103608090940193909352505060008152602001949350505050565b6060815260006157db60608301866148cf565b82810360208401526157ed818661515d565b90508281036040840152614d37818561515d565b63ffffffff818116838216019080821115613be257613be261512e565b63ffffffff828116828216039080821115613be257613be261512e565b600063ffffffff80841680615852576158526153a0565b92169190910492915050565b6001600160a01b0384168152606060208201526000615880606083018561515d565b8281036040840152614d37818561515d565b6000602082840312156158a457600080fd5b81516121eb8161476e565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156158d757600080fd5b81356121eb81614793565b6000602082840312156158f457600080fd5b6121eb826153ca565b6000808335601e1984360301811261591457600080fd5b83018035915067ffffffffffffffff82111561592f57600080fd5b6020019150368190038213156147e257600080fd5b60008235603e1983360301811261595a57600080fd5b9190910192915050565b6000808335601e1984360301811261597b57600080fd5b83018035915067ffffffffffffffff82111561599657600080fd5b6020019150600881901b36038213156147e257600080fd5b6003811061073c57600080fd5b803561478e816159ae565b6001600160481b038116811461073c57600080fd5b803561478e816159c6565b60006101008083850312156159fa57600080fd5b6040519081019067ffffffffffffffff82118183101715615a1d57615a1d614fc2565b8160405283359150615a2e82614793565b818152615a3d60208501614783565b6020820152615a4e604085016159bb565b6040820152615a5f606085016159bb565b6060820152615a70608085016159db565b608082015260a084013560a082015260c084013560c082015260e084013560e0820152809250505092915050565b60008135610521816159ae565b615ab482614b3f565b805460ff60a81b191660a89290921b60ff60a81b16919091179055565b615ada82614b3f565b805460ff60b01b191660b09290921b60ff60b01b16919091179055565b60008135610521816159c6565b8135615b0f81614793565b615b1881614ad2565b815460ff821691508160ff1982161783556020840135615b378161476e565b74ffffffffffffffffffffffffffffffffffffffff008160081b16836affffffffffffffffffffff60a81b841617178455505050615b80615b7a60408401615a9e565b82615aab565b615b95615b8f60608401615a9e565b82615ad1565b615be8615ba460808401615af7565b82805476ffffffffffffffffffffffffffffffffffffffffffffff1660b89290921b76ffffffffffffffffffffffffffffffffffffffffffffff1916919091179055565b60a0820135600182015560c0820135600282015560e08201356003820155505056fea2646970667358221220adffae1746ea7108eb08998f045791bb46645ee4bf987fcbe6da5c8e80170c0864736f6c63430008110033

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  ]
[ 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.