Jon-Becker / nft-generator-py

This tool allows users to generate sets of unique images and metadata using weighted layer collections.
MIT License
306 stars 127 forks source link

Script to update JSON file with proper IPFS Data for images #7

Closed stocktonellis closed 2 years ago

stocktonellis commented 2 years ago

Feature Request:

When deploying the NFT images and metadata to IPFS, it is necessary to first upload the images (and get a unique CID). Then I need to update the JSON files to point at this CID. I can not create the CID in advance of running the generative script (index.py) as I do not have the CID until I upload the images.

Could a script be added to run after the index.py & once I get the CID to go through all files in the metadata folder and update the baseURI to represent the IPFS CID? (Or regenerate them based on all-object.json?) Obviously the data needs to maintain the connection to the image.

Jon-Becker commented 2 years ago

Can you upload the entire folder to IPFS, and your contract URI iterate over the IPFS folder? (I.E: ipfs://folderCID/metadata/1.json && ipfs://folderCID/images/1.png)

If not, ill add this tomorrow.

stocktonellis commented 2 years ago

I tried as you suggested and the issue ends up that when ipfs://folderCID/metadata/1.json is called, it looks for the image at ./images/1.png (no actual reference to the containing folder).

I went through some other projects and infact - the CID of the images and of the json are setup to be different (where the smart contract URI only references the JSON and the connection to the image is wholly contained in the JSON file.

Jon-Becker commented 2 years ago

Does changing the baseURI in generator config to "" fix it?

Either way, i'll post a patch 1.0.2 tomorrow. Thank you!

stocktonellis commented 2 years ago

I'm not sure, but as far as I can tell - it's a two step process. Appreciate it!

(and I'm sure this belongs in a separate issue but you might consider adding "description" to the metadata as well. That seems to be a needed/popular attribute that is missing).

Jon-Becker commented 2 years ago

Tomorrow became today, I hope that helps.

Let me know what you think!

stocktonellis commented 2 years ago

Ok - that works perfectly! One thing that I noticed (not sure if this is new) is that now the .json files have leading zeros (as do the reference to images in the json.

For example: So when I generate 100 NFTs, I get 001.json which references image 001.png but the actual image is just 1.png. (If I do 1000 nfts, I get 0001.json etc.)

Jon-Becker commented 2 years ago

Thanks, i'll fix padding the file names today.

sriharsh1104 commented 1 year ago

Feature Request:

When deploying the NFT images and metadata to IPFS, it is necessary to first upload the images (and get a unique CID). Then I need to update the JSON files to point at this CID. I can not create the CID in advance of running the generative script (index.py) as I do not have the CID until I upload the images.

Could a script be added to run after the index.py & once I get the CID to go through all files in the metadata folder and update the baseURI to represent the IPFS CID? (Or regenerate them based on all-object.json?) Obviously the data needs to maintain the connection to the image. is these feature possible if yes than can you share a video reference or doc for the same .