📹 Hosted Media & Metadata

Using Co:Create's media & metadata hosting to deliver dynamic NFT experiences to your users

👍

Get Help

If you get stuck at any time, reach out to us on Discord or contact us via email at [email protected].

Understanding the Role of Media and Metadata Files in Non-Fungible Tokens

Let's provide some context before we dive into the details.

When you create a non-fungible token, you need to have two files hosted off-chain:

  • a media file
  • a metadata file

These files should be hosted off-chain due to blockchains' inability to store large data volumes and the high cost of data storage. The blockchain only retains the ownership record of an NFT. The NFT, in turn, points to the off-chain hosted metadata file, effectively offsetting the storage cost.

Now, let's take a look at the two files:

  1. The Media File: This file can be of any type/format (e.g., picture, audio, video, document). Essentially, this is the asset your token represents.
  2. The Metadata File: This is a JSON file serving as your token's descriptor. It allows you to define attributes such as the token's name, base_uri, and other properties of your choice. To aid in the discovery of your NFT, structuring your metadata file using a standard scheme is advisable.

When deploying a ERC-721 contract on Co:Create, you'll need to provide a base_uri parameter. This base_uri is a URI that leads to the contract's metadata file.

Here's an example of a metadata URI:

Accessing this link will lead you to a non-fungible token's metadata, which includes a link to the media file itself:

  • ipfs://bafybeicm4hja3ty6jq52nsredyluviugp5d5ekos4cy4337cp5adj5aru4/0.jpg

How to use the Media & Metadata endpoints with Co:Create tokens

Step 1 - Create Media for the NFT

Media can be created & hosted for the NFT collection using the Media API. This media can be any digital content that is associated with the NFT, such as an image or a video. Media can apply to the full collection or it can be applied to a single token. The output of this is a media URL which is publicly accessible.

Step 2 - Create Metadata for the NFT

The next step is to create metadata for the collection using the Metadata API. This metadata can include details about the NFT, such as its name, description, and attributes. If choosing to use Co:Create’s Media API as well, the media URL provided as part of the GET media response is also added to the metadata. Metadata can also apply to the full collection or it can be applied to a single token.

The output of this step is a metadata URI which is added to the token contract upon deployment. (To reduce gas costs, metadata is never stored on-chain unless absolutely necessary. Only the URI is stored on-chain, which points to where the metadata can be viewed.)

Step 3 - Deploy a new ERC721 contract

Co:Create's ERC721 API can be used to deploy a new ERC721 contract, including the metadata URI from the previous step.

Step 4 - Mint the NFT

Once the metadata and media have been created and the token contract has been deployed, the NFT can be minted to a user’s wallet. Minting is the process of creating a new NFT on the blockchain. This can also be done using Co:Create’s ERC721 API.

(Optional) Step 5 - Update the NFT Media and / or Metadata

This step is only relevant if implementing a dynamic NFT use case.

As the end user completes actions that would result in a change to the NFT, the media & metadata associated with the user’s token can be updated to reflect these changes. Updates to each can be made using Co:Create’s Media & Metadata APIs.


What’s Next