Skip to main content

ERC-721 Metadata Module

Manages ERC721 metadata within a diamond

Key Features
  • 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.
Module Usage

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

Definition
struct ERC721MetadataStorage {
string name;
string symbol;
string baseURI;
}

State Variables

PropertyTypeDescription
STORAGE_POSITIONbytes32Diamond 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.

function getStorage() pure returns (ERC721MetadataStorage storage s);

Returns:

PropertyTypeDescription
sERC721MetadataStorageThe ERC721Storage struct in storage.

setMetadata

function setMetadata(string memory _name, string memory _symbol, string memory _baseURI) ;

Parameters:

PropertyTypeDescription
_namestring-
_symbolstring-
_baseURIstring-

Errors

Best Practices

Best Practice
  • 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

Shared Storage

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.

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.