Immutable X Metadata Strategies

Transcript

Toggle full transcript
00:00

Hello and welcome to the lesson on ImmutableX Metadata Strategies. In this lesson, we're going to talk through the strategies that you can apply to deal

00:10

with metadata for ImmutableX NFTs. This is a core part of being able to mint NFTs at scale on ImmutableX.

00:20

First and foremost, there are some key decisions that you need to make when you are deciding how you mint your NFT collection at scale.

00:30

First and foremost for the metadata itself. You need to decide if you want to use IPFS and leverage the immutability guarantees that it provides or you want to have a Web 2 API.

00:40

And then similarly for the media file or files that the metadata points to, you need to have a decision on whether or not you want to use IPFS

00:50

or a Web 2 API for that. And then finally, you need to decide whether or not your collection has static

01:00

versus generative versus dynamic metadata. These three key decisions will determine the approach that you would need

01:10

to take in order to implement your NFT collection and by association, how you can then mint at scale.

01:20

First and foremost, let's talk about how IPFS and ImmutableX interact with each other. If your metadata is known in its entirety ahead of time, i.e.

01:30

it is static metadata, then you can actually use IPFS for this and you can provide an immutability guarantee and b

01:40

you can leverage IPFS by itself. And you don't need to stand up or host any server or API, which is a much simpler hosting scenario.

01:50

First and foremost, you're going to need to upload all of your media to IPFS so that you

02:00

can generate all of the URLs for that media with the content ID or IDs. And then secondly, you can construct the metadata

02:10

and then upload it as an archive into IPFS. And as long as you make it so that each metadata file is represented by the token it say 1 to 3, etc., then

02:20

that would mean that your metadata is available at ipfs://{content id of your archive}/{token ID},

02:30

and this corresponds very nicely to the way that ImmutableX needs to have its metadata URL.

02:40

Now, if you implement this pattern, then you can make it so that the ERC-721

02:50

smart contract that you deploy to Ethereum can have a basic right that's hard coded to ipfs://{the content ID}

03:00

and the marketplaces on Ethereum have native support for IPFS, so this will work nicely. Then in addition to that, to make this work for ImmutableX, you

03:10

need to make sure that the API metadata URI is a https:// gateway that points to your IPFS content ID.

03:20

So as an example, if you're using IPFS IO, then you would set the API metadata URL to be https://ipfs.io/ipfs/{your

03:30

content ID} (of the archive that contains your metadata). And then what ImmutableX will do is it will append /{token ID} every

03:40

time it wants to make a HTTP request to load the metadata of a given NFT.

03:50

Next, let's talk about refresh of metadata on ImmutableX. As we've covered previously, ImmutableX caches metadata for performance. It doesn't do a live look up every single time someone tries to retrieve some

04:00

metadata about a given token. But what this means is if you have a project that has dynamic metadata that changes

04:10

and is not immutable, then you're going to need to trigger a refresh on ImmutableX any time you change that metadata.

04:20

Now, the way the metadata refresh service works is it concurrently requests metadata for each asset that you tell it to refresh and you can tell it to refresh multiple assets

04:30

at a time. There's a rule that the response time for each metadata request needs to be less than 3 seconds. And in terms of reliability, if there are file requests,

04:40

it will retry them several times within an hour period. If this fails persistently, then these failed assets will be marked as such.

04:50

After several failed rate tries and there's a key limitation worth keeping in mind, which is that for any given project, you can refresh up

05:00

to 20 metadata refreshes per hour. And for each metadata refresh, you can specify up to a thousand tokens

05:10

that can be refreshed. Now that we've covered the basic approaches. Next, it's worth looking at the three key metadata strategies that

05:20

are available to us. The first one is static metadata. This is where you have fixed information about your NFT collection.

05:30

That doesn't change over time. This data is immutable and it's known ahead of time. This means that you could store this metadata in IPFS, as we've talked

05:40

about, and it's easy to define it prior to the NFT collection being minted. Alternatively, maybe you have a need for generative metadata.

05:50

This is where you algorithmically or programmatically generate the metadata based on some sort of rule or event. An example of this might be the traits or attributes of some

06:00

sort of crypto collectable generative art piece that has different layers. Or maybe it's a game item that gets generated on the fly as you earn

06:10

that game item. The point here is that the metadata is defined at the time the NFT is first minted.

06:20

But then from that point on is immutable. Thirdly, there is the approach of dynamic metadata.

06:30

This is metadata that changes over time, potentially based on some sort of external data source. So this might be things like real time data like weather or financial data.

06:40

And this metadata that changes over time will change the properties of the NFT that they're associated with.

06:50

So now that we've covered these three strategies, let's talk through how you would implement each of the three. Firstly, we have static metadata.

07:00

Now, in this case, if you're using IPFS, we can follow the process that we talked about before where we have a single archive deployed to a content ID and we make sure that each token ID

07:10

is defined as a file within that archive so that you can append slash token ID to the IPFS URL and get the metadata for a single NFT.

07:20

In terms of the Web 2 API that ImmutableX needs as its metadata APIs URL. This can either be a HTTP gateway to your

07:30

IPFS content ID, or if you want, you can implement a traditional web two API if you don't want to be using IPFS.

07:40

Although our recommendation would be if you have static metadata, it makes sense to use IPFS because the data is already immutable and it's a best

07:50

practice in the industry to use IPFS for immutable metadata. In terms of the Ethereum Smart contract, you can use a standard NFT

08:00

ERC-721 smart contract with the base URL set to ipfs://{the content ID} as we've

08:10

gone through previously. In terms of the ImmutableX collection, we just need to set the API metadata URL to be the HTTP web 2 API gateway that we choose, be it

08:20

and IPFS Gateway, or a traditional Web 2 API in terms of minting and withdrawing the NFT.

08:30

There's no real differences here from what you would normally experience. If we want to implement a strategy for generative metadata, we can still use IPFS. But what we would do is at the point in time we're about to mint the NFT,

08:40

we would upload that metadata to IPFS and generate a specific content ID for that metadata.

08:50

We don't have much choice in terms of the API metadata URL for ImmutableX because the URL changes.

09:00

Given that we have to upload to IPFS on the fly rather than all at once as an archive at the start, we basically have to be using some sort

09:10

of API as a gateway that converts token ID to our request to the underlying IPFS or wherever we decide to store the metadata if we don't want to use IPFS.

09:20

In the Ethereum smart contract, we need to change the standard ERC-721 smart contract such that we set the token URI based on

09:30

what's passed through at minting time. In terms of the API metadata URL. This will have to be our custom API server.

09:40

When when minting on ImmutableX, we should set the blueprint on the token to be the IPFS URL with the content id of the metadata

09:50

for that NFT if we're using IPFS. Or alternatively, it could be our Web 2 API.

10:00

Finally, when withdrawing the NFT, we simply need to use the blueprint that was passed in at minting time and then set that as the token URI.

10:10

Finally, if we're dealing with dynamic metadata, we can't really use IPFS for this. IPFS is inherently immutable, and in this case the metadata

10:20

is mutable. So we basically need to create a traditional Web 2 API. We need to store the metadata in some sort of immutable database,

10:30

and we need to make sure that when that metadata changes that we trigger a metadata refresh on ImmutableX so that the cached metadata that it has is modified to update.

10:40

In terms of the Ethereum smart contract, it can be a fairly standard smart contract with the base URI set to our Web 2 API.

10:50

Similarly, the API metadata URL for the ImmutableX collection can be set to our web to API gateway in

11:00

terms of minting and withdrawal. There isn't really any changes that happen here. So now that we've covered how metadata and immutability and different metadata

11:10

strategies and approaches for metadata work in ImmutableX. From here you have all the tools that you need to mint at scale on ImmutableX.

11:20

In particular, if you take the code that you've been using in the previous labs in this course, then they provide you in combination with these metadata

11:30

strategies, all of the tools that you need to construct an automated minting process that would meet multiple items.

11:40

Thanks for joining me for this lesson.