Hosting ERC721 metadata

Hey Good tutorial thanks

Got it all working and added the meta using json server / github.
I however have a question if i may!

In the token URI I am passing in a url with the token index /0 etc to the json file, and the deploy url is something like “http://my-json-server.typicode.com/user/main/tokens/” where the token is of course added as /0. This results in a BIG JSON file to maintain and update for thousands of tokens. So is it not better to have something like this to support a JSON file per token…

module.exports = function(deployer) { deployer.deploy(ERC721PresetMinterPauserAutoId, "SEGG TOKEN","SEGG", "http://myurl.com/nfts/token-"+{tokenid}+".json"); }; Where the token id is passed into the url to support multiple filenames rather than appended on the end of the folder path?

Thanks for any thoughts.

1 Like

Hi @Peter_Sparks,

Welcome to the community :wave:

For a production system you should look at creating a service/API to provide the metadata. The example using my-json-server is just for the purposes of the tutorial.

To use a URI scheme other than baseURI + tokenID, you could either save a tokenURI per token (which would be expensive for minting) or override tokenURI function to use the scheme you want. For lower cost minting, I would suggest just using baseURI + tokenID e.g. e.g. https://example.com/api/tokens/0

Thanks for the quick replay and thanks for the welcome. Glad to be here :slight_smile:

I had thought of the API, but then all validity of the actual token content itself is centralised?
Sure you have an NFT but only in that the url differs and with no reference to the item the transaction represents?

Sorry so is it not possible to change the registered

1 Like

Hi @Peter_Sparks,

You can use decentralized storage, so set a token URI per token ID when minting. Minting will be more expensive but the metadata won’t be centralized.

Please note, to ensure the availability of data when using IPFS you will need to pin it.

Thanks
But is that not static files, a static JSON and accompanying image for example?

Your first point was over an API instead of a single file serving the JSON / Meta from the token identifier. I would not put my PHP/MYSQL stack as an API on IPFS would i?

1 Like

Hi @Peter_Sparks,

Your choices are centralized or decentralized for your metadata.

If you use decentralized then you can store an IPFS hash for each token ID. This is static data. If you want to change it, then you would need to update each token with a new hash.

If you choose centralized, you provide JSON, which can either be static or dynamic.

It really depends on your use case. You want to make the token metadata available for the life of the token.