How do Art NFTs leverage IPFS to store token metadata?

infernal_toast
2 min readMay 5, 2021

--

Many NFTs (non-fungible tokens) in Ethereum are representative of a work of art, or some sort of multimedia file.

In this case, the token itself is minted by the Artist (ERC721 or ERC1155 standard) and an attribute of the token, known as the Token URI, is set to a hyperlink to the media file, such as this:

https://cloudflare-ipfs.com/ipfs/QmaAC1ouJE2f18Xf7mYPMmDkWms9zCL1b7ZHqz8AnPri2j

(Synthesized Sunset — Pop Wonder World Collection)

What is IPFS and why do tokens do it this way?

A naive approach would host the media file (image/video/script) on a centralized server, such as Amazon or your own personal server so the media could be fetched from there. However, the token is designed to last forever and that personal server might disappear! That is a very bad idea and a mismatch of longevity.

Instead, the ‘deterministic fingerprint’ of the file can be derived using a hashing function such that the file, when hashed, will always result in that output hash (output number.) Then, the file can be ‘pinned’ to the decentralized IPFS system addressed by the file fingerprint hash.

This way, even if the file is removed/unpinned at a later time, anyone else can re-upload the same file back to IPFS and the URL will resolve properly again, meaning that the NFT will have a valid token URI path again!

So you see, by using an IPFS path to the media as the token URI data, the path is ‘universal’ using a decentralized and deterministic protocol. This allows the holder of the NFT to backup the media file and metadata for their NFT, which is normally pinned to IPFS, and that way they can re-pin the files back to IPFS at any time in the future!

Still confused? As an example, the image file for Synthesized Sunset has the IPFS hash of QmaAC1ouJE2f18Xf7mYPMmDkWms9zCL1b7ZHqz8AnPri2. That file will always have that hash and so routing to that hash is a universal and decentralized way to route to the file! (Torrents and their magnet links work in a similar way. )

--

--

No responses yet