👀 Metadata Module
Manage & view metadata for IP Assets.
The Metadata Module enables the creation, management, and retrieval of metadata for IP Assets within Story. It consists of two main components: the CoreMetadataModule for writing operations and the CoreMetadataViewModule for reading operations.
CoreMetadataModule.sol
View the smart contract for the Core Metadata Module.
CoreMetadataViewModule.sol
View the smart contract for the Core Metadata View Module.
Metadata Structure
The metadata for an IP Asset includes:
- metadataURI: A URI pointing to the detailed metadata of the IP Asset
- metadataHash: A hash of the metadata for verification purposes
- nftTokenURI: A URI pointing to the metadata of the NFT associated with the IP Asset
- nftMetadataHash: A hash of the NFT metadata for verification
- registrationDate: When the IP Asset was registered
- owner: The current owner of the IP Asset
CoreMetadataModule (Write Operations)
CoreMetadataModule.sol
is responsible for writing and updating metadata for IP Assets. It is stateful and provides the following key functionalities:
- Setting and updating metadata URIs for IP Assets
- Setting and updating NFT token URIs
- Freezing metadata to make it immutable
- Managing metadata hashes for verification
The module stores metadata in the IP Asset’s storage, making it accessible to other modules and applications.
Setting Metadata
To set metadata for an IP Asset, the caller must have appropriate permissions. The CoreMetadataModule provides several functions for setting metadata:
setMetadataURI
: Sets just the IP metadataURI and its hashupdateNftTokenURI
: Updates the NFT token URI and its hashsetAll
: Sets all metadata attributes at once
Here is an example:
Freezing Metadata
The CoreMetadataModule allows IP Asset owners to freeze metadata, making it immutable. Once frozen, the metadata cannot be changed, ensuring the permanence of the IP Asset’s information.
To freeze metadata:
You can check if metadata is frozen using:
CoreMetadataViewModule (Read Operations)
CoreMetadataViewModule.sol
is a read-only module that provides access to the metadata stored by the CoreMetadataModule. It follows the View Module pattern and offers these key functionalities:
- Retrieving metadata URIs and hashes
- Retrieving NFT token URIs and metadata hashes
- Generating formatted JSON strings with all metadata attributes
- Checking registration dates and ownership information
Retrieving Metadata
The CoreMetadataViewModule provides various functions to retrieve metadata:
getCoreMetadata
: Returns all metadata in a single structgetMetadataURI
: Returns just the metadata URIgetNftTokenURI
: Returns the NFT token URIgetJsonString
: Returns a formatted JSON string with all metadata
Here is an example:
The Metadata Module provides a robust system for managing IP Asset metadata, ensuring that important information about intellectual property is properly recorded, accessible, and can be made immutable when needed.