ETH Price: $2,417.50 (-2.92%)

Contract

0x42bBFEac6E5b6333A04d978CC6CA73A350fc3fda
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Redeem201481462024-06-22 15:30:11107 days ago1719070211IN
0x42bBFEac...350fc3fda
0 ETH0.000384944.03851286
Redeem197086112024-04-22 4:39:47169 days ago1713760787IN
0x42bBFEac...350fc3fda
0 ETH0.000619096.01706462
Redeem184962972023-11-04 4:28:11339 days ago1699072091IN
0x42bBFEac...350fc3fda
0 ETH0.0012951513.58771693
Redeem184961102023-11-04 3:50:11339 days ago1699069811IN
0x42bBFEac...350fc3fda
0 ETH0.0012120112.71546362
Redeem184830002023-11-02 7:45:11340 days ago1698911111IN
0x42bBFEac...350fc3fda
0 ETH0.0014608916.1392537
Redeem184746542023-11-01 3:43:59342 days ago1698810239IN
0x42bBFEac...350fc3fda
0 ETH0.0013328213.98296427
Redeem184745602023-11-01 3:24:47342 days ago1698809087IN
0x42bBFEac...350fc3fda
0 ETH0.0015347516.10139502
Redeem184399212023-10-27 7:01:47346 days ago1698390107IN
0x42bBFEac...350fc3fda
0 ETH0.0016384617.18943834
Redeem184397752023-10-27 6:32:35346 days ago1698388355IN
0x42bBFEac...350fc3fda
0 ETH0.0015655616.42462825
Redeem184261902023-10-25 8:53:35348 days ago1698224015IN
0x42bBFEac...350fc3fda
0 ETH0.0012016312.60662447
Redeem184259962023-10-25 8:14:11348 days ago1698221651IN
0x42bBFEac...350fc3fda
0 ETH0.0014934415.66807175
Redeem184252142023-10-25 5:35:47349 days ago1698212147IN
0x42bBFEac...350fc3fda
0 ETH0.001057711.09663424
Redeem184251352023-10-25 5:19:47349 days ago1698211187IN
0x42bBFEac...350fc3fda
0 ETH0.0010568911.08812235
Redeem184245632023-10-25 3:24:11349 days ago1698204251IN
0x42bBFEac...350fc3fda
0 ETH0.0018285916.26604262
Redeem183873052023-10-19 22:16:59354 days ago1697753819IN
0x42bBFEac...350fc3fda
0 ETH0.000836758.77855086
Redeem183825162023-10-19 6:11:23355 days ago1697695883IN
0x42bBFEac...350fc3fda
0 ETH0.000526645.52510462
Redeem183760382023-10-18 8:25:35355 days ago1697617535IN
0x42bBFEac...350fc3fda
0 ETH0.000625236.55941647
Redeem183759452023-10-18 8:06:23355 days ago1697616383IN
0x42bBFEac...350fc3fda
0 ETH0.000702847.37370024
Redeem183740012023-10-18 1:35:23356 days ago1697592923IN
0x42bBFEac...350fc3fda
0 ETH0.000657016.89286234
Redeem183632082023-10-16 13:22:59357 days ago1697462579IN
0x42bBFEac...350fc3fda
0 ETH0.0013067313.70925071
Redeem183303262023-10-11 22:59:59362 days ago1697065199IN
0x42bBFEac...350fc3fda
0 ETH0.000546555.73404227
Redeem183237822023-10-11 0:58:59363 days ago1696985939IN
0x42bBFEac...350fc3fda
0 ETH0.00048725.11141129
Redeem183235932023-10-11 0:20:47363 days ago1696983647IN
0x42bBFEac...350fc3fda
0 ETH0.00049815.22568588
Redeem183232892023-10-10 23:19:59363 days ago1696979999IN
0x42bBFEac...350fc3fda
0 ETH0.000481895.05561161
Redeem183092502023-10-09 0:10:35365 days ago1696810235IN
0x42bBFEac...350fc3fda
0 ETH0.000612646.76818453
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
NFTBuyer

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 200 runs

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

/**
 * @title NFTBuyer
 * @author pbnather
 */

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";

import "./interfaces/INFTBuyer.sol";

contract NFTBuyer is INFTBuyer, Ownable {
    using SafeERC20 for IERC20;

    /* ============ Structures ============ */

    struct Collection {
        IERC721 collectionAddress;
        IERC20 payoutToken;
        uint256 price;
        bool allowAll;
        mapping(uint256 => bool) allowed;
        uint256[] allowedList;
    }

    /* ============ State ============ */

    Collection[] public collections;
    mapping(address => uint256) public collectionIndexes;
    address public nftReceiver;

    /* ============ Constructor ============ */

    constructor(address _nftReceiver) {
        require(_nftReceiver != address(0));
        nftReceiver = _nftReceiver;
        collections.push();
    }

    /* ============ External Owner Functions ============ */

    /**
     * @notice Adds collection with specific ids, or all ids allowlisted.
     *
     * @dev If @param _allowAll is set to true, @param _ids has to be empty.
     * If @param _allowAll is set to false, @param _ids cannot be empty.
     *
     * @param _collection Address of ERC721 collection.
     * @param _ids List of allowlisted ids.
     * @param _allowAll Bool if all ids are allowlisted.
     * @param _token ERC20 token address that is paid for NFTs in the collection.
     * @param _price Price of the NFT in @param _token.
     */
    function addCollection(
        IERC721 _collection,
        uint256[] memory _ids,
        bool _allowAll,
        IERC20 _token,
        uint256 _price
    ) external onlyOwner {
        uint256 length = _ids.length;
        if (_allowAll) require(length == 0, "_allowAll is true, don't add ids");
        else require(length > 0, "_allowAll is false, specify ids");
        require(address(_token) != address(0), "Token address zero");
        require(address(_collection) != address(0), "Collection address zero");
        require(
            collectionIndexes[address(_collection)] == 0,
            "Collection already exists"
        );
        require(_price > 0, "Price is zero");

        collections.push();
        uint256 index = collections.length - 1;
        collectionIndexes[address(_collection)] = index;
        Collection storage collection = collections[index];
        collection.collectionAddress = _collection;
        collection.payoutToken = _token;
        collection.price = _price;
        collection.allowAll = _allowAll;
        for (uint256 i = 0; i < length; i++) {
            collection.allowed[_ids[i]] = true;
            collection.allowedList.push(_ids[i]);
        }

        emit CollectionAdded(_collection, _token, _price, _ids);
    }

    /**
     * @notice Set collection ids' state.
     *
     * @dev Collection's `allowAll` has to be false.
     *
     * @param _collection Address of ERC721 collection.
     * @param _ids List of collection ids.
     * @param _allows List of ids' allowed states in same order as @param _ids.
     */
    function setCollectionIds(
        IERC721 _collection,
        uint256[] memory _ids,
        bool[] memory _allows
    ) external onlyOwner {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collection = collections[index];
        require(collection.allowAll != true, "Collection is in allAllow mode");
        uint256 length = _ids.length;
        for (uint256 i = 0; i < length; i++) {
            if (collection.allowed[_ids[i]] == _allows[i]) continue;
            collection.allowed[_ids[i]] = _allows[i];
            if (_allows[i]) collection.allowedList.push(_ids[i]);
            else _deleteIdFromCollection(collection, _ids[i]);
        }

        emit CollectionIdsSet(_collection, _ids, _allows);
    }

    /**
     * @notice Set collection's `allowAll` state, if all ids are allowed.
     *
     * @dev Setting `allowAll` to true will clear `allowedList` and `allowed`.
     *
     * @param _collection Address of ERC721 collection.
     * @param _allowAll New `allowAll` state.
     */
    function setCollectionAllowAll(IERC721 _collection, bool _allowAll)
        external
        onlyOwner
    {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collection = collections[index];
        require(collection.allowAll != _allowAll, "State is same");
        collection.allowAll = _allowAll;
        if (_allowAll) {
            uint256 length = collection.allowedList.length;
            for (uint256 i = 0; i < length; i++) {
                collection.allowed[collection.allowedList[i]] = false;
            }
            delete collection.allowedList;
        }
        emit CollectionAllowAllChanged(_collection, _allowAll);
    }

    /**
     * @notice Set collection's price per NFT and ERC20 token to payout.
     *
     * @param _collection Address of ERC721 collection.
     * @param _price Price of the NFT in @param _token.
     * @param _token ERC20 token address that is paid for NFTs in the collection.
     */
    function setCollectionPriceAndToken(
        IERC721 _collection,
        uint256 _price,
        IERC20 _token
    ) external onlyOwner {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collection = collections[index];
        require(_price > 0, "Price is zero");
        require(address(_token) != address(0), "Token is address zero");
        collection.price = _price;
        collection.payoutToken = _token;
        emit CollectionPriceAndTokenChanged(_collection, _price, _token);
    }

    /**
     * @notice Set address that gets all the NFTs.
     *
     * @param _nftReceiver Address that gets all the NFTs.
     */
    function setNftReceiver(address _nftReceiver) external onlyOwner {
        require(_nftReceiver != address(0), "New address is address zero");
        require(_nftReceiver != nftReceiver, "Address is same");
        address oldNftReceiver = nftReceiver;
        nftReceiver = _nftReceiver;
        emit NFTReceiverChanged(oldNftReceiver, _nftReceiver);
    }

    /**
     * @notice Withdraws ERC20 token to the owner address.
     *
     * @param _token ERC20 token address to withdraw.
     */
    function withdrawTokens(IERC20 _token) external onlyOwner {
        require(address(_token) != address(0), "Token is address zero");
        uint256 amount = _token.balanceOf(address(this));
        require(amount > 0, "Cannot withdraw zero tokens");
        _token.safeTransfer(owner(), amount);
        emit WithdrewTokens(_token, amount);
    }

    /* ============ External Functions ============ */

    /**
     * @notice Redeem NFTs for the corresponding ERC20 tokens.
     *
     * @dev Will revert if any NFT won't redeem succesfully.
     *
     * @param _collection Address of ERC721 collection.
     * @param _ids List of ids to redeem.
     */
    function redeem(IERC721 _collection, uint256[] memory _ids) external {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collection = collections[index];
        for (uint256 i = 0; i < _ids.length; i++) {
            if (collection.allowAll || collection.allowed[_ids[i]]) {
                _redeemNft(collection, _ids[i]);
            } else {
                revert("NFT is not allowed");
            }
        }
    }

    /* ============ External View Functions ============ */

    /**
     * @notice Returns length of the `collections` list.
     *
     * @dev First Collection is dummy one.
     *
     * @return length_ Length of the `collections` list.
     */
    function getCollectionsLength() external view returns (uint256 length_) {
        length_ = collections.length;
    }

    /**
     * @notice Returns list of all collection addresses.
     *
     * @dev First dummy collection is ommited from the returned list.
     *
     * @return collections_ List of collection addresses.
     */
    function getAllCollectionAddresses()
        external
        view
        returns (address[] memory collections_)
    {
        uint256 length = collections.length;
        collections_ = new address[](length - 1);
        for (uint256 i = 1; i < length; i++) {
            collections_[i - 1] = address(collections[i].collectionAddress);
        }
    }

    /**
     * @notice Returns all allowed ids from the given collection.
     *
     * @dev If @return allIds_ is true, all ids are allowed, and @return ids_ is empty.
     *
     * @param _collection Address of ERC721 collection.
     *
     * @return allIds_ Bool if all ids are allowlisted.
     * @return ids_ List of allowed ids.
     */
    function getAllowedCollectionIds(IERC721 _collection)
        external
        view
        returns (bool allIds_, uint256[] memory ids_)
    {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collection = collections[index];
        if (collection.allowAll) allIds_ = true;
        else {
            allIds_ = false;
            uint256 length = collection.allowedList.length;
            ids_ = new uint256[](length);
            for (uint256 i = 0; i < length; i++) {
                ids_[i] = collection.allowedList[i];
            }
        }
    }

    /**
     * @notice Returns price in ERC20 token for each NFT in the collection.
     *
     * @param _collection Address of ERC721 collection.
     *
     * @return token_ ERC20 token address that is paid for NFTs in the collection.
     * @return price_ Price of the NFT in @param _token.
     */
    function getCollectionPriceAndToken(IERC721 _collection)
        external
        view
        returns (IERC20 token_, uint256 price_)
    {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collection = collections[index];
        token_ = collection.payoutToken;
        price_ = collection.price;
    }

    /**
     * @notice Returns if the given NFT id is allowlisted to redeem.
     *
     * @param _collection Address of ERC721 collection.
     * @param _id Id of the NFT in the @param _collection.
     *
     * @return allowed_ Bool if NFT with id @param _id is allowed.
     */
    function isNftAllowed(IERC721 _collection, uint256 _id)
        external
        view
        returns (bool allowed_)
    {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collection = collections[index];
        if (collection.allowAll) {
            allowed_ = true;
        } else if (collection.allowed[_id]) {
            allowed_ = true;
        } else {
            allowed_ = false;
        }
    }

    /**
     * @notice Returns list of NFT collection id's that the user has and are able to redeem.
     *
     * @dev Collection has to support IERC721Enumerable for this to work, otherwise it will revert.
     *
     * @param _collection Address of ERC721 collection.
     * @param _account User account address to check.
     *
     * @return ids_ List of collection IDs that the user has and that are allowed to redeem.
     */
    function getUserAllowedNfts(IERC721 _collection, address _account)
        external
        view
        returns (uint256[] memory ids_)
    {
        uint256 index = collectionIndexes[address(_collection)];
        require(index > 0, "Collection doesn't exist");
        Collection storage collectionInfo = collections[index];

        // Return empty array if user doesn't have nfts.
        uint256 nftBalance = _collection.balanceOf(_account);
        if (nftBalance == 0) return new uint256[](0);

        // Check if collection supports IERC721Enumerable extension.
        require(
            _collection.supportsInterface(type(IERC721Enumerable).interfaceId),
            "Collection not IERC721Enumerable"
        );

        IERC721Enumerable collection = IERC721Enumerable(address(_collection));
        uint256[] memory userNfts = new uint256[](nftBalance);

        if (collectionInfo.allowAll) {
            // Return all user NFTs.
            for (uint256 i = 0; i < nftBalance; i++) {
                userNfts[i] = collection.tokenOfOwnerByIndex(_account, i);
            }
            return userNfts;
        } else {
            // Filter NFTs to return.
            uint256 noAllowedIds = 0;
            for (uint256 i = 0; i < nftBalance; i++) {
                uint256 id = collection.tokenOfOwnerByIndex(_account, i);
                if (collectionInfo.allowed[id]) {
                    userNfts[noAllowedIds] = id;
                    noAllowedIds += 1;
                }
            }
            uint256[] memory userAllowedNfts = new uint256[](noAllowedIds);
            for (uint256 i = 0; i < noAllowedIds; i++) {
                userAllowedNfts[i] = userNfts[i];
            }
            return userAllowedNfts;
        }
    }

    /* ============ Private Functions ============ */

    /**
     * @dev Transfer tokens and NFTs, clear collections data if needed.
     *
     * @param _collection Collection struct from `collections` list.
     * @param _id Id of the NFT in the @param _collection.
     */
    function _redeemNft(Collection storage _collection, uint256 _id) private {
        require(
            _collection.payoutToken.balanceOf(address(this)) >=
                _collection.price,
            "Not enough tokens in the contract"
        );
        if (!_collection.allowAll) {
            _collection.allowed[_id] = false;
            _deleteIdFromCollection(_collection, _id);
        }
        _collection.collectionAddress.transferFrom(
            msg.sender,
            nftReceiver,
            _id
        );
        _collection.payoutToken.safeTransfer(msg.sender, _collection.price);
        emit Redeemed(_collection.collectionAddress, _id, msg.sender);
    }

    /**
     * @dev Deletes id from collection metadata
     *
     * @param _collection Collection struct from `collections` list.
     * @param _id Id of the NFT in the @param _collection.
     */
    function _deleteIdFromCollection(
        Collection storage _collection,
        uint256 _id
    ) private {
        for (uint256 i = 0; i < _collection.allowedList.length; i++) {
            if (_collection.allowedList[i] == _id) {
                _collection.allowedList[i] = _collection.allowedList[
                    _collection.allowedList.length - 1
                ];
                _collection.allowedList.pop();
                break;
            }
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 3 of 11 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 4 of 11 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 5 of 11 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 6 of 11 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);

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

File 7 of 11 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

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

File 11 of 11 : INFTBuyer.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

/**
 * @title INFTBuyer
 * @author pbnather
 */

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface INFTBuyer {
    /* ============ Events ============ */

    event CollectionAdded(
        IERC721 indexed _collection,
        IERC20 _token,
        uint256 _price,
        uint256[] _ids
    );

    event CollectionIdsSet(
        IERC721 indexed _collection,
        uint256[] _ids,
        bool[] _allows
    );

    event CollectionAllowAllChanged(
        IERC721 indexed _collection,
        bool _allowAll
    );

    event CollectionPriceAndTokenChanged(
        IERC721 indexed _collection,
        uint256 _price,
        IERC20 _token
    );

    event NFTReceiverChanged(
        address indexed _oldNftReceiver,
        address indexed _newNftReceiver
    );

    event WithdrewTokens(IERC20 indexed _token, uint256 amount);

    event Redeemed(
        IERC721 indexed _collection,
        uint256 indexed _id,
        address indexed _user
    );

    /* ============ External Owner Functions ============ */

    /**
     * @notice Adds collection with specific ids, or all ids allowlisted.
     *
     * @dev If @param _allowAll is set to true, @param _ids has to be empty.
     * If @param _allowAll is set to false, @param _ids cannot be empty.
     *
     * @param _collection Address of ERC721 collection.
     * @param _ids List of allowlisted ids.
     * @param _allowAll Bool if all ids are allowlisted.
     * @param _token ERC20 token address that is paid for NFTs in the collection.
     * @param _price Price of the NFT in @param _token.
     */
    function addCollection(
        IERC721 _collection,
        uint256[] memory _ids,
        bool _allowAll,
        IERC20 _token,
        uint256 _price
    ) external;

    /**
     * @notice Set collection ids' state.
     *
     * @dev Collection's `allowAll` has to be false.
     *
     * @param _collection Address of ERC721 collection.
     * @param _ids List of collection ids.
     * @param _allows List of ids' allowed states in same order as @param _ids.
     */
    function setCollectionIds(
        IERC721 _collection,
        uint256[] memory _ids,
        bool[] memory _allows
    ) external;

    /**
     * @notice Set collection's `allowAll` state, if all ids are allowed.
     *
     * @dev Setting `allowAll` to true will clear `allowedList` and `allowed`.
     *
     * @param _collection Address of ERC721 collection.
     * @param _allowAll New `allowAll` state.
     */
    function setCollectionAllowAll(IERC721 _collection, bool _allowAll)
        external;

    /**
     * @notice Set collection's price per NFT and ERC20 token to payout.
     *
     * @param _collection Address of ERC721 collection.
     * @param _price Price of the NFT in @param _token.
     * @param _token ERC20 token address that is paid for NFTs in the collection.
     */
    function setCollectionPriceAndToken(
        IERC721 _collection,
        uint256 _price,
        IERC20 _token
    ) external;

    /**
     * @notice Set address that gets all the NFTs.
     *
     * @param _nftReceiver Address that gets all the NFTs.
     */
    function setNftReceiver(address _nftReceiver) external;

    /**
     * @notice Withdraws ERC20 token to the owner address.
     *
     * @param _token ERC20 token address to withdraw.
     */
    function withdrawTokens(IERC20 _token) external;

    /* ============ External Functions ============ */

    /**
     * @notice Redeem NFTs for the corresponding ERC20 tokens.
     *
     * @dev Will revert if any NFT won't redeem succesfully.
     *
     * @param _collection Address of ERC721 collection.
     * @param _ids List of ids to redeem.
     */
    function redeem(IERC721 _collection, uint256[] memory _ids) external;

    /* ============ External View Functions ============ */

    /**
     * @notice Returns length of the `collections` list.
     *
     * @dev First Collection is dummy one.
     *
     * @return length_ Length of the `collections` list.
     */
    function getCollectionsLength() external view returns (uint256 length_);

    /**
     * @notice Returns list of all collection addresses.
     *
     * @dev First dummy collection is ommited from the returned list.
     *
     * @return collections_ List of collection addresses.
     */
    function getAllCollectionAddresses()
        external
        view
        returns (address[] memory collections_);

    /**
     * @notice Returns all allowed ids from the given collection.
     *
     * @dev If @return allIds_ is true, all ids are allowed, and @return ids_ is empty.
     *
     * @param _collection Address of ERC721 collection.
     *
     * @return allIds_ Bool if all ids are allowlisted.
     * @return ids_ List of allowed ids.
     */
    function getAllowedCollectionIds(IERC721 _collection)
        external
        view
        returns (bool allIds_, uint256[] memory ids_);

    /**
     * @notice Returns price in ERC20 token for each NFT in the collection.
     *
     * @param _collection Address of ERC721 collection.
     *
     * @return token_ ERC20 token address that is paid for NFTs in the collection.
     * @return price_ Price of the NFT in @param _token.
     */
    function getCollectionPriceAndToken(IERC721 _collection)
        external
        view
        returns (IERC20 token_, uint256 price_);

    /**
     * @notice Returns if the given NFT id is allowlisted to redeem.
     *
     * @param _collection Address of ERC721 collection.
     * @param _id Id of the NFT in the @param _collection.
     *
     * @return allowed_ Bool if NFT with id @param _id is allowed.
     */
    function isNftAllowed(IERC721 _collection, uint256 _id)
        external
        view
        returns (bool allowed_);

    /**
     * @notice Returns list of NFT collection id's that the user has and are able to redeem.
     *
     * @dev Collection has to support IERC721Enumerable for this to work, otherwise it will revert.
     *
     * @param _collection Address of ERC721 collection.
     * @param _account User account address to check.
     *
     * @return ids_ List of collection IDs that the user has and that are allowed to redeem.
     */
    function getUserAllowedNfts(IERC721 _collection, address _account)
        external
        view
        returns (uint256[] memory ids_);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_nftReceiver","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"_collection","type":"address"},{"indexed":false,"internalType":"contract IERC20","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_price","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"_ids","type":"uint256[]"}],"name":"CollectionAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"_collection","type":"address"},{"indexed":false,"internalType":"bool","name":"_allowAll","type":"bool"}],"name":"CollectionAllowAllChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"_collection","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"indexed":false,"internalType":"bool[]","name":"_allows","type":"bool[]"}],"name":"CollectionIdsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"_collection","type":"address"},{"indexed":false,"internalType":"uint256","name":"_price","type":"uint256"},{"indexed":false,"internalType":"contract IERC20","name":"_token","type":"address"}],"name":"CollectionPriceAndTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_oldNftReceiver","type":"address"},{"indexed":true,"internalType":"address","name":"_newNftReceiver","type":"address"}],"name":"NFTReceiverChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC721","name":"_collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"_id","type":"uint256"},{"indexed":true,"internalType":"address","name":"_user","type":"address"}],"name":"Redeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrewTokens","type":"event"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"bool","name":"_allowAll","type":"bool"},{"internalType":"contract IERC20","name":"_token","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"addCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collectionIndexes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"collections","outputs":[{"internalType":"contract IERC721","name":"collectionAddress","type":"address"},{"internalType":"contract IERC20","name":"payoutToken","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bool","name":"allowAll","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllCollectionAddresses","outputs":[{"internalType":"address[]","name":"collections_","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"}],"name":"getAllowedCollectionIds","outputs":[{"internalType":"bool","name":"allIds_","type":"bool"},{"internalType":"uint256[]","name":"ids_","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"}],"name":"getCollectionPriceAndToken","outputs":[{"internalType":"contract IERC20","name":"token_","type":"address"},{"internalType":"uint256","name":"price_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCollectionsLength","outputs":[{"internalType":"uint256","name":"length_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"},{"internalType":"address","name":"_account","type":"address"}],"name":"getUserAllowedNfts","outputs":[{"internalType":"uint256[]","name":"ids_","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"isNftAllowed","outputs":[{"internalType":"bool","name":"allowed_","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"},{"internalType":"bool","name":"_allowAll","type":"bool"}],"name":"setCollectionAllowAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"bool[]","name":"_allows","type":"bool[]"}],"name":"setCollectionIds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"_collection","type":"address"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"contract IERC20","name":"_token","type":"address"}],"name":"setCollectionPriceAndToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftReceiver","type":"address"}],"name":"setNftReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_token","type":"address"}],"name":"withdrawTokens","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b50604051620025b1380380620025b18339810160408190526200003491620000d4565b6200003f3362000084565b6001600160a01b0381166200005357600080fd5b600380546001600160a01b0319166001600160a01b0392909216919091179055600180548101815560005262000106565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215620000e757600080fd5b81516001600160a01b0381168114620000ff57600080fd5b9392505050565b61249b80620001166000396000f3fe608060405234801561001057600080fd5b50600436106101215760003560e01c806380f56105116100ad578063d0086e5b11610071578063d0086e5b146102a9578063d2390aa2146102bc578063ddc690ac146102cf578063f2fde38b146102d7578063fdbda0ec146102ea57600080fd5b806380f561051461023c5780638866eb071461025f5780638da5cb5b14610272578063b02cdd8214610283578063b7a70d0d1461029657600080fd5b806340c637d3116100f457806340c637d3146101c157806349df728c146101ec5780634e60564a146101ff5780637014935e1461021f578063715018a61461023457600080fd5b806301be1feb1461012657806302f2d65d1461013b57806309e9bed51461016e578063343a4acc146101a0575b600080fd5b610139610134366004611f11565b61032a565b005b61015b610149366004611fe6565b60026020526000908152604090205481565b6040519081526020015b60405180910390f35b61018161017c366004611fe6565b610591565b604080516001600160a01b039093168352602083019190915201610165565b6101b36101ae366004611fe6565b61060f565b604051610165929190612045565b6003546101d4906001600160a01b031681565b6040516001600160a01b039091168152602001610165565b6101396101fa366004611fe6565b610738565b61021261020d366004612060565b6108b8565b6040516101659190612099565b610227610cff565b60405161016591906120ac565b610139610dd7565b61024f61024a3660046120f9565b610deb565b6040519015158152602001610165565b61013961026d366004612125565b610e8e565b6000546001600160a01b03166101d4565b6101396102913660046121a2565b611211565b6101396102a43660046121d0565b6113ad565b6101396102b7366004611fe6565b61150b565b6101396102ca366004612212565b61160b565b60015461015b565b6101396102e5366004611fe6565b61173a565b6102fd6102f8366004612262565b6117b3565b604080516001600160a01b0395861681529490931660208501529183015215156060820152608001610165565b6103326117fc565b6001600160a01b038316600090815260026020526040902054806103715760405162461bcd60e51b81526004016103689061227b565b60405180910390fd5b600060018281548110610386576103866122b2565b60009182526020909120600690910201600381015490915060ff1615156001036103f25760405162461bcd60e51b815260206004820152601e60248201527f436f6c6c656374696f6e20697320696e20616c6c416c6c6f77206d6f646500006044820152606401610368565b835160005b8181101561054557848181518110610411576104116122b2565b60200260200101511515836004016000888481518110610433576104336122b2565b60209081029190910181015182528101919091526040016000205460ff161515146105335784818151811061046a5761046a6122b2565b602002602001015183600401600088848151811061048a5761048a6122b2565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055508481815181106104c9576104c96122b2565b60200260200101511561051057826005018682815181106104ec576104ec6122b2565b60209081029190910181015182546001810184556000938452919092200155610533565b61053383878381518110610526576105266122b2565b6020026020010151611856565b8061053d816122de565b9150506103f7565b50856001600160a01b03167f5db82965a05586adafea4290daa132a39f3f34a2bd8adf4d52c795bbccb881d586866040516105819291906122f7565b60405180910390a2505050505050565b6001600160a01b0381166000908152600260205260408120548190806105c95760405162461bcd60e51b81526004016103689061227b565b6000600182815481106105de576105de6122b2565b6000918252602090912060069091020160018101546002909101546001600160a01b03909116969095509350505050565b6001600160a01b038116600090815260026020526040812054606090806106485760405162461bcd60e51b81526004016103689061227b565b60006001828154811061065d5761065d6122b2565b60009182526020909120600690910201600381015490915060ff16156106865760019350610731565b6005810154600094508067ffffffffffffffff8111156106a8576106a8611e2d565b6040519080825280602002602001820160405280156106d1578160200160208202803683370190505b50935060005b8181101561072e578260050181815481106106f4576106f46122b2565b9060005260206000200154858281518110610711576107116122b2565b602090810291909101015280610726816122de565b9150506106d7565b50505b5050915091565b6107406117fc565b6001600160a01b03811661078e5760405162461bcd60e51b8152602060048201526015602482015274546f6b656e2069732061646472657373207a65726f60581b6044820152606401610368565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156107d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f99190612350565b90506000811161084b5760405162461bcd60e51b815260206004820152601b60248201527f43616e6e6f74207769746864726177207a65726f20746f6b656e7300000000006044820152606401610368565b6108716108606000546001600160a01b031690565b6001600160a01b038416908361191e565b816001600160a01b03167fc7373a0f64b3fe06c2144779575ea56ae879f4d815db065edd84fa72d744f128826040516108ac91815260200190565b60405180910390a25050565b6001600160a01b038216600090815260026020526040902054606090806108f15760405162461bcd60e51b81526004016103689061227b565b600060018281548110610906576109066122b2565b6000918252602082206040516370a0823160e01b81526001600160a01b0388811660048301526006939093029091019350908716906370a0823190602401602060405180830381865afa158015610961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109859190612350565b9050806000036109a95750506040805160008152602081019091529150610cf99050565b6040516301ffc9a760e01b815263780e9d6360e01b60048201526001600160a01b038716906301ffc9a790602401602060405180830381865afa1580156109f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a189190612369565b610a645760405162461bcd60e51b815260206004820181905260248201527f436f6c6c656374696f6e206e6f742049455243373231456e756d657261626c656044820152606401610368565b8560008267ffffffffffffffff811115610a8057610a80611e2d565b604051908082528060200260200182016040528015610aa9578160200160208202803683370190505b50600385015490915060ff1615610b725760005b83811015610b6557604051632f745c5960e01b81526001600160a01b03898116600483015260248201839052841690632f745c5990604401602060405180830381865afa158015610b12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b369190612350565b828281518110610b4857610b486122b2565b602090810291909101015280610b5d816122de565b915050610abd565b509450610cf99350505050565b6000805b84811015610c4e57604051632f745c5960e01b81526001600160a01b038a811660048301526024820183905260009190861690632f745c5990604401602060405180830381865afa158015610bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf39190612350565b600081815260048901602052604090205490915060ff1615610c3b5780848481518110610c2257610c226122b2565b6020908102919091010152610c38600184612386565b92505b5080610c46816122de565b915050610b76565b5060008167ffffffffffffffff811115610c6a57610c6a611e2d565b604051908082528060200260200182016040528015610c93578160200160208202803683370190505b50905060005b82811015610cea57838181518110610cb357610cb36122b2565b6020026020010151828281518110610ccd57610ccd6122b2565b602090810291909101015280610ce2816122de565b915050610c99565b509650610cf995505050505050565b92915050565b60018054606091610d109082612399565b67ffffffffffffffff811115610d2857610d28611e2d565b604051908082528060200260200182016040528015610d51578160200160208202803683370190505b50915060015b81811015610dd25760018181548110610d7257610d726122b2565b60009182526020909120600690910201546001600160a01b031683610d98600184612399565b81518110610da857610da86122b2565b6001600160a01b039092166020928302919091019091015280610dca816122de565b915050610d57565b505090565b610ddf6117fc565b610de96000611970565b565b6001600160a01b03821660009081526002602052604081205480610e215760405162461bcd60e51b81526004016103689061227b565b600060018281548110610e3657610e366122b2565b60009182526020909120600690910201600381015490915060ff1615610e5f5760019250610e86565b600084815260048201602052604090205460ff1615610e815760019250610e86565b600092505b505092915050565b610e966117fc565b83518315610ef1578015610eec5760405162461bcd60e51b815260206004820181905260248201527f5f616c6c6f77416c6c20697320747275652c20646f6e277420616464206964736044820152606401610368565b610f41565b60008111610f415760405162461bcd60e51b815260206004820152601f60248201527f5f616c6c6f77416c6c2069732066616c73652c207370656369667920696473006044820152606401610368565b6001600160a01b038316610f8c5760405162461bcd60e51b8152602060048201526012602482015271546f6b656e2061646472657373207a65726f60701b6044820152606401610368565b6001600160a01b038616610fe25760405162461bcd60e51b815260206004820152601760248201527f436f6c6c656374696f6e2061646472657373207a65726f0000000000000000006044820152606401610368565b6001600160a01b038616600090815260026020526040902054156110485760405162461bcd60e51b815260206004820152601960248201527f436f6c6c656374696f6e20616c726561647920657869737473000000000000006044820152606401610368565b600082116110885760405162461bcd60e51b815260206004820152600d60248201526c5072696365206973207a65726f60981b6044820152606401610368565b6001805481018082556000828152916110a091612399565b6001600160a01b0388166000908152600260205260408120829055600180549293509091839081106110d4576110d46122b2565b60009182526020822060069091020180546001600160a01b03808c166001600160a01b0319928316178355600183018054918a16919092161790556002810186905560038101805489151560ff1990911617905591505b838110156111c15760018260040160008a848151811061114d5761114d6122b2565b6020026020010151815260200190815260200160002060006101000a81548160ff02191690831515021790555081600501888281518110611190576111906122b2565b60209081029190910181015182546001810184556000938452919092200155806111b9816122de565b91505061112b565b50876001600160a01b03167fa4f05799781e569452e4805b7766d5ebb28f343f1665d3c3ebae084b21412f9786868a6040516111ff939291906123ac565b60405180910390a25050505050505050565b6112196117fc565b6001600160a01b0382166000908152600260205260409020548061124f5760405162461bcd60e51b81526004016103689061227b565b600060018281548110611264576112646122b2565b906000526020600020906006020190508215158160030160009054906101000a900460ff161515036112c85760405162461bcd60e51b815260206004820152600d60248201526c53746174652069732073616d6560981b6044820152606401610368565b60038101805460ff1916841580159190911790915561136257600581015460005b8181101561135157600083600401600085600501848154811061130e5761130e6122b2565b9060005260206000200154815260200190815260200160002060006101000a81548160ff0219169083151502179055508080611349906122de565b9150506112e9565b50611360600583016000611de6565b505b836001600160a01b03167fdadf9376bd8d207214a10873332ab062e5dee4b208ed70ddc5090939733aa2f28460405161139f911515815260200190565b60405180910390a250505050565b6113b56117fc565b6001600160a01b038316600090815260026020526040902054806113eb5760405162461bcd60e51b81526004016103689061227b565b600060018281548110611400576114006122b2565b90600052602060002090600602019050600084116114505760405162461bcd60e51b815260206004820152600d60248201526c5072696365206973207a65726f60981b6044820152606401610368565b6001600160a01b03831661149e5760405162461bcd60e51b8152602060048201526015602482015274546f6b656e2069732061646472657373207a65726f60581b6044820152606401610368565b600281018490556001810180546001600160a01b0319166001600160a01b03858116918217909255604080518781526020810192909252918716917fc7d671074a1e043497d3ee896cf3bf4d732813a271b9945996f4a009ad45f3f5910160405180910390a25050505050565b6115136117fc565b6001600160a01b0381166115695760405162461bcd60e51b815260206004820152601b60248201527f4e657720616464726573732069732061646472657373207a65726f00000000006044820152606401610368565b6003546001600160a01b03908116908216036115b95760405162461bcd60e51b815260206004820152600f60248201526e416464726573732069732073616d6560881b6044820152606401610368565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907fe0f366a85198edee1222e726e5fe9ed5060df3361ed0ef8eae5b79e92afca20c90600090a35050565b6001600160a01b038216600090815260026020526040902054806116415760405162461bcd60e51b81526004016103689061227b565b600060018281548110611656576116566122b2565b9060005260206000209060060201905060005b835181101561173357600382015460ff16806116b75750816004016000858381518110611698576116986122b2565b60209081029190910181015182528101919091526040016000205460ff165b156116e4576116df828583815181106116d2576116d26122b2565b60200260200101516119c0565b611721565b60405162461bcd60e51b8152602060048201526012602482015271139195081a5cc81b9bdd08185b1b1bddd95960721b6044820152606401610368565b8061172b816122de565b915050611669565b5050505050565b6117426117fc565b6001600160a01b0381166117a75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610368565b6117b081611970565b50565b600181815481106117c357600080fd5b600091825260209091206006909102018054600182015460028301546003909301546001600160a01b0392831694509116919060ff1684565b6000546001600160a01b03163314610de95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610368565b60005b6005830154811015611919578183600501828154811061187b5761187b6122b2565b9060005260206000200154036119075760058301805461189d90600190612399565b815481106118ad576118ad6122b2565b90600052602060002001548360050182815481106118cd576118cd6122b2565b600091825260209091200155600583018054806118ec576118ec6123dc565b60019003818190600052602060002001600090559055505050565b80611911816122de565b915050611859565b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611919908490611b84565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600282015460018301546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611a0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a339190612350565b1015611a8b5760405162461bcd60e51b815260206004820152602160248201527f4e6f7420656e6f75676820746f6b656e7320696e2074686520636f6e747261636044820152601d60fa1b6064820152608401610368565b600382015460ff16611ab95760008181526004830160205260409020805460ff19169055611ab98282611856565b81546003546040516323b872dd60e01b81523360048201526001600160a01b039182166024820152604481018490529116906323b872dd90606401600060405180830381600087803b158015611b0e57600080fd5b505af1158015611b22573d6000803e3d6000fd5b50505060028301546001840154611b4592506001600160a01b031690339061191e565b8154604051339183916001600160a01b03909116907f753fa485a7db01b79a5bf240795c914378b8fb5fcb2a848f2acd51aa6804adbf90600090a45050565b6000611bd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611c569092919063ffffffff16565b8051909150156119195780806020019051810190611bf79190612369565b6119195760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610368565b6060611c658484600085611c6d565b949350505050565b606082471015611cce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610368565b600080866001600160a01b03168587604051611cea9190612416565b60006040518083038185875af1925050503d8060008114611d27576040519150601f19603f3d011682016040523d82523d6000602084013e611d2c565b606091505b5091509150611d3d87838387611d48565b979650505050505050565b60608315611db7578251600003611db0576001600160a01b0385163b611db05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610368565b5081611c65565b611c658383815115611dcc5781518083602001fd5b8060405162461bcd60e51b81526004016103689190612432565b50805460008255906000526020600020908101906117b091905b80821115611e145760008155600101611e00565b5090565b6001600160a01b03811681146117b057600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611e6c57611e6c611e2d565b604052919050565b600067ffffffffffffffff821115611e8e57611e8e611e2d565b5060051b60200190565b600082601f830112611ea957600080fd5b81356020611ebe611eb983611e74565b611e43565b82815260059290921b84018101918181019086841115611edd57600080fd5b8286015b84811015611ef85780358352918301918301611ee1565b509695505050505050565b80151581146117b057600080fd5b600080600060608486031215611f2657600080fd5b8335611f3181611e18565b925060208481013567ffffffffffffffff80821115611f4f57600080fd5b611f5b88838901611e98565b94506040870135915080821115611f7157600080fd5b508501601f81018713611f8357600080fd5b8035611f91611eb982611e74565b81815260059190911b82018301908381019089831115611fb057600080fd5b928401925b82841015611fd7578335611fc881611f03565b82529284019290840190611fb5565b80955050505050509250925092565b600060208284031215611ff857600080fd5b813561200381611e18565b9392505050565b600081518084526020808501945080840160005b8381101561203a5781518752958201959082019060010161201e565b509495945050505050565b8215158152604060208201526000611c65604083018461200a565b6000806040838503121561207357600080fd5b823561207e81611e18565b9150602083013561208e81611e18565b809150509250929050565b602081526000612003602083018461200a565b6020808252825182820181905260009190848201906040850190845b818110156120ed5783516001600160a01b0316835292840192918401916001016120c8565b50909695505050505050565b6000806040838503121561210c57600080fd5b823561211781611e18565b946020939093013593505050565b600080600080600060a0868803121561213d57600080fd5b853561214881611e18565b9450602086013567ffffffffffffffff81111561216457600080fd5b61217088828901611e98565b945050604086013561218181611f03565b9250606086013561219181611e18565b949793965091946080013592915050565b600080604083850312156121b557600080fd5b82356121c081611e18565b9150602083013561208e81611f03565b6000806000606084860312156121e557600080fd5b83356121f081611e18565b925060208401359150604084013561220781611e18565b809150509250925092565b6000806040838503121561222557600080fd5b823561223081611e18565b9150602083013567ffffffffffffffff81111561224c57600080fd5b61225885828601611e98565b9150509250929050565b60006020828403121561227457600080fd5b5035919050565b60208082526018908201527f436f6c6c656374696f6e20646f65736e27742065786973740000000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016122f0576122f06122c8565b5060010190565b60408152600061230a604083018561200a565b82810360208481019190915284518083528582019282019060005b81811015612343578451151583529383019391830191600101612325565b5090979650505050505050565b60006020828403121561236257600080fd5b5051919050565b60006020828403121561237b57600080fd5b815161200381611f03565b80820180821115610cf957610cf96122c8565b81810381811115610cf957610cf96122c8565b60018060a01b03841681528260208201526060604082015260006123d3606083018461200a565b95945050505050565b634e487b7160e01b600052603160045260246000fd5b60005b8381101561240d5781810151838201526020016123f5565b50506000910152565b600082516124288184602087016123f2565b9190910192915050565b60208152600082518060208401526124518160408501602087016123f2565b601f01601f1916919091016040019291505056fea2646970667358221220324b33b5e6c623c2e4c71c2555a06243437571e79d576732b2d31203acb6b81764736f6c63430008110033000000000000000000000000587a87e705c784d9ad37ab193c04e5ad39178bcf

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101215760003560e01c806380f56105116100ad578063d0086e5b11610071578063d0086e5b146102a9578063d2390aa2146102bc578063ddc690ac146102cf578063f2fde38b146102d7578063fdbda0ec146102ea57600080fd5b806380f561051461023c5780638866eb071461025f5780638da5cb5b14610272578063b02cdd8214610283578063b7a70d0d1461029657600080fd5b806340c637d3116100f457806340c637d3146101c157806349df728c146101ec5780634e60564a146101ff5780637014935e1461021f578063715018a61461023457600080fd5b806301be1feb1461012657806302f2d65d1461013b57806309e9bed51461016e578063343a4acc146101a0575b600080fd5b610139610134366004611f11565b61032a565b005b61015b610149366004611fe6565b60026020526000908152604090205481565b6040519081526020015b60405180910390f35b61018161017c366004611fe6565b610591565b604080516001600160a01b039093168352602083019190915201610165565b6101b36101ae366004611fe6565b61060f565b604051610165929190612045565b6003546101d4906001600160a01b031681565b6040516001600160a01b039091168152602001610165565b6101396101fa366004611fe6565b610738565b61021261020d366004612060565b6108b8565b6040516101659190612099565b610227610cff565b60405161016591906120ac565b610139610dd7565b61024f61024a3660046120f9565b610deb565b6040519015158152602001610165565b61013961026d366004612125565b610e8e565b6000546001600160a01b03166101d4565b6101396102913660046121a2565b611211565b6101396102a43660046121d0565b6113ad565b6101396102b7366004611fe6565b61150b565b6101396102ca366004612212565b61160b565b60015461015b565b6101396102e5366004611fe6565b61173a565b6102fd6102f8366004612262565b6117b3565b604080516001600160a01b0395861681529490931660208501529183015215156060820152608001610165565b6103326117fc565b6001600160a01b038316600090815260026020526040902054806103715760405162461bcd60e51b81526004016103689061227b565b60405180910390fd5b600060018281548110610386576103866122b2565b60009182526020909120600690910201600381015490915060ff1615156001036103f25760405162461bcd60e51b815260206004820152601e60248201527f436f6c6c656374696f6e20697320696e20616c6c416c6c6f77206d6f646500006044820152606401610368565b835160005b8181101561054557848181518110610411576104116122b2565b60200260200101511515836004016000888481518110610433576104336122b2565b60209081029190910181015182528101919091526040016000205460ff161515146105335784818151811061046a5761046a6122b2565b602002602001015183600401600088848151811061048a5761048a6122b2565b6020026020010151815260200190815260200160002060006101000a81548160ff0219169083151502179055508481815181106104c9576104c96122b2565b60200260200101511561051057826005018682815181106104ec576104ec6122b2565b60209081029190910181015182546001810184556000938452919092200155610533565b61053383878381518110610526576105266122b2565b6020026020010151611856565b8061053d816122de565b9150506103f7565b50856001600160a01b03167f5db82965a05586adafea4290daa132a39f3f34a2bd8adf4d52c795bbccb881d586866040516105819291906122f7565b60405180910390a2505050505050565b6001600160a01b0381166000908152600260205260408120548190806105c95760405162461bcd60e51b81526004016103689061227b565b6000600182815481106105de576105de6122b2565b6000918252602090912060069091020160018101546002909101546001600160a01b03909116969095509350505050565b6001600160a01b038116600090815260026020526040812054606090806106485760405162461bcd60e51b81526004016103689061227b565b60006001828154811061065d5761065d6122b2565b60009182526020909120600690910201600381015490915060ff16156106865760019350610731565b6005810154600094508067ffffffffffffffff8111156106a8576106a8611e2d565b6040519080825280602002602001820160405280156106d1578160200160208202803683370190505b50935060005b8181101561072e578260050181815481106106f4576106f46122b2565b9060005260206000200154858281518110610711576107116122b2565b602090810291909101015280610726816122de565b9150506106d7565b50505b5050915091565b6107406117fc565b6001600160a01b03811661078e5760405162461bcd60e51b8152602060048201526015602482015274546f6b656e2069732061646472657373207a65726f60581b6044820152606401610368565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156107d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f99190612350565b90506000811161084b5760405162461bcd60e51b815260206004820152601b60248201527f43616e6e6f74207769746864726177207a65726f20746f6b656e7300000000006044820152606401610368565b6108716108606000546001600160a01b031690565b6001600160a01b038416908361191e565b816001600160a01b03167fc7373a0f64b3fe06c2144779575ea56ae879f4d815db065edd84fa72d744f128826040516108ac91815260200190565b60405180910390a25050565b6001600160a01b038216600090815260026020526040902054606090806108f15760405162461bcd60e51b81526004016103689061227b565b600060018281548110610906576109066122b2565b6000918252602082206040516370a0823160e01b81526001600160a01b0388811660048301526006939093029091019350908716906370a0823190602401602060405180830381865afa158015610961573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109859190612350565b9050806000036109a95750506040805160008152602081019091529150610cf99050565b6040516301ffc9a760e01b815263780e9d6360e01b60048201526001600160a01b038716906301ffc9a790602401602060405180830381865afa1580156109f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a189190612369565b610a645760405162461bcd60e51b815260206004820181905260248201527f436f6c6c656374696f6e206e6f742049455243373231456e756d657261626c656044820152606401610368565b8560008267ffffffffffffffff811115610a8057610a80611e2d565b604051908082528060200260200182016040528015610aa9578160200160208202803683370190505b50600385015490915060ff1615610b725760005b83811015610b6557604051632f745c5960e01b81526001600160a01b03898116600483015260248201839052841690632f745c5990604401602060405180830381865afa158015610b12573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b369190612350565b828281518110610b4857610b486122b2565b602090810291909101015280610b5d816122de565b915050610abd565b509450610cf99350505050565b6000805b84811015610c4e57604051632f745c5960e01b81526001600160a01b038a811660048301526024820183905260009190861690632f745c5990604401602060405180830381865afa158015610bcf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bf39190612350565b600081815260048901602052604090205490915060ff1615610c3b5780848481518110610c2257610c226122b2565b6020908102919091010152610c38600184612386565b92505b5080610c46816122de565b915050610b76565b5060008167ffffffffffffffff811115610c6a57610c6a611e2d565b604051908082528060200260200182016040528015610c93578160200160208202803683370190505b50905060005b82811015610cea57838181518110610cb357610cb36122b2565b6020026020010151828281518110610ccd57610ccd6122b2565b602090810291909101015280610ce2816122de565b915050610c99565b509650610cf995505050505050565b92915050565b60018054606091610d109082612399565b67ffffffffffffffff811115610d2857610d28611e2d565b604051908082528060200260200182016040528015610d51578160200160208202803683370190505b50915060015b81811015610dd25760018181548110610d7257610d726122b2565b60009182526020909120600690910201546001600160a01b031683610d98600184612399565b81518110610da857610da86122b2565b6001600160a01b039092166020928302919091019091015280610dca816122de565b915050610d57565b505090565b610ddf6117fc565b610de96000611970565b565b6001600160a01b03821660009081526002602052604081205480610e215760405162461bcd60e51b81526004016103689061227b565b600060018281548110610e3657610e366122b2565b60009182526020909120600690910201600381015490915060ff1615610e5f5760019250610e86565b600084815260048201602052604090205460ff1615610e815760019250610e86565b600092505b505092915050565b610e966117fc565b83518315610ef1578015610eec5760405162461bcd60e51b815260206004820181905260248201527f5f616c6c6f77416c6c20697320747275652c20646f6e277420616464206964736044820152606401610368565b610f41565b60008111610f415760405162461bcd60e51b815260206004820152601f60248201527f5f616c6c6f77416c6c2069732066616c73652c207370656369667920696473006044820152606401610368565b6001600160a01b038316610f8c5760405162461bcd60e51b8152602060048201526012602482015271546f6b656e2061646472657373207a65726f60701b6044820152606401610368565b6001600160a01b038616610fe25760405162461bcd60e51b815260206004820152601760248201527f436f6c6c656374696f6e2061646472657373207a65726f0000000000000000006044820152606401610368565b6001600160a01b038616600090815260026020526040902054156110485760405162461bcd60e51b815260206004820152601960248201527f436f6c6c656374696f6e20616c726561647920657869737473000000000000006044820152606401610368565b600082116110885760405162461bcd60e51b815260206004820152600d60248201526c5072696365206973207a65726f60981b6044820152606401610368565b6001805481018082556000828152916110a091612399565b6001600160a01b0388166000908152600260205260408120829055600180549293509091839081106110d4576110d46122b2565b60009182526020822060069091020180546001600160a01b03808c166001600160a01b0319928316178355600183018054918a16919092161790556002810186905560038101805489151560ff1990911617905591505b838110156111c15760018260040160008a848151811061114d5761114d6122b2565b6020026020010151815260200190815260200160002060006101000a81548160ff02191690831515021790555081600501888281518110611190576111906122b2565b60209081029190910181015182546001810184556000938452919092200155806111b9816122de565b91505061112b565b50876001600160a01b03167fa4f05799781e569452e4805b7766d5ebb28f343f1665d3c3ebae084b21412f9786868a6040516111ff939291906123ac565b60405180910390a25050505050505050565b6112196117fc565b6001600160a01b0382166000908152600260205260409020548061124f5760405162461bcd60e51b81526004016103689061227b565b600060018281548110611264576112646122b2565b906000526020600020906006020190508215158160030160009054906101000a900460ff161515036112c85760405162461bcd60e51b815260206004820152600d60248201526c53746174652069732073616d6560981b6044820152606401610368565b60038101805460ff1916841580159190911790915561136257600581015460005b8181101561135157600083600401600085600501848154811061130e5761130e6122b2565b9060005260206000200154815260200190815260200160002060006101000a81548160ff0219169083151502179055508080611349906122de565b9150506112e9565b50611360600583016000611de6565b505b836001600160a01b03167fdadf9376bd8d207214a10873332ab062e5dee4b208ed70ddc5090939733aa2f28460405161139f911515815260200190565b60405180910390a250505050565b6113b56117fc565b6001600160a01b038316600090815260026020526040902054806113eb5760405162461bcd60e51b81526004016103689061227b565b600060018281548110611400576114006122b2565b90600052602060002090600602019050600084116114505760405162461bcd60e51b815260206004820152600d60248201526c5072696365206973207a65726f60981b6044820152606401610368565b6001600160a01b03831661149e5760405162461bcd60e51b8152602060048201526015602482015274546f6b656e2069732061646472657373207a65726f60581b6044820152606401610368565b600281018490556001810180546001600160a01b0319166001600160a01b03858116918217909255604080518781526020810192909252918716917fc7d671074a1e043497d3ee896cf3bf4d732813a271b9945996f4a009ad45f3f5910160405180910390a25050505050565b6115136117fc565b6001600160a01b0381166115695760405162461bcd60e51b815260206004820152601b60248201527f4e657720616464726573732069732061646472657373207a65726f00000000006044820152606401610368565b6003546001600160a01b03908116908216036115b95760405162461bcd60e51b815260206004820152600f60248201526e416464726573732069732073616d6560881b6044820152606401610368565b600380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907fe0f366a85198edee1222e726e5fe9ed5060df3361ed0ef8eae5b79e92afca20c90600090a35050565b6001600160a01b038216600090815260026020526040902054806116415760405162461bcd60e51b81526004016103689061227b565b600060018281548110611656576116566122b2565b9060005260206000209060060201905060005b835181101561173357600382015460ff16806116b75750816004016000858381518110611698576116986122b2565b60209081029190910181015182528101919091526040016000205460ff165b156116e4576116df828583815181106116d2576116d26122b2565b60200260200101516119c0565b611721565b60405162461bcd60e51b8152602060048201526012602482015271139195081a5cc81b9bdd08185b1b1bddd95960721b6044820152606401610368565b8061172b816122de565b915050611669565b5050505050565b6117426117fc565b6001600160a01b0381166117a75760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610368565b6117b081611970565b50565b600181815481106117c357600080fd5b600091825260209091206006909102018054600182015460028301546003909301546001600160a01b0392831694509116919060ff1684565b6000546001600160a01b03163314610de95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610368565b60005b6005830154811015611919578183600501828154811061187b5761187b6122b2565b9060005260206000200154036119075760058301805461189d90600190612399565b815481106118ad576118ad6122b2565b90600052602060002001548360050182815481106118cd576118cd6122b2565b600091825260209091200155600583018054806118ec576118ec6123dc565b60019003818190600052602060002001600090559055505050565b80611911816122de565b915050611859565b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611919908490611b84565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600282015460018301546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015611a0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a339190612350565b1015611a8b5760405162461bcd60e51b815260206004820152602160248201527f4e6f7420656e6f75676820746f6b656e7320696e2074686520636f6e747261636044820152601d60fa1b6064820152608401610368565b600382015460ff16611ab95760008181526004830160205260409020805460ff19169055611ab98282611856565b81546003546040516323b872dd60e01b81523360048201526001600160a01b039182166024820152604481018490529116906323b872dd90606401600060405180830381600087803b158015611b0e57600080fd5b505af1158015611b22573d6000803e3d6000fd5b50505060028301546001840154611b4592506001600160a01b031690339061191e565b8154604051339183916001600160a01b03909116907f753fa485a7db01b79a5bf240795c914378b8fb5fcb2a848f2acd51aa6804adbf90600090a45050565b6000611bd9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611c569092919063ffffffff16565b8051909150156119195780806020019051810190611bf79190612369565b6119195760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610368565b6060611c658484600085611c6d565b949350505050565b606082471015611cce5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610368565b600080866001600160a01b03168587604051611cea9190612416565b60006040518083038185875af1925050503d8060008114611d27576040519150601f19603f3d011682016040523d82523d6000602084013e611d2c565b606091505b5091509150611d3d87838387611d48565b979650505050505050565b60608315611db7578251600003611db0576001600160a01b0385163b611db05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610368565b5081611c65565b611c658383815115611dcc5781518083602001fd5b8060405162461bcd60e51b81526004016103689190612432565b50805460008255906000526020600020908101906117b091905b80821115611e145760008155600101611e00565b5090565b6001600160a01b03811681146117b057600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611e6c57611e6c611e2d565b604052919050565b600067ffffffffffffffff821115611e8e57611e8e611e2d565b5060051b60200190565b600082601f830112611ea957600080fd5b81356020611ebe611eb983611e74565b611e43565b82815260059290921b84018101918181019086841115611edd57600080fd5b8286015b84811015611ef85780358352918301918301611ee1565b509695505050505050565b80151581146117b057600080fd5b600080600060608486031215611f2657600080fd5b8335611f3181611e18565b925060208481013567ffffffffffffffff80821115611f4f57600080fd5b611f5b88838901611e98565b94506040870135915080821115611f7157600080fd5b508501601f81018713611f8357600080fd5b8035611f91611eb982611e74565b81815260059190911b82018301908381019089831115611fb057600080fd5b928401925b82841015611fd7578335611fc881611f03565b82529284019290840190611fb5565b80955050505050509250925092565b600060208284031215611ff857600080fd5b813561200381611e18565b9392505050565b600081518084526020808501945080840160005b8381101561203a5781518752958201959082019060010161201e565b509495945050505050565b8215158152604060208201526000611c65604083018461200a565b6000806040838503121561207357600080fd5b823561207e81611e18565b9150602083013561208e81611e18565b809150509250929050565b602081526000612003602083018461200a565b6020808252825182820181905260009190848201906040850190845b818110156120ed5783516001600160a01b0316835292840192918401916001016120c8565b50909695505050505050565b6000806040838503121561210c57600080fd5b823561211781611e18565b946020939093013593505050565b600080600080600060a0868803121561213d57600080fd5b853561214881611e18565b9450602086013567ffffffffffffffff81111561216457600080fd5b61217088828901611e98565b945050604086013561218181611f03565b9250606086013561219181611e18565b949793965091946080013592915050565b600080604083850312156121b557600080fd5b82356121c081611e18565b9150602083013561208e81611f03565b6000806000606084860312156121e557600080fd5b83356121f081611e18565b925060208401359150604084013561220781611e18565b809150509250925092565b6000806040838503121561222557600080fd5b823561223081611e18565b9150602083013567ffffffffffffffff81111561224c57600080fd5b61225885828601611e98565b9150509250929050565b60006020828403121561227457600080fd5b5035919050565b60208082526018908201527f436f6c6c656374696f6e20646f65736e27742065786973740000000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016122f0576122f06122c8565b5060010190565b60408152600061230a604083018561200a565b82810360208481019190915284518083528582019282019060005b81811015612343578451151583529383019391830191600101612325565b5090979650505050505050565b60006020828403121561236257600080fd5b5051919050565b60006020828403121561237b57600080fd5b815161200381611f03565b80820180821115610cf957610cf96122c8565b81810381811115610cf957610cf96122c8565b60018060a01b03841681528260208201526060604082015260006123d3606083018461200a565b95945050505050565b634e487b7160e01b600052603160045260246000fd5b60005b8381101561240d5781810151838201526020016123f5565b50506000910152565b600082516124288184602087016123f2565b9190910192915050565b60208152600082518060208401526124518160408501602087016123f2565b601f01601f1916919091016040019291505056fea2646970667358221220324b33b5e6c623c2e4c71c2555a06243437571e79d576732b2d31203acb6b81764736f6c63430008110033

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

000000000000000000000000587a87e705c784d9ad37ab193c04e5ad39178bcf

-----Decoded View---------------
Arg [0] : _nftReceiver (address): 0x587A87E705C784D9aD37Ab193c04e5aD39178BCF

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000587a87e705c784d9ad37ab193c04e5ad39178bcf


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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