ERC-1155 Approve Facet
Manage ERC-1155 approvals within a diamond
- Exposes external
setApprovalForAllfunction for diamond routing. - Emits
ApprovalForAllevent upon approval changes. - Uses inline assembly to access diamond storage.
- Provides
exportSelectorsfor diamond facet discovery.
Overview
This facet provides external functions for managing ERC-1155 token approvals within a diamond proxy. It integrates with diamond storage to track approval status. Developers add this facet to enable token holders to grant operators permission to transfer their ERC-1155 tokens.
Storage
ERC1155Storage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc1155")) |
Functions
setApprovalForAll
Grants or revokes permission to operator to transfer the caller's tokens. Emits an ApprovalForAll event.
Parameters:
| Property | Type | Description |
|---|---|---|
_operator | address | The address to grant/revoke approval to. |
_approved | bool | True to approve, false to revoke. |
exportSelectors
Exports the function selectors of the ERC1155ApproveFacet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the ERC1155ApproveFacet |
Events
Errors
Best Practices
- Grant approvals only to trusted operators.
- Ensure the ERC1155ApproveMod is correctly initialized before this facet is used.
- Verify that the diamond storage layout is compatible before upgrading.
Security Considerations
The setApprovalForAll function allows any caller to approve or revoke an operator for their tokens. Callers must ensure they are approving legitimate operators. The facet includes an ERC1155InvalidOperator error, which is currently not used by the exposed functions, but is available for internal use or future extensions.