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.

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 hash
  • updateNftTokenURI: Updates the NFT token URI and its hash
  • setAll: Sets all metadata attributes at once

Here is an example:

solidity
// Set the metadata URI and hash
coreMetadataModule.setMetadataURI(
    ipAssetAddress,
    "https://example.com/metadata/asset123",
    keccak256("metadata content hash")
);

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:

solidity
// Make the metadata immutable
coreMetadataModule.freezeMetadata(ipAssetAddress);

You can check if metadata is frozen using:

solidity
// Check if metadata is frozen
bool isFrozen = coreMetadataModule.isMetadataFrozen(ipAssetAddress);

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 struct
  • getMetadataURI: Returns just the metadata URI
  • getNftTokenURI: Returns the NFT token URI
  • getJsonString: Returns a formatted JSON string with all metadata

Here is an example:

solidity
// Get the metadata URI
string memory uri = coreMetadataViewModule.getMetadataURI(ipAssetAddress);

// Get all metadata in one call
CoreMetadata memory metadata = coreMetadataViewModule.getCoreMetadata(ipAssetAddress);

// Get a JSON representation of all metadata
string memory jsonMetadata = coreMetadataViewModule.getJsonString(ipAssetAddress);

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.