ERC-721 Enumerable Burn Facet
ERC-721 token burning and enumeration tracking
- Implements ERC-721 token burning.
- Integrates with diamond storage for enumeration tracking.
- Exposes
burnfunction externally via the diamond proxy. - Provides internal functions (
getStorage,getERC721Storage) for accessing facet-specific and shared storage.
Overview
This facet implements ERC-721 token burning functionality within a Compose diamond. It exposes external functions for destroying tokens and integrates with diamond storage for enumeration tracking. Developers add this facet to manage token lifecycle and maintain correct token counts.
Storage
ERC721EnumerableStorage
ERC721Storage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc721.enumerable")) |
ERC721_STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc721")) |
Functions
burn
Burns (destroys) a token, removing it from enumeration tracking.
Parameters:
| Property | Type | Description |
|---|---|---|
_tokenId | uint256 | The ID of the token to burn. |
exportSelectors
Exports the function selectors of the ERC721EnumerableBurnFacet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the ERC721EnumerableBurnFacet |
Events
Errors
Best Practices
- Ensure the
ERC721EnumerableBurnFacetis properly registered with the diamond proxy. - Initialize the diamond's storage for ERC-721 before adding this facet.
- Verify that the
burnfunction's access control is configured appropriately for your diamond's security model.
Security Considerations
The burn function is an external function and should have appropriate access controls implemented at the diamond level to prevent unauthorized token destruction. The function removes a token from enumeration tracking, which could affect other facets relying on token order or count. Errors ERC721NonexistentToken and ERC721InsufficientApproval are emitted if the token does not exist or if approval conditions are not met, respectively.