2.3 Burning Mechanism
/**
* Function to burn an expired handle.
* @param tokenId The token ID associated with the handle.
*/
function burnHandle(uint256 tokenId) internal {
// Get the handle name with suffix and the corresponding handle.
string memory handleWithSuffix = handleNames[tokenId];
Handle storage handle = handles[handleWithSuffix];
// Check if the handle is registered.
require(handle.tokenId != 0, "Handle not registered");
// Check if the handle is expired.
require(handle.expirationTimestamp <= block.timestamp, "Handle is not expired");
address owner = ownerOf(tokenId); // Get the owner of the token.
// Mark the token as burned
burnedTokenIds[tokenId] = true;
// Burn the token
_burn(tokenId);
emit HandleBurned(owner, handleWithSuffix, tokenId);
}
Last updated