Set token metadata right before mint

Sorry in advance if I'm not in the right category. Also I looked to see if this question has already been asked and I didn't find anything so sorry if there are duplicates.

I have a question about the metadata of an NFT. I'm going to have a smart contract, where there can be several collections (so each will have its own ipfs folder). Moreover, I need to control the NFT that will be released (at least its metadata).

Forget what you are used to see, and take the context as it is (the project is only internal and is not meant to be used anywhere else, hence the liberties taken).

Ideally, you should :
On the backend, I know which NFT I need to retrieve (the server-side NFT is attached to a product, if the user has that product, he should have the corresponding NFT and not a random one). So I will have an ipfs folder with the complete supply, each image and its metadata. The user has a product X, I get the corresponding ipfs link and I send it to my smart contract to say "hey, you're going to mint this token here, and not a random".

Another point, I will have several different ipfs folders. In my smart contract, I will have a map with the different links. Can I switch the baseURI to mint the token in the right folder before the mint ?

Summary:

  • Can I choose precisely which NFT will be mint, or do I have to mint a random one THEN modify its metadata in the mint method?
  • Can I choose the ipfs baseURI before each mint?

I don't want to have a smart contract for each project. I'm just looking to switch the baseURI to look in the corresponding folder, and mint a specific NFT from that folder.

In each tutorial, I see that the baseURI must be specified in the constructor. But it really bothers me, I'm sure it should be possible to switch and modify this URL before each mint

1 Like

The base url is just used so save storage space and having to only append the nft Id. you can easily change it to create an array of base urls and depending on that return the NFT’s meta data url.

In general NFT’s aren’t minted “randomly”. The actual metadata stored on the are randomly created instead. The NFT’s that are minted just increase the nft id by 1 each time. However when you write the contract you can write it and make it behave in any way you want.

2 Likes

Yes. You can do all of this, based on how you code your NFT smart contract code.

1 Like