ERC-1155 Burn Facet
Burn ERC-1155 tokens within a diamond
- Provides external functions for burning single and batch ERC-1155 tokens.
- Leverages diamond storage for token balances and operator approvals.
- Emits
TransferSingleandTransferBatchevents upon successful burns. - Includes
exportSelectorsfor facet discovery within a diamond.
Overview
This facet provides external functions for burning ERC-1155 tokens within a Compose diamond. It routes calls through the diamond proxy, accesses shared storage via getStorage, and emits standard ERC-1155 transfer events. Developers add this facet to enable token burning functionality while maintaining diamond upgradeability.
Storage
ERC1155Storage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc1155")) |
Functions
burn
Burns a single token type from an address. Emits a TransferSingle event. Caller must be the owner or an approved operator.
Parameters:
| Property | Type | Description |
|---|---|---|
_from | address | The address whose tokens will be burned. |
_id | uint256 | The token type to burn. |
_value | uint256 | The amount of tokens to burn. |
burnBatch
Burns multiple token types from an address in a single transaction. Emits a TransferBatch event. Caller must be the owner or an approved operator.
Parameters:
| Property | Type | Description |
|---|---|---|
_from | address | The address whose tokens will be burned. |
_ids | uint256[] | The token types to burn. |
_values | uint256[] | The amounts of tokens to burn for each type. |
exportSelectors
Exports the function selectors of the ERC1155BurnFacet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the ERC1155BurnFacet |
Events
Errors
Best Practices
- Ensure the ERC1155BurnFacet is properly initialized with correct storage slot.
- Caller must possess the token or be an approved operator before calling burn functions.
- Verify that
_idsand_valuesarrays have matching lengths before callingburnBatch.
Security Considerations
The burn and burnBatch functions require the caller to be the owner of the tokens or an approved operator. Insufficient balance will revert with ERC1155InsufficientBalance. Mismatched array lengths in burnBatch will revert with ERC1155InvalidArrayLength. Ensure that the diamond's access control mechanism correctly routes calls and that token ownership logic is consistent across all relevant facets.