Solidity Tutorial — How to Store NFT Metadata and SVG’s on the Blockchain

Andy Hartnett
3 min readSep 16, 2021

Recently I took a deep dive into the Crypto World. Especially on DeFi and Smart Contracts. So I did what probably every other developer has done that started working on the Block Chain. I minted my own NFT. Particularly an ERC-721 Token. This is an article I really wish I had a few weeks ago.

OpenSea Requirements For NFT’s

If you want your token to be available on Opensea you’ll need to follow the ERC721 standard. You can read full instructions on creating NFT’s to this standard on OpenSea’s Website . But the main requirement for these NFT’s is that your smart contract contains a tokenURI() method which returns the url containing your metadata.

Why Store On Chain

One of the biggest issues I’ve thought of when it comes to NFT’s is their immutability and permanence.

The immutability problem.

The smart contract on the chain always has the same tokenURI but there’s no guarantee that endpoint will always return the same thing. For example, say I have a webserver and I set up the webserver to return meta data based on the token number. Ex:

my-webserver-url.com/token/1

--

--

Andy Hartnett
Andy Hartnett

Responses (2)