ERC721EnumerableBurnFacet
Burns ERC-721 tokens and removes them from enumeration
- Exposes external function
burn(uint256 tokenId)for token destruction. - Integrates with ERC-721 enumeration tracking.
- Follows EIP-2535 diamond standard for composability.
- Uses internal
getStorage()for state access.
Overview
This facet provides functionality to burn ERC-721 tokens within a diamond proxy, ensuring they are removed from enumeration tracking. It exposes the burn function for token destruction and getStorage for internal access to its state. Integrate this facet to enable token destruction capabilities while maintaining the diamond's upgradeability and composition.
Storage
ERC721EnumerableStorage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.erc721.enumerable")) |
Functions
burn
Burns (destroys) a token, removing it from enumeration tracking.
Parameters:
| Property | Type | Description |
|---|---|---|
_tokenId | uint256 | The ID of the token to burn. |
Events
Errors
Best Practices
- Initialize the facet's storage during diamond setup.
- Ensure the caller has the necessary permissions to burn the specified token.
- Verify that the token exists before attempting to burn it.
Security Considerations
The burn function should be protected by appropriate access control mechanisms to prevent unauthorized token destruction. Input validation for _tokenId is crucial to prevent issues with non-existent tokens, which will revert with ERC721NonexistentToken. Ensure that the caller has sufficient approval to burn the token, otherwise ERC721InsufficientApproval will be reverted.