ERC721 Metadata Storage + Reading Contract Data

Hi everyone :slight_smile:

Been minting NFTs thru platforms like Rarible and OS for a few months now but have decided to take a leap of faith and develop my own smart contract for a GAN project.

Currently I have a .py script which generates X amount of images, uploads and pins to IPFS, then generates a JSON file for the token metadata.

My dilemma is how do I host this metadata, currently I’ve been playing around with fake REST apis but have ran into the problem of Heroku’s temporary storage, I’m thinking I need to somehow push my JSON metadata from Python into a Mongo or Postgres DB which can then be resolved as the db.JSON file on my token metadata api, is this the correct way to do this?

Alternatively my last resort will be simply generating a final JSON output of all token metadata and deploying it from Heroku at the start as static data, this breaks the data flow so would be preferable to have it all linked from image/metadata generation to minting tokens as opposed to manually uploading db.json.

My final question is how do I read my smart contract from my metadata api?
For example I’d like the API to only show token ids up to the totalSupply read from the contract, is there an easy way to do this? or an easy way to pull totalSupply int?

I’m learning on the fly here coming from very basic Python knowledge so would appreciate any resources or any push in the right direction.

Thanks :smile:

1 Like

I wrote a short article that might help you make a decision on this topic.

2 Likes

Hi @Fiends_World,

Welcome to the community :wave:

If you know all of your metadata at token deployment, then you could upload all of your metadata as a directory to IPFS, and then you could have a base URI of your IPFS hash, and your token URI for each tokenID could be ipfs://[IPFS HASH]/[tokenID].

I have also used GitHub pages to store metadata for a centralized approach.

2 Likes

from what i have seen Rarible hosts the metadata on IPFS as well - so when you create your NFT all data referenced by the smart contract is on IPFS, both the content and the metadata.

2 Likes

Thanks for the response.

Sorry to be a pain but did you have any resources or tips for uploading to IPFS wrapped with a directory so I could go this route?

Not sure how to upload to Pinata in such a way that I could return ipfs://[IPFS HASH]/[tokenID] without the end containing filename e.g ipfs://[IPFS HASH]/1.JSON

Thanks

1 Like

Hi @Fiends_World,

Rename your files so they don’t have an extension, e.g. so they are named 1 rather than 1.json and then upload the directory to IPFS.

1 Like

Ah I see, thanks a lot :smile:

1 Like

Hey mate, sorry one last question haha.

When using ERC721PresetMinterPauserAutoId preset, is it the person calling the SafeMint function who pays mint gas fee, or is it on the Smart Contract?

Cheers

1 Like

It’s the person who makes the call

2 Likes