ERC-721 Metadata Module
Manages ERC721 metadata within a diamond
- Provides internal functions for ERC721 metadata management.
- Utilizes diamond storage (EIP-8042) for shared state.
- No external dependencies, promoting composability.
- Functions are designed for internal use within custom facets.
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 managing ERC721 metadata. Facets can import this module to access and modify the name, symbol, and base URI using shared diamond storage. Changes made through this module are immediately visible to all facets interacting with the same storage slot.
Storage
ERC721MetadataStorage
storage-location: erc8042:erc721.metadata
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc721.metadata")) |
Functions
getStorage
Returns a pointer to the ERC-721 storage struct. Uses inline assembly to access the storage slot defined by STORAGE_POSITION.
Returns:
| Property | Type | Description |
|---|---|---|
s | ERC721MetadataStorage | The ERC721Storage struct in storage. |
setMetadata
Parameters:
| Property | Type | Description |
|---|---|---|
_name | string | - |
_symbol | string | - |
_baseURI | string | - |
Errors
Best Practices
- Ensure the ERC721MetadataMod is correctly initialized and accessible via diamond storage.
- Call
getStorage()to read the current metadata values before attempting to set new ones. - Be aware that changes to metadata are immediately visible to all facets using the same storage slot.
Integration Notes
This module interacts with diamond storage at the slot identified by STORAGE_POSITION, which is defined as keccak256(\"erc721.metadata\"). The getStorage() function uses inline assembly to access this specific storage slot, returning a pointer to the ERC721MetadataStorage struct. This struct contains fields for name, symbol, and baseURI. Any modifications made to this storage slot by any facet through this module are immediately reflected and accessible to all other facets interacting with the same diamond storage pattern.