Dynamically create metadata for ERC721

Hi eveyone. I also wonder this but for ERC721. Wanted to ask here before opening another thread.

Let’s say we have an external service to create and send metadata.
1- How can this (title) be done?
2- If there is no easy answer, where can I learn more about this?

For example, is the workflow below possible?

1- User initiates mint.
2- A seed is generated inside the contract
3- Seed sent to an external API
4- API returns metadata
5- Token saves metadata
6- Minting complete

I’m very new to this, any kind of help is appreciated.


1 Like

Hi @zuhtu,

Welcome to the community :wave:

You could have a transaction to do something inside the contract, then generate metadata offchain and then have another transaction do the mint.

Though you want to avoid having to do multiple transactions.
Also true randomness can’t be done onchain.

As an aside: I suggest creating a new thread per question so anyone can answer. I moved this question to a new topic.

Thanks @abcoathup!

This is because transaction costs, right?

Let’s assume I don’t mind the gas costs. This means I can’t pause the token minting until offchain metadata is generated and sent, and continue minting process? Instead, mint the token, have a mechanism to update the token’s metadata, then have a transaction to update metadata.

If the latter is the correct way, do you have any examples of such implementation?

1 Like

Hi @zuhtu,

Mostly gas cost and complexity. It depends if a user is doing the minting or if you are doing the minting, but you then need a second transaction.

This means that you have a mechanism to update a tokens metadata (for good or for bad). If you are updating metadata then you could keep it offchain, as users have to trust you any way.

I don’t have examples of this. You may want to look at how other projects do this.

It appears to be mostly offchain metadata (centralized) or using decentralized storage at the time of minting.

1 Like

Thanks @abcoathup. Have a nice day.

1 Like

Actually, I have one more related question. Let’s say we decided to update metadata of tokens after they were minted. Is updating multiple tokens’ metadata (different URI for each token) possible with only 1 transaction? Or we have to make separate transactions for each token?

1 Like

Hi @zuhtu,

If you use centalized metadata (e.g. https://example.com/token/1) then you don’t need to update onchain.

If you use decentralized metadata then you would need to update each token (a transaction per token). Your community would then need to trust that you would keep the admin keys secure and that you would appropriately update.

1 Like