ERC721 Question

Hi,

Long story short .. is it possible to lock safeTransferFrom function and keep _burn function ?
What I want to achieve is to let user to mint the NFT's and do not allow them to transfer, but allow them to burn their own NFTs it they want to..

Is it at all possible ?
I wrote code like this, but of course it blocks the burn function.

 function _beforeTokenTransfer(address from, address to, uint256 tokenId, uint256 batchSize)
        internal
        whenNotPaused
        override(ERC721, ERC721Enumerable)
    {   
        super._beforeTokenTransfer(from, to, tokenId, batchSize);
        if (from == msg.sender) {
            revert("Transfer locked");
        } 
    }

Thanks

You have more than 1 way to achieve this:

  1. block only the transfers overriding the transfer function
  2. override the burn function to not use the beforeTokenTransfer
1 Like

Thank you for answer.

Could you please provide any example ?
I would be more than grateful.

By block only the transfers overriding the transfer function
you mean by doing something like this ?

Seem to work as it's now only a read function.

function safeTransferFrom(address ,address, uint) public pure override(ERC721, IERC721) {
        revert("Cannot transfer");
    }

Thanks