How to Build ERC-721 NFTs with IPFS



The ERC-721 standard has given rise to the non-fungible token (NFT) market on Ethereum. ERC-721 is a standard for creating an NFT—a complicated way of saying “unique items”. Any unique thing can be an NFT. A house, a baseball card, a piece of art, etc. But the power is not in the item just being unique and digitized. The power is in verifiability. That’s where the ERC-721 standard shines.


The problem with creating ERC-721 tokens comes from storing the underlying assets. Blockchains are not great for storing large pieces of data. In 2017, Jamila Omar of Interplanetary Database estimated the cost of storing 1GB of data on Ethereum would be more than $4 million.

In general, the cost to store data on Ethereum works out to approximately 17,500 ETH/GB, or around $4,672,500 at today’s prices.
  • Jamila Omar, 2017

So if we know the cost of storing the assets tied to an NFT is too high to use a blockchain, what are the alternatives? We could store assets using traditional cloud storage. Amazon’s S3 and Microsoft’s Azure provide cheap storage solutions. However, traditional cloud storage as we know it has a major flaw.

It’s not cryptographically verifiable.


Verifiability

The whole point of an NFT is digital verification and control of what might be a physical or digital asset. If we cannot verify the underlying asset itself in a similar way to verifying the ownership of the token that represents the asset, we have lost track of the ultimate goal.


The solution to both problems is IPFS. IPFS is a distributed storage network. It works in a similar way to cloud storage. You make a request for content and that content is returned. However, the big difference is the content is stored by utilizing a global network of storage providers. IPFS leverages a tool called content addressability. This means that instead of you making a request to that data center in Ohio for a piece of content, you would instead make a request FOR the content itself. It might be located in Ohio. It might be located closer. With content addressability, you no longer have to rely on a single location for the retrieval of content. This is far more efficient for global blockchains.


IPFS also takes care of the verifiability for us. Because all content is defined and stored based on the content itself, should a piece of content be tampered with or changed, we would have a mismatch when trying to verify the content and know it is wrong. Let’s make this a little more clear with a simple example:

Alice stores a picture of a cat on IPFS and that cat picture is represented by a content identifier. For simplicity, let’s say the identifier is “C”.


Bob requests that cat picture and then draws a mustache on that poor cat. When Bob uploads his picture, he will no longer have the same identifier. Because he has changed the underlying data (from cat to mustachioed cat), Bob’s identifier might be “M”.


If Bob tried to pass his photo off as