ERC-721 Burn Facet
Burns ERC-721 tokens within a diamond
- Exposes external functions for burning ERC-721 tokens through a diamond proxy.
- Interacts with shared diamond storage for token management.
- Supports burning single tokens and batches of tokens.
- Includes
exportSelectorsfor diamond selector discovery.
Overview
This facet provides functionality to burn (destroy) ERC-721 tokens. It interacts with diamond storage to manage token destruction. Developers integrate this facet to enable token holders to permanently remove their tokens from circulation via the diamond proxy.
Storage
ERC721Storage
State Variables
| Property | Type | Description |
|---|---|---|
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. |
burnBatch
Burns (destroys) a token, removing it from enumeration tracking.
Parameters:
| Property | Type | Description |
|---|---|---|
_tokenIds | uint256[] | The ID of the token to burn. |
exportSelectors
Exports the function selectors of the ERC721BurnFacet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the ERC721BurnFacet |
Events
Errors
Best Practices
- Ensure the ERC721BurnFacet is properly initialized with access control if required by your diamond architecture.
- Validate that the caller has the necessary permissions to burn tokens before calling the
burnorburnBatchfunctions. - Verify storage slot compatibility with other facets before upgrading or adding this facet to a diamond.
Security Considerations
The burn and burnBatch functions modify state by destroying tokens. Ensure that appropriate access control mechanisms are in place within the diamond to restrict who can call these functions. The facet does not explicitly implement reentrancy guards; follow standard Solidity security practices for external calls if any are introduced by related facets. Input validation for _tokenIds is crucial to prevent unexpected behavior or denial of service.