ERC-721 Burn Module
Burns ERC-721 tokens using diamond storage
- Provides
internalfunctions for token burning. - Utilizes the diamond storage pattern for shared state.
- No external dependencies, ensuring minimal on-chain footprint.
- Emits
Transferevent upon successful token burning.
This module provides internal functions for use in your custom facets. Import it to access shared logic and storage.
Overview
This module provides internal functions for burning ERC-721 tokens. Facets can import and use this module to remove tokens from circulation via shared diamond storage. Token state changes made through this module are immediately visible to all facets accessing the same storage.
Storage
ERC721Storage
Storage layout for ERC-721 token management. Defines ownership, balances, approvals, and operator mappings per ERC-721 standard. storage-location: erc8042:erc721
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc721")) |
Functions
burn
Burns (destroys) a specific ERC-721 token. Reverts if the token does not exist. Clears ownership and approval. This module does not perform approval checks. Ensure proper ownership or approval validation before calling this function.
Parameters:
| Property | Type | Description |
|---|---|---|
_tokenId | uint256 | The ID of the token to burn. |
getStorage
Returns the ERC-721 storage struct from its predefined slot. Uses inline assembly to access diamond storage location.
Returns:
| Property | Type | Description |
|---|---|---|
s | ERC721Storage | The storage reference for ERC-721 state variables. |
Events
Errors
Best Practices
- Ensure appropriate ownership or approval checks are performed by the calling facet before invoking
burn. - Verify that the
ERC721Storagestruct definition used by this module is compatible with your diamond's storage layout. - Handle the
ERC721NonexistentTokenerror if the token ID provided toburndoes not exist.
Integration Notes
This module interacts with diamond storage at the STORAGE_POSITION defined by keccak256(\"erc721\"). The burn function modifies internal state within the ERC721Storage struct, including clearing ownership and approvals for the specified token ID. The getStorage function provides direct access to this shared storage struct via inline assembly. Changes to this storage are immediately visible to all facets within the same diamond.