Another _burn internal function

There are two _burn() internal functions present in the implementation. These are overloaded functions that have the same name; however, they take different arguments.

The function takes the tokenId of an NFT that is to be burned. The _burn() function code is defined as follows:

function _burn(uint256 tokenId) internal {
_burn(ownerOf(tokenId), tokenId);
}

The code finds the owner of the token and calls the other overloaded _burn() function. As it is an internal function, this can be used in the inherited contract to burn specific tokens when required.

 

This function should be used by the inherited contracts when they directly want to burn a token using just its tokenId only. For example, you can implement the following logic in an inherited contract:

function process(uint256 tokenId) public onlyOwner {
//Some pre-validations
bool isAllowedToBurn = true; //process this boolean in logic
if( isAllowedToBurn ) {
super._burn(tokenId);
}
}

As in the preceding example, only after certain validations and when it has been allowed to burn a given token, contract can burn tokens directly without checking their owners. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.168.2