APE Price: $0.72 (-3.98%)

Contract

0x4CE5A72DCa54A1EC71f5c9b8101C7eBC4d34d9e5

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0 APE

APE Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
TieredNFTBurn

Compiler Version
v0.8.27+commit.40a35a09

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 3 : TieredNFTBurn.sol
// contracts/TieredNFTBurn.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/**
 * @title TieredNFTBurn
 * @dev A contract that allows users to "burn" NFTs by sending them to the null address.
 *      Users are rewarded with tiers based on the number of NFTs they burn.
 *      Tier 1: Burn 25 or more NFTs
 *      Tier 2: Burn 15-24 NFTs
 *      Tier 3: Burn 5-14 NFTs
 * @author jojoracky Rizz @github chimmykk 
 */
contract TieredNFTBurn {
    IERC721 public nftToken;
    address public constant burnAddress = address(0);

    // Mapping to track total NFTs burned by each address
    mapping(address => uint256) public burnCount;
    // Mapping to track assigned tier for each address
    mapping(address => uint8) public tier;

    // Tier thresholds for each reward level
    uint256 public constant TIER_1_THRESHOLD = 25;
    uint256 public constant TIER_2_THRESHOLD = 15;
    uint256 public constant TIER_3_THRESHOLD = 5;

    // Events for tracking burns and tier assignments
    event Burn(address indexed user, uint256 tokenId);
    event TierAssigned(address indexed user, uint8 tier);

    /**
     * @dev Initializes the contract with the NFT contract address.
     * @param _nftTokenAddress The address of the NFT contract.
     */
    constructor(address _nftTokenAddress) {
        nftToken = IERC721(_nftTokenAddress);
    }

    /**
     * @dev Allows a user to burn multiple NFTs by transferring them to the null address.
     *      Also updates the user's burn count and assigns a tier based on the total NFTs burned.
     * @param tokenIds An array of token IDs to be burned.
     *
     * Requirements:
     * - `msg.sender` must own each token ID in `tokenIds`.
     */
    function burn(uint256[] calldata tokenIds) external {
        uint256 amount = tokenIds.length;
        require(amount > 0, "Must burn at least one token");

        for (uint256 i = 0; i < amount; i++) {
            uint256 tokenId = tokenIds[i];
            // Verify ownership of the token before transferring to burn address
            require(nftToken.ownerOf(tokenId) == msg.sender, "Not the owner of this token");

            // Transfer the NFT to the burn address (null address) to "burn" it
            nftToken.transferFrom(msg.sender, burnAddress, tokenId);
            emit Burn(msg.sender, tokenId);
        }

        // Update the user's burn count
        burnCount[msg.sender] += amount;

        // Calculate the user's new tier based on the cumulative burn count
        uint8 newTier = 0;
        if (burnCount[msg.sender] >= TIER_1_THRESHOLD) {
            newTier = 1;
        } else if (burnCount[msg.sender] >= TIER_2_THRESHOLD) {
            newTier = 2;
        } else if (burnCount[msg.sender] >= TIER_3_THRESHOLD) {
            newTier = 3;
        }

        // Update and emit new tier if it's different from the current tier
        if (newTier > 0 && newTier != tier[msg.sender]) {
            tier[msg.sender] = newTier;
            emit TierAssigned(msg.sender, newTier);
        }
    }

    /**
     * @dev Returns the tier level of a given user.
     * @param user The address of the user to query.
     * @return The tier level of the user.
     */
    function getUserTier(address user) external view returns (uint8) {
        return tier[user];
    }

    /**
     * @dev Returns the total number of NFTs burned by a given user.
     * @param user The address of the user to query.
     * @return The total burn count of the user.
     */
    function getUserBurnCount(address user) external view returns (uint256) {
        return burnCount[user];
    }
}

File 2 of 3 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-721 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 ERC-721 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 ERC-721
     * 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 address zero.
     *
     * 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 3 of 3 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * 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[ERC 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);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_nftTokenAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint8","name":"tier","type":"uint8"}],"name":"TierAssigned","type":"event"},{"inputs":[],"name":"TIER_1_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TIER_2_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TIER_3_THRESHOLD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"burnCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserBurnCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserTier","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftToken","outputs":[{"internalType":"contract IERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tier","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"}]

6080604052348015600f57600080fd5b50604051610680380380610680833981016040819052602c916050565b600080546001600160a01b0319166001600160a01b0392909216919091179055607e565b600060208284031215606157600080fd5b81516001600160a01b0381168114607757600080fd5b9392505050565b6105f38061008d6000396000f3fe608060405234801561001057600080fd5b506004361061009d5760003560e01c8063b80f55c911610066578063b80f55c91461015b578063cb9ea33714610170578063d06fcba814610178578063e4d2620e1461018b578063ef2f90cf146101b757600080fd5b8062bb6e92146100a257806315889e43146100bd5780631f5c20ec146100dd5780632785f8bb1461010657806370d5ae051461013b575b600080fd5b6100aa600581565b6040519081526020015b60405180910390f35b6100aa6100cb3660046104c8565b60016020526000908152604090205481565b6100aa6100eb3660046104c8565b6001600160a01b031660009081526001602052604090205490565b6101296101143660046104c8565b60026020526000908152604090205460ff1681565b60405160ff90911681526020016100b4565b610143600081565b6040516001600160a01b0390911681526020016100b4565b61016e6101693660046104ec565b6101bf565b005b6100aa600f81565b600054610143906001600160a01b031681565b6101296101993660046104c8565b6001600160a01b031660009081526002602052604090205460ff1690565b6100aa601981565b80806102125760405162461bcd60e51b815260206004820152601c60248201527f4d757374206275726e206174206c65617374206f6e6520746f6b656e0000000060448201526064015b60405180910390fd5b60005b818110156103ab57600084848381811061023157610231610563565b6000546040516331a9108f60e11b8152602092909202939093013560048201819052935033926001600160a01b03169150636352211e90602401602060405180830381865afa158015610288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ac9190610579565b6001600160a01b0316146103025760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420746865206f776e6572206f66207468697320746f6b656e00000000006044820152606401610209565b600080546040516323b872dd60e01b81523360048201526024810192909252604482018390526001600160a01b0316906323b872dd90606401600060405180830381600087803b15801561035557600080fd5b505af1158015610369573d6000803e3d6000fd5b50506040518381523392507fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5915060200160405180910390a250600101610215565b5033600090815260016020526040812080548392906103cb908490610596565b9091555050336000908152600160205260408120546019116103ef57506001610429565b33600090815260016020526040902054600f1161040e57506002610429565b33600090815260016020526040902054600511610429575060035b60008160ff1611801561045157503360009081526002602052604090205460ff828116911614155b156104aa5733600081815260026020908152604091829020805460ff191660ff861690811790915591519182527f25a8e6b917872d4f0242d981f1efb363113f216dc7314bde01c287968defb51d910160405180910390a25b50505050565b6001600160a01b03811681146104c557600080fd5b50565b6000602082840312156104da57600080fd5b81356104e5816104b0565b9392505050565b600080602083850312156104ff57600080fd5b823567ffffffffffffffff81111561051657600080fd5b8301601f8101851361052757600080fd5b803567ffffffffffffffff81111561053e57600080fd5b8560208260051b840101111561055357600080fd5b6020919091019590945092505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561058b57600080fd5b81516104e5816104b0565b808201808211156105b757634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212203a1180925222c6e11f571f9f73a916e0fd7728ff67b5dd69e5513bab74956e5664736f6c634300081b003300000000000000000000000019e79f9db731b92f581d3ef0e6328ae918bb88ce

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061009d5760003560e01c8063b80f55c911610066578063b80f55c91461015b578063cb9ea33714610170578063d06fcba814610178578063e4d2620e1461018b578063ef2f90cf146101b757600080fd5b8062bb6e92146100a257806315889e43146100bd5780631f5c20ec146100dd5780632785f8bb1461010657806370d5ae051461013b575b600080fd5b6100aa600581565b6040519081526020015b60405180910390f35b6100aa6100cb3660046104c8565b60016020526000908152604090205481565b6100aa6100eb3660046104c8565b6001600160a01b031660009081526001602052604090205490565b6101296101143660046104c8565b60026020526000908152604090205460ff1681565b60405160ff90911681526020016100b4565b610143600081565b6040516001600160a01b0390911681526020016100b4565b61016e6101693660046104ec565b6101bf565b005b6100aa600f81565b600054610143906001600160a01b031681565b6101296101993660046104c8565b6001600160a01b031660009081526002602052604090205460ff1690565b6100aa601981565b80806102125760405162461bcd60e51b815260206004820152601c60248201527f4d757374206275726e206174206c65617374206f6e6520746f6b656e0000000060448201526064015b60405180910390fd5b60005b818110156103ab57600084848381811061023157610231610563565b6000546040516331a9108f60e11b8152602092909202939093013560048201819052935033926001600160a01b03169150636352211e90602401602060405180830381865afa158015610288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102ac9190610579565b6001600160a01b0316146103025760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420746865206f776e6572206f66207468697320746f6b656e00000000006044820152606401610209565b600080546040516323b872dd60e01b81523360048201526024810192909252604482018390526001600160a01b0316906323b872dd90606401600060405180830381600087803b15801561035557600080fd5b505af1158015610369573d6000803e3d6000fd5b50506040518381523392507fcc16f5dbb4873280815c1ee09dbd06736cffcc184412cf7a71a0fdb75d397ca5915060200160405180910390a250600101610215565b5033600090815260016020526040812080548392906103cb908490610596565b9091555050336000908152600160205260408120546019116103ef57506001610429565b33600090815260016020526040902054600f1161040e57506002610429565b33600090815260016020526040902054600511610429575060035b60008160ff1611801561045157503360009081526002602052604090205460ff828116911614155b156104aa5733600081815260026020908152604091829020805460ff191660ff861690811790915591519182527f25a8e6b917872d4f0242d981f1efb363113f216dc7314bde01c287968defb51d910160405180910390a25b50505050565b6001600160a01b03811681146104c557600080fd5b50565b6000602082840312156104da57600080fd5b81356104e5816104b0565b9392505050565b600080602083850312156104ff57600080fd5b823567ffffffffffffffff81111561051657600080fd5b8301601f8101851361052757600080fd5b803567ffffffffffffffff81111561053e57600080fd5b8560208260051b840101111561055357600080fd5b6020919091019590945092505050565b634e487b7160e01b600052603260045260246000fd5b60006020828403121561058b57600080fd5b81516104e5816104b0565b808201808211156105b757634e487b7160e01b600052601160045260246000fd5b9291505056fea26469706673582212203a1180925222c6e11f571f9f73a916e0fd7728ff67b5dd69e5513bab74956e5664736f6c634300081b0033

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

00000000000000000000000019e79f9db731b92f581d3ef0e6328ae918bb88ce

-----Decoded View---------------
Arg [0] : _nftTokenAddress (address): 0x19E79f9db731b92f581D3Ef0E6328ae918bb88CE

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000019e79f9db731b92f581d3ef0e6328ae918bb88ce


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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