ETH Price: $2,589.33 (+2.03%)

Contract

0xe7C0Ac93420fD84F3335Dc5270F78B03e0B07a61

Overview

ETH Balance

0 ETH

ETH Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
NiftyKitV3

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import {ECDSAUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import {AddressUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import {ClonesUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/ClonesUpgradeable.sol";
import {DiamondCollection} from "./diamond/DiamondCollection.sol";
import {IDropKitPass} from "./interfaces/IDropKitPass.sol";
import {INiftyKitV3} from "./interfaces/INiftyKitV3.sol";
import {IERC173} from "./interfaces/IERC173.sol";

contract NiftyKitV3 is INiftyKitV3, Initializable, OwnableUpgradeable {
    enum FeeType {
        Seller,
        Buyer,
        Split
    }

    struct Collection {
        uint256 feeRate;
        FeeType feeType;
        bool exists;
    }

    event DiamondCreated(address indexed diamondAddress, string collectionId);

    using AddressUpgradeable for address;
    using ECDSAUpgradeable for bytes32;

    address private _signer;
    address private _treasury;
    address private _appRegistry;
    mapping(string => bool) _verifiedCollections;
    mapping(address => Collection) private _collections;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }

    function initialize(address appRegistry_) public initializer {
        _appRegistry = appRegistry_;
        _treasury = _msgSender();
        __Ownable_init();
    }

    function commission(
        address collection,
        uint256 amount
    ) public view override returns (uint256, uint256) {
        Collection memory _collection = _collections[collection];
        require(_collection.exists, "Invalid collection");
        uint256 feeAmount = (_collection.feeRate * amount) / 10000;

        if (_collection.feeType == FeeType.Seller) {
            return (feeAmount, 0);
        }

        if (_collection.feeType == FeeType.Buyer) {
            return (0, feeAmount);
        }

        uint256 splitAmount = feeAmount / 2;

        return (splitAmount, splitAmount);
    }

    function getFees(
        uint256 amount
    ) external view override returns (uint256, uint256) {
        return commission(_msgSender(), amount);
    }

    function appRegistry() external view returns (address) {
        return _appRegistry;
    }

    function treasury() external view returns (address) {
        return _treasury;
    }

    function withdraw() external onlyOwner {
        uint256 balance = address(this).balance;
        require(balance > 0, "Not enough to withdraw");

        AddressUpgradeable.sendValue(payable(_treasury), balance);
    }

    function setTreasury(address newTreasury) external onlyOwner {
        _treasury = newTreasury;
    }

    function setSigner(address signer) external onlyOwner {
        _signer = signer;
    }

    function setRate(address collection, uint256 rate) external onlyOwner {
        Collection storage _collection = _collections[collection];
        require(_collection.exists, "Does not exist");

        _collection.feeRate = rate;
    }

    function setFeeType(address collection, FeeType feeType) external {
        Collection storage _collection = _collections[collection];
        require(_collection.exists, "Does not exist");
        require(IERC173(collection).owner() == _msgSender(), "Not the owner");

        _collection.feeType = feeType;
    }

    function createDiamond(
        string memory collectionId_,
        uint96 feeRate_,
        bytes calldata signature_,
        address treasury_,
        address royalty_,
        uint16 royaltyBps_,
        string memory name_,
        string memory symbol_,
        bytes32[] calldata apps_
    ) external {
        require(_signer != address(0), "Signer not set");
        require(!_verifiedCollections[collectionId_], "Already created");
        require(
            keccak256(abi.encodePacked(collectionId_, feeRate_, block.chainid))
                .toEthSignedMessageHash()
                .recover(signature_) == _signer,
            "Invalid signature"
        );

        _verifiedCollections[collectionId_] = true;

        DiamondCollection collection = new DiamondCollection(
            _msgSender(),
            treasury_,
            royalty_,
            royaltyBps_,
            name_,
            symbol_,
            apps_
        );

        address deployed = address(collection);

        _collections[deployed] = Collection(
            feeRate_,
            FeeType.Seller,
            true
        );

        emit DiamondCreated(deployed, collectionId_);
    }

    receive() external payable {}
}

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

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal onlyInitializing {
        _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);
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/Clones.sol)

pragma solidity ^0.8.0;

/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 *
 * _Available since v3.4._
 */
library ClonesUpgradeable {
    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create(0, ptr, 0x37)
        }
        require(instance != address(0), "ERC1167: create failed");
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple time will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            instance := create2(0, ptr, 0x37, salt)
        }
        require(instance != address(0), "ERC1167: create2 failed");
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        /// @solidity memory-safe-assembly
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            mstore(add(ptr, 0x14), shl(0x60, implementation))
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
            mstore(add(ptr, 0x38), shl(0x60, deployer))
            mstore(add(ptr, 0x4c), salt)
            mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
            predicted := keccak256(add(ptr, 0x37), 0x55)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(address implementation, bytes32 salt)
        internal
        view
        returns (address predicted)
    {
        return predictDeterministicAddress(implementation, salt, address(this));
    }
}

File 1 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 functionCall(target, data, "Address: low-level call failed");
    }

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../StringsUpgradeable.sol";

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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    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 1 of 16 : BaseStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {INiftyKitAppRegistry} from "../interfaces/INiftyKitAppRegistry.sol";
import {INiftyKitV3} from "../interfaces/INiftyKitV3.sol";

library BaseStorage {
    enum Transfer {
        AllowAll,
        AllowedOperatorsOnly,
        BlockAll
    }

    struct URIEntry {
        bool isValue;
        string tokenURI;
    }

    bytes32 private constant STORAGE_SLOT = keccak256("niftykit.base.storage");

    uint256 public constant ADMIN_ROLE = 1 << 0;
    uint256 public constant MANAGER_ROLE = 1 << 1;
    uint256 public constant API_ROLE = 1 << 2;

    struct Layout {
        mapping(bytes32 => INiftyKitAppRegistry.App) _apps;
        mapping(address => bool) _allowedOperators;
        mapping(uint256 => bool) _blockedTokenIds;
        mapping(uint256 => URIEntry) _tokenURIs;
        bool _operatorFilteringEnabled;
        Transfer _transferStatus;
        INiftyKitV3 _niftyKit;
        uint8 _baseVersion;
        address _treasury;
        string _baseURI;
    }

    function layout() internal pure returns (Layout storage ds) {
        bytes32 position = STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            ds.slot := position
        }
    }
}

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

import {INiftyKitAppRegistry} from "../interfaces/INiftyKitAppRegistry.sol";
import {INiftyKitV3} from "../interfaces/INiftyKitV3.sol";
import {IDiamondCut} from "../interfaces/IDiamondCut.sol";
import {LibDiamond} from "../libraries/LibDiamond.sol";
import {BaseStorage} from "./BaseStorage.sol";

contract DiamondCollection {
    constructor(
        address owner,
        address treasury,
        address royalty,
        uint16 royaltyBps,
        string memory name,
        string memory symbol,
        bytes32[] memory apps
    ) {
        BaseStorage.Layout storage layout = BaseStorage.layout();
        layout._niftyKit = INiftyKitV3(msg.sender);
        INiftyKitAppRegistry registry = INiftyKitAppRegistry(
            layout._niftyKit.appRegistry()
        );
        INiftyKitAppRegistry.Base memory base = registry.getBase();
        IDiamondCut.FacetCut[] memory facetCuts = new IDiamondCut.FacetCut[](
            apps.length + 1
        );

        layout._treasury = treasury;
        layout._baseVersion = base.version;
        facetCuts = _appFacets(facetCuts, layout, registry, apps);
        facetCuts = _baseFacet(facetCuts, base);

        LibDiamond.diamondCut(
            facetCuts,
            base.implementation,
            abi.encodeWithSignature(
                "_initialize(address,string,string,address,uint16)",
                owner,
                name,
                symbol,
                royalty,
                royaltyBps
            )
        );
    }

    function _appFacets(
        IDiamondCut.FacetCut[] memory facetCuts,
        BaseStorage.Layout storage layout,
        INiftyKitAppRegistry registry,
        bytes32[] memory apps
    ) internal returns (IDiamondCut.FacetCut[] memory) {
        LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
        uint256 appsLength = apps.length;
        for (uint256 i = 0; i < appsLength; ) {
            INiftyKitAppRegistry.App memory app = registry.getApp(apps[i]);
            if (app.version == 0) revert("App does not exist");

            facetCuts[i] = IDiamondCut.FacetCut({
                facetAddress: app.implementation,
                action: IDiamondCut.FacetCutAction.Add,
                functionSelectors: app.selectors
            });

            ds.supportedInterfaces[app.interfaceId] = true;
            layout._apps[apps[i]] = app;

            unchecked {
                i++;
            }
        }

        return facetCuts;
    }

    function _baseFacet(
        IDiamondCut.FacetCut[] memory facetCuts,
        INiftyKitAppRegistry.Base memory base
    ) internal returns (IDiamondCut.FacetCut[] memory) {
        LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage();
        facetCuts[facetCuts.length - 1] = IDiamondCut.FacetCut({
            facetAddress: base.implementation,
            action: IDiamondCut.FacetCutAction.Add,
            functionSelectors: base.selectors
        });

        uint256 idsLength = base.interfaceIds.length;
        for (uint256 i = 0; i < idsLength; ) {
            ds.supportedInterfaces[base.interfaceIds[i]] = true;

            unchecked {
                i++;
            }
        }

        return facetCuts;
    }

    // Find facet for function that is called and execute the
    // function if a facet is found and return any value.
    fallback() external payable {
        LibDiamond.DiamondStorage storage ds;
        bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION;
        // get diamond storage
        assembly {
            ds.slot := position
        }
        // get facet from function selector
        address facet = address(bytes20(ds.facets[msg.sig]));
        require(facet != address(0), "Diamond: Function does not exist");
        // Execute external function from facet using delegatecall and return any value.
        assembly {
            // copy function selector and any arguments
            calldatacopy(0, 0, calldatasize())
            // execute function call using the facet
            let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0)
            // get any return value
            returndatacopy(0, 0, returndatasize())
            // return any return value or error back to the caller
            switch result
            case 0 {
                revert(0, returndatasize())
            }
            default {
                return(0, returndatasize())
            }
        }
    }

    receive() external payable {}
}

File 1 of 16 : IDiamondCut.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

interface IDiamondCut {
    enum FacetCutAction {Add, Replace, Remove}
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _diamondCut Contains the facet addresses and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call, including function selector and arguments
    ///                  _calldata is executed with delegatecall on _init
    function diamondCut(
        FacetCut[] calldata _diamondCut,
        address _init,
        bytes calldata _calldata
    ) external;

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}

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

interface IDropKitPass {
    struct FeeEntry {
        uint96 value;
        bool isValue;
    }

    struct Pass {
        uint256 price;
        bool isValue;
    }

    event PassCreated(uint256 indexed stageId, uint96 indexed feeRate);

    event PassRedeemed(
        uint256 indexed stageId,
        uint96 indexed feeRate,
        bytes32 indexed hash
    );

    /**
     * @dev Contract upgradeable initializer
     */
    function initialize(
        string memory name,
        string memory symbol,
        address treasury,
        address royalty,
        uint96 royaltyFee,
        uint96 defaultFeeRate
    ) external;

    /**
     * @dev Batch mints feeRate tokens for a given stage
     */
    function batchAirdrop(
        uint256 stageId,
        address[] calldata recipients,
        uint96[] calldata feeRates
    ) external;

    /**
     * @dev Gets the fee rate for a given token id
     */
    function getFeeRate(uint256 tokenId) external view returns (uint96);

    /**
     * @dev Gets the fee rate for a given address
     */
    function getFeeRateOf(address owner) external view returns (uint96);
}

File 1 of 16 : IERC173.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IERC173 {
    /// @notice Get the address of the owner
    /// @return The address of the owner.
    function owner() external view returns (address);
}

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

interface INiftyKitAppRegistry {
    struct App {
        address implementation;
        bytes4 interfaceId;
        bytes4[] selectors;
        uint8 version;
    }

    struct Base {
        address implementation;
        bytes4[] interfaceIds;
        bytes4[] selectors;
        uint8 version;
    }

    /**
     * Get App Facet by app name
     * @param name app name
     */
    function getApp(bytes32 name) external view returns (App memory);

    /**
     * Get base Facet
     */
    function getBase() external view returns (Base memory);
}

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

interface INiftyKitV3 {
    /**
     * @dev Returns app registry address.
     */
    function appRegistry() external returns (address);

    /**
     * @dev Returns the commission amount (sellerFee, buyerFee).
     */
    function commission(
        address collection,
        uint256 amount
    ) external view returns (uint256, uint256);

    /**
     * @dev Get fees by amount (called from collection)
     */
    function getFees(uint256 amount) external view returns (uint256, uint256);
}

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

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/
import { IDiamondCut } from "../interfaces/IDiamondCut.sol";

// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.
// The loupe functions are required by the EIP2535 Diamonds standard

error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata);

library LibDiamond {
    bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");

    struct DiamondStorage {
        // maps function selectors to the facets that execute the functions.
        // and maps the selectors to their position in the selectorSlots array.
        // func selector => address facet, selector position
        mapping(bytes4 => bytes32) facets;
        // array of slots of function selectors.
        // each slot holds 8 function selectors.
        mapping(uint256 => bytes32) selectorSlots;
        // The number of function selectors in selectorSlots
        uint16 selectorCount;
        // Used to query if a contract implements an interface.
        // Used to implement ERC-165.
        mapping(bytes4 => bool) supportedInterfaces;
        // owner of the contract
        address contractOwner;
    }

    function diamondStorage() internal pure returns (DiamondStorage storage ds) {
        bytes32 position = DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }

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

    function setContractOwner(address _newOwner) internal {
        DiamondStorage storage ds = diamondStorage();
        address previousOwner = ds.contractOwner;
        ds.contractOwner = _newOwner;
        emit OwnershipTransferred(previousOwner, _newOwner);
    }

    function contractOwner() internal view returns (address contractOwner_) {
        contractOwner_ = diamondStorage().contractOwner;
    }

    function enforceIsContractOwner() internal view {
        require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
    }

    event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);

    bytes32 constant CLEAR_ADDRESS_MASK = bytes32(uint256(0xffffffffffffffffffffffff));
    bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));

    // Internal function version of diamondCut
    // This code is almost the same as the external diamondCut,
    // except it is using 'Facet[] memory _diamondCut' instead of
    // 'Facet[] calldata _diamondCut'.
    // The code is duplicated to prevent copying calldata to memory which
    // causes an error for a two dimensional array.
    function diamondCut(
        IDiamondCut.FacetCut[] memory _diamondCut,
        address _init,
        bytes memory _calldata
    ) internal {
        DiamondStorage storage ds = diamondStorage();
        uint256 originalSelectorCount = ds.selectorCount;
        uint256 selectorCount = originalSelectorCount;
        bytes32 selectorSlot;
        // Check if last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8" 
        if (selectorCount & 7 > 0) {
            // get last selectorSlot
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            selectorSlot = ds.selectorSlots[selectorCount >> 3];
        }
        // loop through diamond cut
        for (uint256 facetIndex; facetIndex < _diamondCut.length; ) {
            (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(
                selectorCount,
                selectorSlot,
                _diamondCut[facetIndex].facetAddress,
                _diamondCut[facetIndex].action,
                _diamondCut[facetIndex].functionSelectors
            );

            unchecked {
                facetIndex++;
            }
        }
        if (selectorCount != originalSelectorCount) {
            ds.selectorCount = uint16(selectorCount);
        }
        // If last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8" 
        if (selectorCount & 7 > 0) {
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            ds.selectorSlots[selectorCount >> 3] = selectorSlot;
        }
        emit DiamondCut(_diamondCut, _init, _calldata);
        initializeDiamondCut(_init, _calldata);
    }

    function addReplaceRemoveFacetSelectors(
        uint256 _selectorCount,
        bytes32 _selectorSlot,
        address _newFacetAddress,
        IDiamondCut.FacetCutAction _action,
        bytes4[] memory _selectors
    ) internal returns (uint256, bytes32) {
        DiamondStorage storage ds = diamondStorage();
        require(_selectors.length > 0, "LibDiamondCut: No selectors in facet to cut");
        if (_action == IDiamondCut.FacetCutAction.Add) {
            enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Add facet has no code");
            for (uint256 selectorIndex; selectorIndex < _selectors.length; ) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                require(address(bytes20(oldFacet)) == address(0), "LibDiamondCut: Can't add function that already exists");
                // add facet for selector
                ds.facets[selector] = bytes20(_newFacetAddress) | bytes32(_selectorCount);
                // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8" 
                // " << 5 is the same as multiplying by 32 ( * 32)
                uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;
                // clear selector position in slot and add selector
                _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition);
                // if slot is full then write it to storage
                if (selectorInSlotPosition == 224) {
                    // "_selectorSlot >> 3" is a gas efficient division by 8 "_selectorSlot / 8"
                    ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;
                    _selectorSlot = 0;
                }
                _selectorCount++;

                unchecked {
                    selectorIndex++;
                }
            }
        } else if (_action == IDiamondCut.FacetCutAction.Replace) {
            enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Replace facet has no code");
            for (uint256 selectorIndex; selectorIndex < _selectors.length; ) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                address oldFacetAddress = address(bytes20(oldFacet));
                // only useful if immutable functions exist
                require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function");
                require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function");
                require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist");
                // replace old facet address
                ds.facets[selector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(_newFacetAddress);

                unchecked {
                    selectorIndex++;
                }
            }
        } else if (_action == IDiamondCut.FacetCutAction.Remove) {
            require(_newFacetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)");
            // "_selectorCount >> 3" is a gas efficient division by 8 "_selectorCount / 8"
            uint256 selectorSlotCount = _selectorCount >> 3;
            // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8" 
            uint256 selectorInSlotIndex = _selectorCount & 7;
            for (uint256 selectorIndex; selectorIndex < _selectors.length; ) {
                if (_selectorSlot == 0) {
                    // get last selectorSlot
                    selectorSlotCount--;
                    _selectorSlot = ds.selectorSlots[selectorSlotCount];
                    selectorInSlotIndex = 7;
                } else {
                    selectorInSlotIndex--;
                }
                bytes4 lastSelector;
                uint256 oldSelectorsSlotCount;
                uint256 oldSelectorInSlotPosition;
                // adding a block here prevents stack too deep error
                {
                    bytes4 selector = _selectors[selectorIndex];
                    bytes32 oldFacet = ds.facets[selector];
                    require(address(bytes20(oldFacet)) != address(0), "LibDiamondCut: Can't remove function that doesn't exist");
                    // only useful if immutable functions exist
                    require(address(bytes20(oldFacet)) != address(this), "LibDiamondCut: Can't remove immutable function");
                    // replace selector with last selector in ds.facets
                    // gets the last selector
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    lastSelector = bytes4(_selectorSlot << (selectorInSlotIndex << 5));
                    if (lastSelector != selector) {
                        // update last selector slot position info
                        ds.facets[lastSelector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(ds.facets[lastSelector]);
                    }
                    delete ds.facets[selector];
                    uint256 oldSelectorCount = uint16(uint256(oldFacet));
                    // "oldSelectorCount >> 3" is a gas efficient division by 8 "oldSelectorCount / 8"
                    oldSelectorsSlotCount = oldSelectorCount >> 3;
                    // "oldSelectorCount & 7" is a gas efficient modulo by eight "oldSelectorCount % 8" 
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;
                }
                if (oldSelectorsSlotCount != selectorSlotCount) {
                    bytes32 oldSelectorSlot = ds.selectorSlots[oldSelectorsSlotCount];
                    // clears the selector we are deleting and puts the last selector in its place.
                    oldSelectorSlot =
                        (oldSelectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                    // update storage with the modified slot
                    ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
                } else {
                    // clears the selector we are deleting and puts the last selector in its place.
                    _selectorSlot =
                        (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                }
                if (selectorInSlotIndex == 0) {
                    delete ds.selectorSlots[selectorSlotCount];
                    _selectorSlot = 0;
                }

                unchecked {
                    selectorIndex++;
                }
            }
            _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;
        } else {
            revert("LibDiamondCut: Incorrect FacetCutAction");
        }
        return (_selectorCount, _selectorSlot);
    }

    function initializeDiamondCut(address _init, bytes memory _calldata) internal {
        if (_init == address(0)) {
            return;
        }
        enforceHasContractCode(_init, "LibDiamondCut: _init address has no code");        
        (bool success, bytes memory error) = _init.delegatecall(_calldata);
        if (!success) {
            if (error.length > 0) {
                // bubble up error
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(error)
                    revert(add(32, error), returndata_size)
                }
            } else {
                revert InitializationFunctionReverted(_init, _calldata);
            }
        }
    }

    function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {
        uint256 contractSize;
        assembly {
            contractSize := extcodesize(_contract)
        }
        require(contractSize > 0, _errorMessage);
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"diamondAddress","type":"address"},{"indexed":false,"internalType":"string","name":"collectionId","type":"string"}],"name":"DiamondCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","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":"appRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"commission","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"collectionId_","type":"string"},{"internalType":"uint96","name":"feeRate_","type":"uint96"},{"internalType":"bytes","name":"signature_","type":"bytes"},{"internalType":"address","name":"treasury_","type":"address"},{"internalType":"address","name":"royalty_","type":"address"},{"internalType":"uint16","name":"royaltyBps_","type":"uint16"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"bytes32[]","name":"apps_","type":"bytes32[]"}],"name":"createDiamond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"getFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"appRegistry_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"enum NiftyKitV3.FeeType","name":"feeType","type":"uint8"}],"name":"setFeeType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"rate","type":"uint256"}],"name":"setRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"setSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newTreasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b5061001961001e565b6100de565b600054610100900460ff161561008a5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff90811610156100dc576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b613071806100ed6000396000f3fe608060405260043610620000f35760003560e01c80638da5cb5b1162000089578063d5a06d4c1162000060578063d5a06d4c1462000263578063e04c55ac146200029e578063f0f4426014620002c3578063f2fde38b14620002e857600080fd5b80638da5cb5b14620001fe578063bb4fceb9146200021e578063c4d66de8146200023e57600080fd5b806358671ea011620000ca57806358671ea0146200016457806361d027b314620001895780636c19e78314620001c1578063715018a614620001e657600080fd5b80630d114c9614620001005780632bdb709714620001275780633ccfd60b146200014c57600080fd5b36620000fb57005b600080fd5b3480156200010d57600080fd5b50620001256200011f36600462001340565b6200030d565b005b3480156200013457600080fd5b50620001256200014636600462001480565b62000659565b3480156200015957600080fd5b5062000125620006cb565b3480156200017157600080fd5b506200012562000183366004620014af565b62000739565b3480156200019657600080fd5b506066546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b348015620001ce57600080fd5b5062000125620001e0366004620014f0565b62000883565b348015620001f357600080fd5b5062000125620008af565b3480156200020b57600080fd5b506033546001600160a01b0316620001a4565b3480156200022b57600080fd5b506067546001600160a01b0316620001a4565b3480156200024b57600080fd5b50620001256200025d366004620014f0565b620008c7565b3480156200027057600080fd5b50620002886200028236600462001517565b62000a0b565b60408051928352602083019190915201620001b8565b348015620002ab57600080fd5b5062000288620002bd36600462001480565b62000a23565b348015620002d057600080fd5b5062000125620002e2366004620014f0565b62000b8b565b348015620002f557600080fd5b506200012562000307366004620014f0565b62000bb7565b6065546001600160a01b03166200035c5760405162461bcd60e51b815260206004820152600e60248201526d14da59db995c881b9bdd081cd95d60921b60448201526064015b60405180910390fd5b60688b6040516200036e919062001557565b9081526040519081900360200190205460ff1615620003c25760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818dc99585d1959608a1b604482015260640162000353565b606554604080516020601f8c018190048102820181019092528a81526001600160a01b03909216916200049a918c908c9081908401838280828437600081840152601f19601f82011690508083019250505050505050620004938e8e46604051602001620004339392919062001575565b60408051601f1981840301815282825280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000084830152603c8085019190915282518085039091018152605c909301909152815191012090565b9062000c33565b6001600160a01b031614620004e65760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b604482015260640162000353565b600160688c604051620004fa919062001557565b908152604051908190036020019020805491151560ff199092169190911790556000620005243390565b888888888888886040516200053990620011a2565b6200054c989796959493929190620015df565b604051809103906000f08015801562000569573d6000803e3d6000fd5b5060408051606081019091526bffffffffffffffffffffffff8d16815290915081906020810160008152600160209182018190526001600160a01b03841660009081526069835260409020835181559183015182820180549192909160ff191690836002811115620005df57620005df62001672565b021790555060408201518160010160016101000a81548160ff021916908315150217905550905050806001600160a01b03167fc0d721c6df448044cc0d6d8e96fd439aca86c1444d96de57611262f629687dbd8e60405162000642919062001688565b60405180910390a250505050505050505050505050565b6200066362000c5d565b6001600160a01b03821660009081526069602052604090206001810154610100900460ff16620006c75760405162461bcd60e51b815260206004820152600e60248201526d111bd95cc81b9bdd08195e1a5cdd60921b604482015260640162000353565b5550565b620006d562000c5d565b47806200071e5760405162461bcd60e51b81526020600482015260166024820152754e6f7420656e6f75676820746f20776974686472617760501b604482015260640162000353565b60665462000736906001600160a01b03168262000cb9565b50565b6001600160a01b03821660009081526069602052604090206001810154610100900460ff166200079d5760405162461bcd60e51b815260206004820152600e60248201526d111bd95cc81b9bdd08195e1a5cdd60921b604482015260640162000353565b336001600160a01b0316836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620007e6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200080c91906200169d565b6001600160a01b031614620008545760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b604482015260640162000353565b60018082018054849260ff199091169083600281111562000879576200087962001672565b0217905550505050565b6200088d62000c5d565b606580546001600160a01b0319166001600160a01b0392909216919091179055565b620008b962000c5d565b620008c5600062000ddd565b565b600054610100900460ff1615808015620008e85750600054600160ff909116105b80620009045750303b15801562000904575060005460ff166001145b620009695760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840162000353565b6000805460ff1916600117905580156200098d576000805461ff0019166101001790555b606780546001600160a01b0384166001600160a01b0319918216179091556066805490911633179055620009c062000e2f565b801562000a07576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b60008062000a1a338462000a23565b91509150915091565b6001600160a01b03821660009081526069602090815260408083208151606081019092528054825260018101548493849392919083019060ff16600281111562000a715762000a7162001672565b600281111562000a855762000a8562001672565b815260019190910154610100900460ff161515602090910152604081015190915062000ae95760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21031b7b63632b1ba34b7b760711b604482015260640162000353565b600061271085836000015162000b009190620016bd565b62000b0c9190620016e3565b905060008260200151600281111562000b295762000b2962001672565b0362000b3d5792506000915062000b849050565b60018260200151600281111562000b585762000b5862001672565b0362000b6c5760009350915062000b849050565b600062000b7b600283620016e3565b94508493505050505b9250929050565b62000b9562000c5d565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b62000bc162000c5d565b6001600160a01b03811662000c285760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840162000353565b620007368162000ddd565b600080600062000c44858562000e63565b9150915062000c538162000eaa565b5090505b92915050565b6033546001600160a01b03163314620008c55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000353565b8047101562000d0b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640162000353565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811462000d5a576040519150601f19603f3d011682016040523d82523d6000602084013e62000d5f565b606091505b505090508062000dd85760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840162000353565b505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1662000e595760405162461bcd60e51b8152600401620003539062001706565b620008c562001078565b600080825160410362000e9d5760208301516040840151606085015160001a62000e9087828585620010ad565b9450945050505062000b84565b5060009050600262000b84565b600081600481111562000ec15762000ec162001672565b0362000eca5750565b600181600481111562000ee15762000ee162001672565b0362000f305760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640162000353565b600281600481111562000f475762000f4762001672565b0362000f965760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640162000353565b600381600481111562000fad5762000fad62001672565b03620010075760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840162000353565b60048160048111156200101e576200101e62001672565b03620007365760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840162000353565b600054610100900460ff16620010a25760405162461bcd60e51b8152600401620003539062001706565b620008c53362000ddd565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115620010e6575060009050600362001199565b8460ff16601b14158015620010ff57508460ff16601c14155b1562001112575060009050600462001199565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801562001167573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116620011925760006001925092505062001199565b9150600090505b94509492505050565b6118ea806200175283390190565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620011d857600080fd5b813567ffffffffffffffff80821115620011f657620011f6620011b0565b604051601f8301601f19908116603f01168101908282118183101715620012215762001221620011b0565b816040528381528660208588010111156200123b57600080fd5b836020870160208301376000602085830101528094505050505092915050565b80356bffffffffffffffffffffffff811681146200127857600080fd5b919050565b60008083601f8401126200129057600080fd5b50813567ffffffffffffffff811115620012a957600080fd5b60208301915083602082850101111562000b8457600080fd5b6001600160a01b03811681146200073657600080fd5b80356200127881620012c2565b803561ffff811681146200127857600080fd5b60008083601f8401126200130b57600080fd5b50813567ffffffffffffffff8111156200132457600080fd5b6020830191508360208260051b850101111562000b8457600080fd5b60008060008060008060008060008060006101208c8e0312156200136357600080fd5b67ffffffffffffffff808d3511156200137b57600080fd5b6200138a8e8e358f01620011c6565b9b506200139a60208e016200125b565b9a508060408e01351115620013ae57600080fd5b620013c08e60408f01358f016200127d565b909a509850620013d360608e01620012d8565b9750620013e360808e01620012d8565b9650620013f360a08e01620012e5565b95508060c08e013511156200140757600080fd5b620014198e60c08f01358f01620011c6565b94508060e08e013511156200142d57600080fd5b6200143f8e60e08f01358f01620011c6565b9350806101008e013511156200145457600080fd5b50620014688d6101008e01358e01620012f8565b81935080925050509295989b509295989b9093969950565b600080604083850312156200149457600080fd5b8235620014a181620012c2565b946020939093013593505050565b60008060408385031215620014c357600080fd5b8235620014d081620012c2565b9150602083013560038110620014e557600080fd5b809150509250929050565b6000602082840312156200150357600080fd5b81356200151081620012c2565b9392505050565b6000602082840312156200152a57600080fd5b5035919050565b60005b838110156200154e57818101518382015260200162001534565b50506000910152565b600082516200156b81846020870162001531565b9190910192915050565b600084516200158981846020890162001531565b60a09490941b6001600160a01b03191691909301908152600c810191909152602c0192915050565b60008151808452620015cb81602086016020860162001531565b601f01601f19169290920160200192915050565b6001600160a01b03898116825288811660208301528716604082015261ffff8616606082015260e0608082018190526000906200161f90830187620015b1565b82810360a0840152620016338187620015b1565b83810360c085015284815290506001600160fb1b038411156200165557600080fd5b8360051b80866020840137016020019a9950505050505050505050565b634e487b7160e01b600052602160045260246000fd5b602081526000620015106020830184620015b1565b600060208284031215620016b057600080fd5b81516200151081620012c2565b808202811582820484141762000c5757634e487b7160e01b600052601160045260246000fd5b6000826200170157634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe608060405234801561001057600080fd5b506040516118ea3803806118ea83398101604081905261002f9161120d565b7f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5a805462010000600160b01b031916336201000090810291909117918290556040805163bb4fceb960e01b815290517f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db56936000936001600160a01b039104169163bb4fceb9916004828101926020929190829003018187875af11580156100da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100fe91906112e1565b90506000816001600160a01b031663d104a1366040518163ffffffff1660e01b8152600401600060405180830381865afa158015610140573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610168919081019061138e565b905060008451600161017a9190611456565b6001600160401b0381111561019157610191611082565b6040519080825280602002602001820160405280156101de57816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816101af5790505b506005850180546001600160a01b0319166001600160a01b038d16179055606083015160048601805460ff60b01b1916600160b01b60ff909316929092029190911790559050610230818585886102a3565b905061023c81836104ca565b90506102938183600001518d8a8a8e8e604051602401610260959493929190611495565b60408051601f198184030181529190526020810180516001600160e01b039081166375a2840360e01b179091526105ab16565b5050505050505050505050611734565b80516060906000805160206118568339815191529060005b818110156104be576000866001600160a01b03166342c71f1d8784815181106102e6576102e66114e8565b60200260200101516040518263ffffffff1660e01b815260040161030c91815260200190565b600060405180830381865afa158015610329573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261035191908101906114fe565b9050806060015160ff166000036103a45760405162461bcd60e51b8152602060048201526012602482015271105c1c08191bd95cc81b9bdd08195e1a5cdd60721b60448201526064015b60405180910390fd5b604080516060810190915281516001600160a01b03168152602081016000815260200182604001518152508983815181106103e1576103e16114e8565b602090810291909101810191909152818101516001600160e01b03191660009081526003860190915260408120805460ff19166001179055865182918a91899086908110610431576104316114e8565b6020908102919091018101518252818101929092526040908101600020835181548585015160e01c600160a01b026001600160c01b03199091166001600160a01b0390921691909117178155908301518051919261049792600185019290910190610fa5565b50606091909101516002909101805460ff191660ff909216919091179055506001016102bb565b50959695505050505050565b604080516060818101835283516001600160a01b0316825260006020830152838301519282019290925283516000805160206118568339815191529190859061051590600190611587565b81518110610525576105256114e8565b60200260200101819052506000836020015151905060005b8181101561059e57600183600301600087602001518481518110610563576105636114e8565b6020908102919091018101516001600160e01b0319168252810191909152604001600020805460ff191691151591909117905560010161053d565b5084925050505b92915050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e546000805160206118568339815191529061ffff8116908190600090600716156106085750600381901c60009081526001840160205260409020545b60005b875181101561068b5761067e83838a848151811061062b5761062b6114e8565b6020026020010151600001518b8581518110610649576106496114e8565b6020026020010151602001518c8681518110610667576106676114e8565b60200260200101516040015161071760201b60201c565b909350915060010161060b565b508282146106a75760028401805461ffff191661ffff84161790555b60078216156106c957600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738787876040516106fc9392919061159a565b60405180910390a161070e8686610eb8565b50505050505050565b60008080600080516020611856833981519152905060008451116107915760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b606482015260840161039b565b60008560028111156107a5576107a5611571565b03610913576107cc8660405180606001604052806024815260200161187660249139610f84565b60005b845181101561090d5760008582815181106107ec576107ec6114e8565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c1561088d5760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c7265616479206578697374730000000000000000000000606482015260840161039b565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a8190036108f15760038c901c600090815260018601602052604081209b909b555b8b6108fb8161169a565b9c5050600190930192506107cf915050565b50610eac565b600185600281111561092757610927611571565b03610b235761094e866040518060600160405280602881526020016118c260289139610f84565b60005b845181101561090d57600085828151811061096e5761096e6114e8565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c308103610a035760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b606482015260840161039b565b896001600160a01b0316816001600160a01b031603610a785760405162461bcd60e51b8152602060048201526038602482015260008051602061183683398151915260448201527f6374696f6e20776974682073616d652066756e6374696f6e0000000000000000606482015260840161039b565b6001600160a01b038116610ae25760405162461bcd60e51b8152602060048201526038602482015260008051602061183683398151915260448201527f6374696f6e207468617420646f65736e27742065786973740000000000000000606482015260840161039b565b506001600160e01b031990911660009081526020849052604090206001600160601b03919091166001600160601b031960608a901b16179055600101610951565b6002856002811115610b3757610b37611571565b03610e54576001600160a01b03861615610bb95760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d757374206265206164647265737328302900000000000000000000606482015260840161039b565b600388901c6007891660005b8651811015610e345760008a9003610c015782610be1816116b3565b60008181526001870160205260409020549b50935060079250610c0f9050565b81610c0b816116b3565b9250505b6000806000808a8581518110610c2757610c276114e8565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c610cc75760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e2774206578697374000000000000000000606482015260840161039b565b30606082901c03610d315760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b606482015260840161039b565b600587901b8f901b94506001600160e01b031980861690831614610d82576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166001600160601b0383161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e0169050858214610de7576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c179055610e0b565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b84600003610e2957600086815260018801602052604081208190559c505b505050600101610bc5565b5080610e418360086116ca565b610e4b9190611456565b99505050610eac565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b606482015260840161039b565b50959694955050505050565b6001600160a01b038216610eca575050565b610eec8260405180606001604052806028815260200161189a60289139610f84565b600080836001600160a01b031683604051610f0791906116e1565b600060405180830381855af49150503d8060008114610f42576040519150601f19603f3d011682016040523d82523d6000602084013e610f47565b606091505b509150915081610f7e57805115610f615780518082602001fd5b838360405163192105d760e01b815260040161039b9291906116fd565b50505050565b813b8181610f7e5760405162461bcd60e51b815260040161039b9190611721565b828054828255906000526020600020906007016008900481019282156110415791602002820160005b8382111561100f57835183826101000a81548163ffffffff021916908360e01c02179055509260200192600401602081600301049283019260010302610fce565b801561103f5782816101000a81549063ffffffff021916905560040160208160030104928301926001030261100f565b505b5061104d929150611051565b5090565b5b8082111561104d5760008155600101611052565b80516001600160a01b038116811461107d57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156110ba576110ba611082565b60405290565b604051601f8201601f191681016001600160401b03811182821017156110e8576110e8611082565b604052919050565b60005b8381101561110b5781810151838201526020016110f3565b50506000910152565b600082601f83011261112557600080fd5b81516001600160401b0381111561113e5761113e611082565b611151601f8201601f19166020016110c0565b81815284602083860101111561116657600080fd5b6111778260208301602087016110f0565b949350505050565b60006001600160401b0382111561119857611198611082565b5060051b60200190565b600082601f8301126111b357600080fd5b815160206111c86111c38361117f565b6110c0565b82815260059290921b840181019181810190868411156111e757600080fd5b8286015b8481101561120257805183529183019183016111eb565b509695505050505050565b600080600080600080600060e0888a03121561122857600080fd5b61123188611066565b965061123f60208901611066565b955061124d60408901611066565b9450606088015161ffff8116811461126457600080fd5b60808901519094506001600160401b038082111561128157600080fd5b61128d8b838c01611114565b945060a08a01519150808211156112a357600080fd5b6112af8b838c01611114565b935060c08a01519150808211156112c557600080fd5b506112d28a828b016111a2565b91505092959891949750929550565b6000602082840312156112f357600080fd5b6112fc82611066565b9392505050565b80516001600160e01b03198116811461107d57600080fd5b600082601f83011261132c57600080fd5b8151602061133c6111c38361117f565b82815260059290921b8401810191818101908684111561135b57600080fd5b8286015b848110156112025761137081611303565b835291830191830161135f565b805160ff8116811461107d57600080fd5b6000602082840312156113a057600080fd5b81516001600160401b03808211156113b757600080fd5b90830190608082860312156113cb57600080fd5b6113d3611098565b6113dc83611066565b81526020830151828111156113f057600080fd5b6113fc8782860161131b565b60208301525060408301518281111561141457600080fd5b6114208782860161131b565b6040830152506114326060840161137d565b606082015295945050505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156105a5576105a5611440565b600081518084526114818160208601602086016110f0565b601f01601f19169290920160200192915050565b600060018060a01b03808816835260a060208401526114b760a0840188611469565b83810360408501526114c98188611469565b959091166060840152505061ffff919091166080909101529392505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561151057600080fd5b81516001600160401b038082111561152757600080fd5b908301906080828603121561153b57600080fd5b611543611098565b61154c83611066565b815261155a60208401611303565b602082015260408301518281111561141457600080fd5b634e487b7160e01b600052602160045260246000fd5b818103818111156105a5576105a5611440565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101561166a57898403607f19018652815180516001600160a01b0316855283810151898601906003811061160957634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156116555783516001600160e01b031916825292860192600192909201919086019061162b565b509785019795505050908201906001016115c3565b50506001600160a01b038a1690880152868103604088015261168c8189611469565b9a9950505050505050505050565b6000600182016116ac576116ac611440565b5060010190565b6000816116c2576116c2611440565b506000190190565b80820281158282048414176105a5576105a5611440565b600082516116f38184602087016110f0565b9190910192915050565b6001600160a01b038316815260406020820181905260009061117790830184611469565b6020815260006112fc6020830184611469565b60f4806117426000396000f3fe608060405236600a57005b600080356001600160e01b03191681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6020819052604090912054819060601c80609b5760405162461bcd60e51b815260206004820181905260248201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f74206578697374604482015260640160405180910390fd5b3660008037600080366000845af43d6000803e80801560b9573d6000f35b3d6000fdfea26469706673582212206d25102b4d75f611f80bca95f71de85c40d00ec95bee8807fc20e6d745f0f01464736f6c634300081300334c69624469616d6f6e644375743a2043616e2774207265706c6163652066756ec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a26469706673582212207c9c0a911780694844865cd549c09afcaf0e178e83bac93750af8555f0a64c1a64736f6c63430008130033

Deployed Bytecode

0x608060405260043610620000f35760003560e01c80638da5cb5b1162000089578063d5a06d4c1162000060578063d5a06d4c1462000263578063e04c55ac146200029e578063f0f4426014620002c3578063f2fde38b14620002e857600080fd5b80638da5cb5b14620001fe578063bb4fceb9146200021e578063c4d66de8146200023e57600080fd5b806358671ea011620000ca57806358671ea0146200016457806361d027b314620001895780636c19e78314620001c1578063715018a614620001e657600080fd5b80630d114c9614620001005780632bdb709714620001275780633ccfd60b146200014c57600080fd5b36620000fb57005b600080fd5b3480156200010d57600080fd5b50620001256200011f36600462001340565b6200030d565b005b3480156200013457600080fd5b50620001256200014636600462001480565b62000659565b3480156200015957600080fd5b5062000125620006cb565b3480156200017157600080fd5b506200012562000183366004620014af565b62000739565b3480156200019657600080fd5b506066546001600160a01b03165b6040516001600160a01b0390911681526020015b60405180910390f35b348015620001ce57600080fd5b5062000125620001e0366004620014f0565b62000883565b348015620001f357600080fd5b5062000125620008af565b3480156200020b57600080fd5b506033546001600160a01b0316620001a4565b3480156200022b57600080fd5b506067546001600160a01b0316620001a4565b3480156200024b57600080fd5b50620001256200025d366004620014f0565b620008c7565b3480156200027057600080fd5b50620002886200028236600462001517565b62000a0b565b60408051928352602083019190915201620001b8565b348015620002ab57600080fd5b5062000288620002bd36600462001480565b62000a23565b348015620002d057600080fd5b5062000125620002e2366004620014f0565b62000b8b565b348015620002f557600080fd5b506200012562000307366004620014f0565b62000bb7565b6065546001600160a01b03166200035c5760405162461bcd60e51b815260206004820152600e60248201526d14da59db995c881b9bdd081cd95d60921b60448201526064015b60405180910390fd5b60688b6040516200036e919062001557565b9081526040519081900360200190205460ff1615620003c25760405162461bcd60e51b815260206004820152600f60248201526e105b1c9958591e4818dc99585d1959608a1b604482015260640162000353565b606554604080516020601f8c018190048102820181019092528a81526001600160a01b03909216916200049a918c908c9081908401838280828437600081840152601f19601f82011690508083019250505050505050620004938e8e46604051602001620004339392919062001575565b60408051601f1981840301815282825280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000084830152603c8085019190915282518085039091018152605c909301909152815191012090565b9062000c33565b6001600160a01b031614620004e65760405162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b604482015260640162000353565b600160688c604051620004fa919062001557565b908152604051908190036020019020805491151560ff199092169190911790556000620005243390565b888888888888886040516200053990620011a2565b6200054c989796959493929190620015df565b604051809103906000f08015801562000569573d6000803e3d6000fd5b5060408051606081019091526bffffffffffffffffffffffff8d16815290915081906020810160008152600160209182018190526001600160a01b03841660009081526069835260409020835181559183015182820180549192909160ff191690836002811115620005df57620005df62001672565b021790555060408201518160010160016101000a81548160ff021916908315150217905550905050806001600160a01b03167fc0d721c6df448044cc0d6d8e96fd439aca86c1444d96de57611262f629687dbd8e60405162000642919062001688565b60405180910390a250505050505050505050505050565b6200066362000c5d565b6001600160a01b03821660009081526069602052604090206001810154610100900460ff16620006c75760405162461bcd60e51b815260206004820152600e60248201526d111bd95cc81b9bdd08195e1a5cdd60921b604482015260640162000353565b5550565b620006d562000c5d565b47806200071e5760405162461bcd60e51b81526020600482015260166024820152754e6f7420656e6f75676820746f20776974686472617760501b604482015260640162000353565b60665462000736906001600160a01b03168262000cb9565b50565b6001600160a01b03821660009081526069602052604090206001810154610100900460ff166200079d5760405162461bcd60e51b815260206004820152600e60248201526d111bd95cc81b9bdd08195e1a5cdd60921b604482015260640162000353565b336001600160a01b0316836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015620007e6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200080c91906200169d565b6001600160a01b031614620008545760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b604482015260640162000353565b60018082018054849260ff199091169083600281111562000879576200087962001672565b0217905550505050565b6200088d62000c5d565b606580546001600160a01b0319166001600160a01b0392909216919091179055565b620008b962000c5d565b620008c5600062000ddd565b565b600054610100900460ff1615808015620008e85750600054600160ff909116105b80620009045750303b15801562000904575060005460ff166001145b620009695760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840162000353565b6000805460ff1916600117905580156200098d576000805461ff0019166101001790555b606780546001600160a01b0384166001600160a01b0319918216179091556066805490911633179055620009c062000e2f565b801562000a07576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050565b60008062000a1a338462000a23565b91509150915091565b6001600160a01b03821660009081526069602090815260408083208151606081019092528054825260018101548493849392919083019060ff16600281111562000a715762000a7162001672565b600281111562000a855762000a8562001672565b815260019190910154610100900460ff161515602090910152604081015190915062000ae95760405162461bcd60e51b815260206004820152601260248201527124b73b30b634b21031b7b63632b1ba34b7b760711b604482015260640162000353565b600061271085836000015162000b009190620016bd565b62000b0c9190620016e3565b905060008260200151600281111562000b295762000b2962001672565b0362000b3d5792506000915062000b849050565b60018260200151600281111562000b585762000b5862001672565b0362000b6c5760009350915062000b849050565b600062000b7b600283620016e3565b94508493505050505b9250929050565b62000b9562000c5d565b606680546001600160a01b0319166001600160a01b0392909216919091179055565b62000bc162000c5d565b6001600160a01b03811662000c285760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840162000353565b620007368162000ddd565b600080600062000c44858562000e63565b9150915062000c538162000eaa565b5090505b92915050565b6033546001600160a01b03163314620008c55760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640162000353565b8047101562000d0b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015260640162000353565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811462000d5a576040519150601f19603f3d011682016040523d82523d6000602084013e62000d5f565b606091505b505090508062000dd85760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d61792068617665207265766572746564000000000000606482015260840162000353565b505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1662000e595760405162461bcd60e51b8152600401620003539062001706565b620008c562001078565b600080825160410362000e9d5760208301516040840151606085015160001a62000e9087828585620010ad565b9450945050505062000b84565b5060009050600262000b84565b600081600481111562000ec15762000ec162001672565b0362000eca5750565b600181600481111562000ee15762000ee162001672565b0362000f305760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640162000353565b600281600481111562000f475762000f4762001672565b0362000f965760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640162000353565b600381600481111562000fad5762000fad62001672565b03620010075760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840162000353565b60048160048111156200101e576200101e62001672565b03620007365760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840162000353565b600054610100900460ff16620010a25760405162461bcd60e51b8152600401620003539062001706565b620008c53362000ddd565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115620010e6575060009050600362001199565b8460ff16601b14158015620010ff57508460ff16601c14155b1562001112575060009050600462001199565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801562001167573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116620011925760006001925092505062001199565b9150600090505b94509492505050565b6118ea806200175283390190565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620011d857600080fd5b813567ffffffffffffffff80821115620011f657620011f6620011b0565b604051601f8301601f19908116603f01168101908282118183101715620012215762001221620011b0565b816040528381528660208588010111156200123b57600080fd5b836020870160208301376000602085830101528094505050505092915050565b80356bffffffffffffffffffffffff811681146200127857600080fd5b919050565b60008083601f8401126200129057600080fd5b50813567ffffffffffffffff811115620012a957600080fd5b60208301915083602082850101111562000b8457600080fd5b6001600160a01b03811681146200073657600080fd5b80356200127881620012c2565b803561ffff811681146200127857600080fd5b60008083601f8401126200130b57600080fd5b50813567ffffffffffffffff8111156200132457600080fd5b6020830191508360208260051b850101111562000b8457600080fd5b60008060008060008060008060008060006101208c8e0312156200136357600080fd5b67ffffffffffffffff808d3511156200137b57600080fd5b6200138a8e8e358f01620011c6565b9b506200139a60208e016200125b565b9a508060408e01351115620013ae57600080fd5b620013c08e60408f01358f016200127d565b909a509850620013d360608e01620012d8565b9750620013e360808e01620012d8565b9650620013f360a08e01620012e5565b95508060c08e013511156200140757600080fd5b620014198e60c08f01358f01620011c6565b94508060e08e013511156200142d57600080fd5b6200143f8e60e08f01358f01620011c6565b9350806101008e013511156200145457600080fd5b50620014688d6101008e01358e01620012f8565b81935080925050509295989b509295989b9093969950565b600080604083850312156200149457600080fd5b8235620014a181620012c2565b946020939093013593505050565b60008060408385031215620014c357600080fd5b8235620014d081620012c2565b9150602083013560038110620014e557600080fd5b809150509250929050565b6000602082840312156200150357600080fd5b81356200151081620012c2565b9392505050565b6000602082840312156200152a57600080fd5b5035919050565b60005b838110156200154e57818101518382015260200162001534565b50506000910152565b600082516200156b81846020870162001531565b9190910192915050565b600084516200158981846020890162001531565b60a09490941b6001600160a01b03191691909301908152600c810191909152602c0192915050565b60008151808452620015cb81602086016020860162001531565b601f01601f19169290920160200192915050565b6001600160a01b03898116825288811660208301528716604082015261ffff8616606082015260e0608082018190526000906200161f90830187620015b1565b82810360a0840152620016338187620015b1565b83810360c085015284815290506001600160fb1b038411156200165557600080fd5b8360051b80866020840137016020019a9950505050505050505050565b634e487b7160e01b600052602160045260246000fd5b602081526000620015106020830184620015b1565b600060208284031215620016b057600080fd5b81516200151081620012c2565b808202811582820484141762000c5757634e487b7160e01b600052601160045260246000fd5b6000826200170157634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fe608060405234801561001057600080fd5b506040516118ea3803806118ea83398101604081905261002f9161120d565b7f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db5a805462010000600160b01b031916336201000090810291909117918290556040805163bb4fceb960e01b815290517f45f38af8fd646bf817698fe2be76218d850d401ba88ffd7c9cd1b4f5c9a1db56936000936001600160a01b039104169163bb4fceb9916004828101926020929190829003018187875af11580156100da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100fe91906112e1565b90506000816001600160a01b031663d104a1366040518163ffffffff1660e01b8152600401600060405180830381865afa158015610140573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610168919081019061138e565b905060008451600161017a9190611456565b6001600160401b0381111561019157610191611082565b6040519080825280602002602001820160405280156101de57816020015b604080516060808201835260008083526020830152918101919091528152602001906001900390816101af5790505b506005850180546001600160a01b0319166001600160a01b038d16179055606083015160048601805460ff60b01b1916600160b01b60ff909316929092029190911790559050610230818585886102a3565b905061023c81836104ca565b90506102938183600001518d8a8a8e8e604051602401610260959493929190611495565b60408051601f198184030181529190526020810180516001600160e01b039081166375a2840360e01b179091526105ab16565b5050505050505050505050611734565b80516060906000805160206118568339815191529060005b818110156104be576000866001600160a01b03166342c71f1d8784815181106102e6576102e66114e8565b60200260200101516040518263ffffffff1660e01b815260040161030c91815260200190565b600060405180830381865afa158015610329573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261035191908101906114fe565b9050806060015160ff166000036103a45760405162461bcd60e51b8152602060048201526012602482015271105c1c08191bd95cc81b9bdd08195e1a5cdd60721b60448201526064015b60405180910390fd5b604080516060810190915281516001600160a01b03168152602081016000815260200182604001518152508983815181106103e1576103e16114e8565b602090810291909101810191909152818101516001600160e01b03191660009081526003860190915260408120805460ff19166001179055865182918a91899086908110610431576104316114e8565b6020908102919091018101518252818101929092526040908101600020835181548585015160e01c600160a01b026001600160c01b03199091166001600160a01b0390921691909117178155908301518051919261049792600185019290910190610fa5565b50606091909101516002909101805460ff191660ff909216919091179055506001016102bb565b50959695505050505050565b604080516060818101835283516001600160a01b0316825260006020830152838301519282019290925283516000805160206118568339815191529190859061051590600190611587565b81518110610525576105256114e8565b60200260200101819052506000836020015151905060005b8181101561059e57600183600301600087602001518481518110610563576105636114e8565b6020908102919091018101516001600160e01b0319168252810191909152604001600020805460ff191691151591909117905560010161053d565b5084925050505b92915050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131e546000805160206118568339815191529061ffff8116908190600090600716156106085750600381901c60009081526001840160205260409020545b60005b875181101561068b5761067e83838a848151811061062b5761062b6114e8565b6020026020010151600001518b8581518110610649576106496114e8565b6020026020010151602001518c8681518110610667576106676114e8565b60200260200101516040015161071760201b60201c565b909350915060010161060b565b508282146106a75760028401805461ffff191661ffff84161790555b60078216156106c957600382901c600090815260018501602052604090208190555b7f8faa70878671ccd212d20771b795c50af8fd3ff6cf27f4bde57e5d4de0aeb6738787876040516106fc9392919061159a565b60405180910390a161070e8686610eb8565b50505050505050565b60008080600080516020611856833981519152905060008451116107915760405162461bcd60e51b815260206004820152602b60248201527f4c69624469616d6f6e644375743a204e6f2073656c6563746f727320696e206660448201526a1858d95d081d1bc818dd5d60aa1b606482015260840161039b565b60008560028111156107a5576107a5611571565b03610913576107cc8660405180606001604052806024815260200161187660249139610f84565b60005b845181101561090d5760008582815181106107ec576107ec6114e8565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c1561088d5760405162461bcd60e51b815260206004820152603560248201527f4c69624469616d6f6e644375743a2043616e2774206164642066756e6374696f60448201527f6e207468617420616c7265616479206578697374730000000000000000000000606482015260840161039b565b6001600160e01b031980831660008181526020879052604090206001600160601b031960608d901b168e17905560e060058e901b811692831c199c909c1690821c179a8190036108f15760038c901c600090815260018601602052604081209b909b555b8b6108fb8161169a565b9c5050600190930192506107cf915050565b50610eac565b600185600281111561092757610927611571565b03610b235761094e866040518060600160405280602881526020016118c260289139610f84565b60005b845181101561090d57600085828151811061096e5761096e6114e8565b6020908102919091018101516001600160e01b03198116600090815291859052604090912054909150606081901c308103610a035760405162461bcd60e51b815260206004820152602f60248201527f4c69624469616d6f6e644375743a2043616e2774207265706c61636520696d6d60448201526e3aba30b1363290333ab731ba34b7b760891b606482015260840161039b565b896001600160a01b0316816001600160a01b031603610a785760405162461bcd60e51b8152602060048201526038602482015260008051602061183683398151915260448201527f6374696f6e20776974682073616d652066756e6374696f6e0000000000000000606482015260840161039b565b6001600160a01b038116610ae25760405162461bcd60e51b8152602060048201526038602482015260008051602061183683398151915260448201527f6374696f6e207468617420646f65736e27742065786973740000000000000000606482015260840161039b565b506001600160e01b031990911660009081526020849052604090206001600160601b03919091166001600160601b031960608a901b16179055600101610951565b6002856002811115610b3757610b37611571565b03610e54576001600160a01b03861615610bb95760405162461bcd60e51b815260206004820152603660248201527f4c69624469616d6f6e644375743a2052656d6f7665206661636574206164647260448201527f657373206d757374206265206164647265737328302900000000000000000000606482015260840161039b565b600388901c6007891660005b8651811015610e345760008a9003610c015782610be1816116b3565b60008181526001870160205260409020549b50935060079250610c0f9050565b81610c0b816116b3565b9250505b6000806000808a8581518110610c2757610c276114e8565b6020908102919091018101516001600160e01b031981166000908152918a9052604090912054909150606081901c610cc75760405162461bcd60e51b815260206004820152603760248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f76652066756e6360448201527f74696f6e207468617420646f65736e2774206578697374000000000000000000606482015260840161039b565b30606082901c03610d315760405162461bcd60e51b815260206004820152602e60248201527f4c69624469616d6f6e644375743a2043616e27742072656d6f766520696d6d7560448201526d3a30b1363290333ab731ba34b7b760911b606482015260840161039b565b600587901b8f901b94506001600160e01b031980861690831614610d82576001600160e01b03198516600090815260208a90526040902080546001600160601b0319166001600160601b0383161790555b6001600160e01b031991909116600090815260208990526040812055600381901c611fff16925060051b60e0169050858214610de7576000828152600188016020526040902080546001600160e01b031980841c19909116908516831c179055610e0b565b80836001600160e01b031916901c816001600160e01b031960001b901c198e16179c505b84600003610e2957600086815260018801602052604081208190559c505b505050600101610bc5565b5080610e418360086116ca565b610e4b9190611456565b99505050610eac565b60405162461bcd60e51b815260206004820152602760248201527f4c69624469616d6f6e644375743a20496e636f727265637420466163657443756044820152663a20b1ba34b7b760c91b606482015260840161039b565b50959694955050505050565b6001600160a01b038216610eca575050565b610eec8260405180606001604052806028815260200161189a60289139610f84565b600080836001600160a01b031683604051610f0791906116e1565b600060405180830381855af49150503d8060008114610f42576040519150601f19603f3d011682016040523d82523d6000602084013e610f47565b606091505b509150915081610f7e57805115610f615780518082602001fd5b838360405163192105d760e01b815260040161039b9291906116fd565b50505050565b813b8181610f7e5760405162461bcd60e51b815260040161039b9190611721565b828054828255906000526020600020906007016008900481019282156110415791602002820160005b8382111561100f57835183826101000a81548163ffffffff021916908360e01c02179055509260200192600401602081600301049283019260010302610fce565b801561103f5782816101000a81549063ffffffff021916905560040160208160030104928301926001030261100f565b505b5061104d929150611051565b5090565b5b8082111561104d5760008155600101611052565b80516001600160a01b038116811461107d57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156110ba576110ba611082565b60405290565b604051601f8201601f191681016001600160401b03811182821017156110e8576110e8611082565b604052919050565b60005b8381101561110b5781810151838201526020016110f3565b50506000910152565b600082601f83011261112557600080fd5b81516001600160401b0381111561113e5761113e611082565b611151601f8201601f19166020016110c0565b81815284602083860101111561116657600080fd5b6111778260208301602087016110f0565b949350505050565b60006001600160401b0382111561119857611198611082565b5060051b60200190565b600082601f8301126111b357600080fd5b815160206111c86111c38361117f565b6110c0565b82815260059290921b840181019181810190868411156111e757600080fd5b8286015b8481101561120257805183529183019183016111eb565b509695505050505050565b600080600080600080600060e0888a03121561122857600080fd5b61123188611066565b965061123f60208901611066565b955061124d60408901611066565b9450606088015161ffff8116811461126457600080fd5b60808901519094506001600160401b038082111561128157600080fd5b61128d8b838c01611114565b945060a08a01519150808211156112a357600080fd5b6112af8b838c01611114565b935060c08a01519150808211156112c557600080fd5b506112d28a828b016111a2565b91505092959891949750929550565b6000602082840312156112f357600080fd5b6112fc82611066565b9392505050565b80516001600160e01b03198116811461107d57600080fd5b600082601f83011261132c57600080fd5b8151602061133c6111c38361117f565b82815260059290921b8401810191818101908684111561135b57600080fd5b8286015b848110156112025761137081611303565b835291830191830161135f565b805160ff8116811461107d57600080fd5b6000602082840312156113a057600080fd5b81516001600160401b03808211156113b757600080fd5b90830190608082860312156113cb57600080fd5b6113d3611098565b6113dc83611066565b81526020830151828111156113f057600080fd5b6113fc8782860161131b565b60208301525060408301518281111561141457600080fd5b6114208782860161131b565b6040830152506114326060840161137d565b606082015295945050505050565b634e487b7160e01b600052601160045260246000fd5b808201808211156105a5576105a5611440565b600081518084526114818160208601602086016110f0565b601f01601f19169290920160200192915050565b600060018060a01b03808816835260a060208401526114b760a0840188611469565b83810360408501526114c98188611469565b959091166060840152505061ffff919091166080909101529392505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561151057600080fd5b81516001600160401b038082111561152757600080fd5b908301906080828603121561153b57600080fd5b611543611098565b61154c83611066565b815261155a60208401611303565b602082015260408301518281111561141457600080fd5b634e487b7160e01b600052602160045260246000fd5b818103818111156105a5576105a5611440565b60006060808301818452808751808352608092508286019150828160051b8701016020808b0160005b8481101561166a57898403607f19018652815180516001600160a01b0316855283810151898601906003811061160957634e487b7160e01b600052602160045260246000fd5b868601526040918201519186018a905281519081905290840190600090898701905b808310156116555783516001600160e01b031916825292860192600192909201919086019061162b565b509785019795505050908201906001016115c3565b50506001600160a01b038a1690880152868103604088015261168c8189611469565b9a9950505050505050505050565b6000600182016116ac576116ac611440565b5060010190565b6000816116c2576116c2611440565b506000190190565b80820281158282048414176105a5576105a5611440565b600082516116f38184602087016110f0565b9190910192915050565b6001600160a01b038316815260406020820181905260009061117790830184611469565b6020815260006112fc6020830184611469565b60f4806117426000396000f3fe608060405236600a57005b600080356001600160e01b03191681527fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c6020819052604090912054819060601c80609b5760405162461bcd60e51b815260206004820181905260248201527f4469616d6f6e643a2046756e6374696f6e20646f6573206e6f74206578697374604482015260640160405180910390fd5b3660008037600080366000845af43d6000803e80801560b9573d6000f35b3d6000fdfea26469706673582212206d25102b4d75f611f80bca95f71de85c40d00ec95bee8807fc20e6d745f0f01464736f6c634300081300334c69624469616d6f6e644375743a2043616e2774207265706c6163652066756ec8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c4c69624469616d6f6e644375743a2041646420666163657420686173206e6f20636f64654c69624469616d6f6e644375743a205f696e6974206164647265737320686173206e6f20636f64654c69624469616d6f6e644375743a205265706c61636520666163657420686173206e6f20636f6465a26469706673582212207c9c0a911780694844865cd549c09afcaf0e178e83bac93750af8555f0a64c1a64736f6c63430008130033

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

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.