Skip to main content

ERC-721 Burn Facet

Burns ERC-721 tokens within a diamond

Key Features
  • 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 exportSelectors for 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

Definition
struct ERC721Storage {
mapping(uint256 tokenId => address owner) ownerOf;
mapping(address owner => uint256 balance) balanceOf;
mapping(address owner => mapping(address operator => bool approved)) isApprovedForAll;
mapping(uint256 tokenId => address approved) approved;
}

State Variables

PropertyTypeDescription
STORAGE_POSITIONbytes32Diamond storage slot position for this module (Value: keccak256("erc721"))

Functions

burn

Burns (destroys) a token, removing it from enumeration tracking.

function burn(uint256 _tokenId) external;

Parameters:

PropertyTypeDescription
_tokenIduint256The ID of the token to burn.

burnBatch

Burns (destroys) a token, removing it from enumeration tracking.

function burnBatch(uint256[] memory _tokenIds) external;

Parameters:

PropertyTypeDescription
_tokenIdsuint256[]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

function exportSelectors() external pure returns (bytes memory);

Returns:

PropertyTypeDescription
-bytesselectors The exported function selectors of the ERC721BurnFacet

Events

Errors

Best Practices

Best Practice
  • 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 burn or burnBatch functions.
  • Verify storage slot compatibility with other facets before upgrading or adding this facet to a diamond.

Security Considerations

Security

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.

Was this helpful?
Last updated:

Newsletter

Get notified about releases, feature announcements, and technical deep-dives on building smart contracts with Compose.

No spam. Unsubscribe anytime.