APE Price: $0.68 (-2.09%)

Contract Diff Checker

Contract Name:
TransferToNull

Contract Source Code:

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

interface IERC721A {
    function ownerOf(uint256 tokenId) external view returns (address);
    function transferFrom(address from, address to, uint256 tokenId) external;
}

contract TransferToNull {
    address public nftContractAddress;

    // Constructor to set the NFT contract address
    constructor(address _nftContractAddress) {
        nftContractAddress = _nftContractAddress;
    }

    // Function to transfer multiple NFTs to the null address (0x0)
    function transferToNull(uint256[] calldata tokenIds) external {
        IERC721A nft = IERC721A(nftContractAddress);

        for (uint256 i = 0; i < tokenIds.length; i++) {
            uint256 tokenId = tokenIds[i];
            // Ensure the caller owns the token
            address owner = nft.ownerOf(tokenId);
            require(owner == msg.sender, "You must own the token to transfer it");

            // Transfer the token to the null address (0x0)
            nft.transferFrom(owner, address(0), tokenId);
        }
    }
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):