2.3 Burning Mechanism

The handle/sub-handle gets burned and are issued a new token ID when another user mints an expired handle/sub-handle using the mintHandle or mintSubhandle function. It's crucial for owners to renew before the expiration date to prevent reclamation through the mint function. When a parent handle gets reclaimed by another user, the previous parent handle owner loses any upcoming revenue share from sub-handle owners, which is then transferred to the new owner of the handle. Burn Handle:


/**
    * 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);
    }
                                                                

Burn Sub-Handle:


/**
    * Function to burn an expired subhandle.
    * @param subhandleAndParent The combined name of the subhandle and its parent handle.
    */
    function burnSubhandle(string memory subhandleAndParent) internal {
        // Split the combined handle name into subhandle name and parent handle name.
        (string memory subhandleName, string memory parentHandleName) = StringUtil.splitCombinedHandleName(subhandleAndParent);
        // Construct the parent handle name with suffix.
        string memory parentHandleWithSuffix = string(abi.encodePacked(parentHandleName, ".", string(HANDLE_SUFFIX)));
        // Get the subhandle from the parent handle's subhandles mapping.
        Subhandle storage subhandle = handles[parentHandleWithSuffix].subhandles[subhandleName];

        // Check if the subhandle is registered.
        require(subhandle.tokenId != 0, "Subhandle not registered");
        // Check if the subhandle is expired.
        require(subhandle.expirationTimestamp <= block.timestamp, "Subhandle is not expired");

        // Mark the token as burned
        burnedTokenIds[subhandle.tokenId] = true;

        // Burn the token
        _burn(subhandle.tokenId);

        // Construct the subhandle name with suffix.
        string memory subhandleWithSuffix = string(abi.encodePacked(subhandleName, ".", parentHandleWithSuffix));

        emit SubhandleBurned(msg.sender, subhandleWithSuffix, subhandle.tokenId);
    }

Example:


logs	[
	{
		"from": "0xF27374C91BF602603AC5C9DaCC19BE431E3501cb",
		"topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
		"event": "Transfer",
		"args": {
			"0": "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2",
			"1": "0x0000000000000000000000000000000000000000",
			"2": "1",
			"from": "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2",
			"to": "0x0000000000000000000000000000000000000000",
			"tokenId": "1"
		}
	},
	{
		"from": "0xF27374C91BF602603AC5C9DaCC19BE431E3501cb",
		"topic": "0x5c1f7b3601e4cd4a1078139c2f4b0099777ade51b09f3f9ea8f0ad4af6d601bf",
		"event": "HandleBurned",
		"args": {
			"0": "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2",
			"1": "testing123.₿",
			"2": "1",
			"owner": "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2",
			"handleName": "testing123.₿",
			"tokenId": "1"
		}
	},
	{
		"from": "0xF27374C91BF602603AC5C9DaCC19BE431E3501cb",
		"topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
		"event": "Transfer",
		"args": {
			"0": "0x0000000000000000000000000000000000000000",
			"1": "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db",
			"2": "2",
			"from": "0x0000000000000000000000000000000000000000",
			"to": "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db",
			"tokenId": "2"
		}
	},
	{
		"from": "0xF27374C91BF602603AC5C9DaCC19BE431E3501cb",
		"topic": "0xbca2d57eabab381fa4ab39218b0b9ddc157bae88693c3a180a5451dac48303a0",
		"event": "HandleRegistered",
		"args": {
			"0": "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db",
			"1": "testing123.₿",
			"2": "1746466030",
			"3": "2",
			"owner": "0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db",
			"handleName": "testing123.₿",
			"expirationTimestamp": "1746466030",
			"tokenId": "2"
		}
	}
]

0xAb...835cb2 < Token Id 1 = testing123.₿ < Burned < Minted < Token Id 2 Issued = testing123.₿ < 0x4B...2C02db

Last updated