Million Dollar Pixels: Diving into NFT Decentralization, Copyright, and Minting by@andyleroy

Million Dollar Pixels: Diving into NFT Decentralization, Copyright, and Minting

image
Andy LeRoy HackerNoon profile picture

Andy LeRoy

Building Analytics for the Bitcoin Lightning Network @ ExponentialLayers.com

The picture in this article preview is a copy of Bored Ape 7729.  This particular Bored Ape - number one of 10,000 in its 'family' collection - can be yours right now... for $345k.

Earlier this year, Beeple sold this NFT ...for $69 million.

To round out the examples, this flying poptart cat picture sold for nearly $600k.

As part of writing this article I had to double check - sure enough Ja Rule sold a FyreFest NFT for $122k.  Imagine the hype for an exclusive Billy McFarland x Theranos crossover NFT drop.

image

We've heard about NFTs these last few years - it's almost daily that some pixelated artwork makes headlines for its million-dollar sale.  But how do they work?  Are these a giant Ponzi scheme or the next big metaverse investment opportunity?

The list of companies joining the NFT space is long - Nike, Adidas, and Visa are all getting involved.  Taco Bell is even dishing out NFTs to help us Live Mas.

And the money flowing in and valuations are stratospheric: OpenSea recently raised $300 Million at a $13 Billion Valuation, and Dapper Labs (behind NBA Top Shots) raised $250 million at a $7.6 Billion valuation.

I have long been curious about NFTs, so in this article we'll explore it all...

How big is the NFT opportunity?  How is value created digitally on the blockchain?  Why is any of this important?

We'll also break down the technical components of how NFTs work and the different networks that make it possible.  How decentralized are these networks and their NFTs?

And we'll go full 'right click save' mode and remint a $300k Bored Ape (and also create a brand new NFT) using the great resources and tutorials from Alchemy, IPFS, and Filebase in a demo.

Crypto Kitties and Bored Apes - NFTs and the Intersection of IRL and Digital Communities


"Crypto" covers just about everything.  Macroeconomics, game theory, monetary policy, politics, economic incentives, and world-changing protocol design.

With NFTs, it gets absolutely wild.  Pump and dump schemes, Ape Coins, and discord servers with dedicated #gm (good morning) and meme generation channels abound.

If you ever need an extra dose of chaos or entertainment, just sign in to a random crypto coin, DAO, or NFT Discord Server at 10pm at night.  Schemes for days.

image

But this energy and a new sense of community have quickly formed over the last few years.  In his podcast, Invest Like the Best, Patrick O'Shaughnessy brought on Eric Golden, a Fidelity money manager and owner of a Bored Ape.

Their conversation was fascinating.  Shaq, Neymar, Justin Bieber, and Paris Hilton all own Bored Apes.  An entire community exists, with special chat rooms, and worldwide parties for owners.  It's like a country club that spans the physical and digital worlds.

And it's not just Bored Apes that have captured everyone's attention.  Back in 2017, the Crypto Kitty revolution started, where digital cats could breed with each other on the blockchain.  At one point, the Crypto Kitty activity on the blockchain made up an estimated 25% of the Ethereum network.  To quote the term VentureBeat coined in their article - the "Kittyverse" is just now a full Metaverse.

image

This whole idea of community and ownership continues to take a new prominent role in our ever-growing digital society.

And with more of our lives being lived in the digital world, having control and transparency of digital property is so powerful, and it offers ownership in a world where the value of traditional user-generated content has accrued to the platforms, rather than the creators.

Layer on the creativity of the communities and the idea that a digital creation (artwork) can be augmented and improved over time, benefits can be accrued to the holder, and governance can be established (DAOs) - the opportunities hold great promise.

How Big is the NFT Opportunity & Market?


The list goes on and on of companies making their way into the blockchain space - and more specifically the web3/NFT space.

So is this a giant pyramid scheme or the foundations of the Metaverse?  There is certainly some healthy skepticism to pair with the high flying valuations.

image

But that hasn't slowed down some of the growth in the NFT space.  A few more high-level numbers and growth statistics - all of these are pulled from the annual report from nonfungible.com

  • Total NFTs Sold: In 2021, 27.4 million NFTs were sold - a 1,800% increase from 2020

  • Total NFT Sales (Volume): In 2021 $17.6 Billion was traded, a 21,350% increase from 2020

  • Average Sales Price: In 2021, the Average NFT went for $807, up from $49 one year earlier

The Network Effect - Analyzing On Chain Metrics and Blockchain Network Activity


All of the above statistics are pulled from third party research, but because everything is recorded on the blockchain, it can all be verified.  We won't be downloading, indexing, and querying the Ethereum blockchain here, but it is worth taking a look at the mechanics of Minting NFTs and the network they are built on.

NFTs are stored on a blockchain - the most common blockchain is Ethereum.  Decentralization and blockchain adoption is key - if a blockchain does not hold its value over time, the NFT will also lose value.  And an NFT cannot be 'transferred' to another blockchain.

There are Blockchains beyond Ethereum, and some Blockchains are layers on top of Ethereum (L2's).  But a blockchain can only be as decentralized as the network(s) below it.  If an NFT blockchain is an Ethereum Layer 2, this may offer faster transactions or more features, but at the end of the day, the transaction has to make it onto Ethereum in some form.

As such, an NFT minted on the Ethereum blockchain is a bet on that blockchain winning out over others (like Solana).

[Bitcoin is in an asset class by itself and NFTs are not directly related to Bitcoin]

Ethereum Contracts, Transaction, and Blocks

Ethereum operates as a world computer, and it is a decentralized state machine.  Every ~12 to 14 seconds, a new block is mined.  Within each block are transactions, which are changes to the global state.  For example, if a smart contract was executed, a new contract was created, Ethereum was exchanged, or new data was recorded - all of these would change the state of the network, and would be included in a block.

Some operations are more computationally expensive than others, and someone's server out there has to handle the load to execute the changes, so Ethereum has a concept of 'gas' which is a unit of compute.  Gas costs money (measured in Eth) and is paid to the miner who takes care of the computation.

Ethereum block size target is 15k gas, with an upper bound of 30k.  In other words, there is a maximum amount of computation that can be packaged up in each block.  It will resize based on demand on the network, but this offers an upper bound on the overall network.  Every ~12 seconds, the state of the global network is updated for every participating node, complete with any network additions or changes that have taken place.

NFT's are required to be recorded on the Ethereum network.  First a contract must be created and added to the network.  And then the specific NFT data must be sent to the created contract. There are more than 3 million smart contracts on the Ethereum Network.  Of those, ~10,000 contracts are dedicated to being able to create and transfer NFTs.

image

When the crypto kitty craze took off, it accounted for 25% of Ethereum network activity.  Does this make NFT’s or Ethereum valuable?  Maybe... Netflix makes up some 12% of internet traffic, but doesn't accrue all of the value of the network.  But this is a good benchmark for volume, and serves as a demand factor for valuing Ethereum.

Can I Right Click Save an NFT? Truth, Copyright, Ownership, and Value


“Can I right click save an NFT”?  Yes, this is possible.  It is even possible to remint the original image (we will do that in a demo below).  But just like physical artwork or a collectors edition baseball card, the original is where all of the value is - copies are worthless.

With any art, value is all in the eye of the beholder and subject to supply and demand.  The Bored Ape collection has value because they are scarce (only 10k of them).  And the creator and their community matter.  A random person dunking a basketball is not going to command the same as Lebron James doing the same.

image

But who says what the 'authentic' picture of Lebron's dunk is?  There may have been hundreds of people who captured the same dunk on their iPhone. Could they all mint their photos as an NFT and make thousands?  This is again where community, network effects, and ongoing digital rights come into play.  If Lebron himself mints the photo it would have tremendous value.  And if an 'official partner' of the NBA such as Dapper Labs, does the same it too could hold the value.

Beyond just a collectible, NFTs can have Utility Value.  Patrick O'Shaughnessy references this throughout many of his podcast conversations on NFTs and Blockchain - using the idea of a unique digital sword or clothing item that could appear in an online game.

For me personally, one of the most exciting and interesting things about NFTs is the ability to make a unique, verifiable token of anything - and preserve ownership rights.

If I own the private key to a digital item, I can cryptographically prove ownership.  And as this moves from art to things like a car title, housing deed, or certificate of stock in a company, the possibilities are much more real.

Combining smart contracts on Ethereum, a decentralized way to move data on chain (Chainlink), and decentralized storage mechanisms gives us a much clearer path to understand what is 'real' in our evolving digital society.  It gives back a premium and avenue for truth and ownership.

How Do NFTs Actually Work?


Decentralized File Storage

The first step to creating an NFT is to store the data somewhere.  And it has to be decentralized.  The whole point of an NFT is that it is unique, and cannot be changed by anyone.  The data can’t (*shouldn't*) be exclusively stored on AWS or Azure, as this gives the uploader or the cloud platform the ability to modify or restrict the data.

We talked a bit about the Ethereum network constraints.  Every byte that is stored on the Ethereum network costs money (200 gas per byte).  If a 2 Megabyte image (a common iPhone photo size) were to be stored on the blockchain, it would cost nearly 18 Eth - which at today’s prices would be about $50k.  This is infeasible for nearly all digital art, so the NFT can’t be stored directly on the Ethereum blockchain.

So the data can’t be stored on a cloud provider and it can't be stored directly on the blockchain…what are the other options?  Enter IPFS (Interplanetary File System).  IPFS offers a peer to peer decentralized platform for storing any files.  In a way it is a bit like LimeWire used to be.

IPFS works by using Content Addressing.  Any file (which is just 1’s and 0’s) is run through a hashing algorithm to get a unique CID.  If I write 'hello world' in a text file and upload it, it will be the exact same CID as your text file with the same content.  If we change the text and reupload the file, the CID will be completely different.  IPFS and Filebase offer some great background content into the mechanics of how this all works, and Filebase walks through all of the various networks in detail.

Anyone can download IPFS - they make a Desktop GUI Application.  And you can test it out by uploading various files and seeing what the CID is (be careful, these files can theoretically be around forever).

Pinning Data

With this CID the data can now be shared globally using the IPFS platform and protocol.  But who wants to store any files?  File storage costs money and no one does this for free.  This is where the concept of pinning comes in.

With pinning, a storage provider will store the file (identified by CID) on their servers.  Anyone can browse to this file (and repin it) as ong as it remains pinned by someone on the IPFS network.

Just like Ethereum needs to keep its decentralization and network effects, IPFS must maintain the same for any NFTs to preserve their value.

Multiple IPFS Pinning Services and protocols have become available lately.  Some are more centralized than others, and some are blockchain based with their own tokens.  Pinning is not free, so various incentive structures are in place for third parties to offer their pinning (storage) services.

In our demo below we will use both Filebase and Pinata for pinning the files we upload to IPFS.

Minting an NFT

The first step to creating an NFT is to upload the image/file itself to an IPFS provider.  This could be our own instance of IPFS, but we want to make sure the file will stay pinned, so we can also use a service such as Filebase.

After uploading the file to IPFS, we get its CID and will create a metadata file pointing to this new ID.  We then upload that metadata json file back to IPFS, again giving a different CID.

Lastly we need to store our record of ownership of the metadata file, which points to the actual image, on chain.  To do this requires an Ethereum Contract (ERC 721).  After the contract is created, we can then invoke it with the specifics of our Content ID and send all of the data to the Ethereum Network.

Minting an NFT on Ethereum - A Demo with Alchemy, IPFS, and Filebase


To see everything in action, we will walk through minting our own NFT.  The end result is your very own MetaMask wallet with your own collection of NFTs.  (For me, that is a picture of my brother's dog, alongside a couple of reminted Bored Apes)

image

The final code for this tutorial is here.

And the demo NFT Contract and interactions can all be seen on the Ropsten Ethereum network here.

Much of the code and details to deploy an NFT Contract, Mint a new NFT, and view it in a Wallet (MetaMask) are all covered in the fantastic tutorials here from Alchemy and Filebase (all using Hardhat scaffolding).

Rather than go line by line through them, I'll add a few notes, from where I ran into questions, to augment their fantastic resources. And in the spirit of decentralization, there are many great companies that support Ethereum node-as-a-service development. QuickNode is another fantastic provider of all underlying blockchain infrastructure that offers a fast track for NFT contract development and deployment.

  • You can demo IPFS as much as needed by downloading their Desktop GUI here.  Once downloaded, you can upload test files or directories and see how CIDs are created.
  • You can use Filebase and Pinata to create accounts and upload the same files from your local testing.  You can see they get the exact same CIDs even on remote platforms.
  • I was a bit confused seeing different CIDs between Pinata and Filebase - there are two versions of CIDs.  Filebase uses the V1 version and Pinata the V0 version.
  • When creating the metadata files, you can use either version of the IPFS links for the CIDs created.
  • There is another form of centralization to account for, which is IPFS Gateways.  See the next section for more details.
  • To see the metadata and IPFS CIDs for an existing NFT, you can head over to OpenSea, find the NFT, and click the metadata details.  You can then download the data.  Even when uploading the image to your local IPFS, you'll get the same CID (which is expected).
  • Filebase has some great resources about how they handle data storage and compute.  They offer IPFS storage, but also ensure decentralized pinning, taking care of all details to create contracts with storage partners on the Sia Network.  Their docs are great.
  • The NFT Contract deployed in the github code linked is updated a bit from the sample code from Alchemy.  This captures some recent changes to OpenZepplin extensions for ERC 721.
  • To transfer an NFT from one account to another, the contract deployed has inherited methods like transferFrom that can be used (example code here)

image

image

Big thanks to Alchemy and Filebase for their great tutorials and resources.

How Decentralized Are NFTs?


To recap everything so far:

  • NFT's are created by uploading a file to IPFS

  • The IPFS image is then referenced in a metadata file pointing to the IPFS image, which is also uploaded to IPFS

  • The metadata file is linked to the blockchain with an on chain transaction to a deployed ERC 721 contract.

The maximum decentralization of an NFT therefore is limited to how decentralized the Blockchain network is (Ethereum in most cases), how decentralized IPFS is, and how decentralized the interactions between each system is.

The decentralization of the Ethereum network involves many components (soon to be staking and Proof of Stake, roadmap, deployment process), all covered outside of this article.

IPFS is a protocol for file addressing and sharing that enables anyone to host and pin a file in a fully decentralized manner.  While the file may end up pinned on AWS or a third party vendor, or even replicated on another decentralized network, there are protocols in the middle that allow 'sovereign' hosting of any content and the choice of any pinning vendor if desired.

The last piece is the communication between everything, and specifically the IPFS Gateway.  When a file is referenced from the blockchain, it needs an HTTP link to point to the metadata.  In the demo we could use Filebase, which uses the dweb.link gateway, or Pinata, which uses the gateway.pinata.cloud gateway.

I'm not sure of the best way around this gateway centralization.  Any third party gateway requires a centralization of trust.  From what I understand, as more browsers or clients build for the IPFS protocol, this centralization risk of any one gateway being offline or taken down goes away as the client could iterate multiple gateways using the file CID by itself.  So instead of adding a transaction record to the blockchain with a specific CID, we could just use the file CID itself.  The Brave browser for example auto links from a CID to a dweb extension (ie type in this and see the auto redirect): ipfs://QmbUpvyA86q2GLSh1VKKyugNyoJdKFcthX8Joy5mtU2FSv/ There is also an option to self host a gateway that would route back to the underlying CID on the IPFS network. So there are options for decentralization here.

I'll keep digging here and see what I can find, and if you are reading this far please let me know what I may be missing or any other factors to consider.

Conclusion


While the NFT space may be rife with gambling and the occasional scam, and overvalued in 90% of cases, there is already great demonstrated value.  And the underlying principles of cryptographic ownership, decentralization, and transparency will continue to prove invaluable as we all seek truth and digital property rights heading into the next evolution of our digital world.

If you enjoy this kind of content, please subscribe to the Exponential Layers newsletter to get all updates on new videos and articles.


Welcome to the Decentralized Internet Contest!

The picture in this article preview is a copy of Bored Ape 7729.  This particular Bored Ape - number one of 10,000 in its 'family' collection - can be yours right now... for $345k.

Earlier this year, Beeple sold this NFT ...for $69 million.

To round out the examples, this flying poptart cat picture sold for nearly $600k.

As part of writing this article I had to double check - sure enough Ja Rule sold a FyreFest NFT for $122k.  Imagine the hype for an exclusive Billy McFarland x Theranos crossover NFT drop.

image

We've heard about NFTs these last few years - it's almost daily that some pixelated artwork makes headlines for its million-dollar sale.  But how do they work?  Are these a giant Ponzi scheme or the next big metaverse investment opportunity?

The list of companies joining the NFT space is long - Nike, Adidas, and Visa are all getting involved.  Taco Bell is even dishing out NFTs to help us Live Mas.

And the money flowing in and valuations are stratospheric: OpenSea recently raised $300 Million at a $13 Billion Valuation, and Dapper Labs (behind NBA Top Shots) raised $250 million at a $7.6 Billion valuation.

I have long been curious about NFTs, so in this article we'll explore it all...

How big is the NFT opportunity?  How is value created digitally on the blockchain?  Why is any of this important?

We'll also break down the technical components of how NFTs work and the different networks that make it possible.  How decentralized are these networks and their NFTs?

And we'll go full 'right click save' mode and remint a $300k Bored Ape (and also create a brand new NFT) using the great resources and tutorials from Alchemy, IPFS, and Filebase in a demo.

Crypto Kitties and Bored Apes - NFTs and the Intersection of IRL and Digital Communities


"Crypto" covers just about everything.  Macroeconomics, game theory, monetary policy, politics, economic incentives, and world-changing protocol design.

With NFTs, it gets absolutely wild.  Pump and dump schemes, Ape Coins, and discord servers with dedicated #gm (good morning) and meme generation channels abound.

If you ever need an extra dose of chaos or entertainment, just sign in to a random crypto coin, DAO, or NFT Discord Server at 10pm at night.  Schemes for days.

image

But this energy and a new sense of community have quickly formed over the last few years.  In his podcast, Invest Like the Best, Patrick O'Shaughnessy brought on Eric Golden, a Fidelity money manager and owner of a Bored Ape.

Their conversation was fascinating.  Shaq, Neymar, Justin Bieber, and Paris Hilton all own Bored Apes.  An entire community exists, with special chat rooms, and worldwide parties for owners.  It's like a country club that spans the physical and digital worlds.

And it's not just Bored Apes that have captured everyone's attention.  Back in 2017, the Crypto Kitty revolution started, where digital cats could breed with each other on the blockchain.  At one point, the Crypto Kitty activity on the blockchain made up an estimated 25% of the Ethereum network.  To quote the term VentureBeat coined in their article - the "Kittyverse" is just now a full Metaverse.

image

This whole idea of community and ownership continues to take a new prominent role in our ever-growing digital society.

And with more of our lives being lived in the digital world, having control and transparency of digital property is so powerful, and it offers ownership in a world where the value of traditional user-generated content has accrued to the platforms, rather than the creators.

Layer on the creativity of the communities and the idea that a digital creation (artwork) can be augmented and improved over time, benefits can be accrued to the holder, and governance can be established (DAOs) - the opportunities hold great promise.

How Big is the NFT Opportunity & Market?


The list goes on and on of companies making their way into the blockchain space - and more specifically the web3/NFT space.

So is this a giant pyramid scheme or the foundations of the Metaverse?  There is certainly some healthy skepticism to pair with the high flying valuations.

image

But that hasn't slowed down some of the growth in the NFT space.  A few more high-level numbers and growth statistics - all of these are pulled from the annual report from nonfungible.com

  • Total NFTs Sold: In 2021, 27.4 million NFTs were sold - a 1,800% increase from 2020

  • Total NFT Sales (Volume): In 2021 $17.6 Billion was traded, a 21,350% increase from 2020

  • Average Sales Price: In 2021, the Average NFT went for $807, up from $49 one year earlier

The Network Effect - Analyzing On Chain Metrics and Blockchain Network Activity


All of the above statistics are pulled from third party research, but because everything is recorded on the blockchain, it can all be verified.  We won't be downloading, indexing, and querying the Ethereum blockchain here, but it is worth taking a look at the mechanics of Minting NFTs and the network they are built on.

NFTs are stored on a blockchain - the most common blockchain is Ethereum.  Decentralization and blockchain adoption is key - if a blockchain does not hold its value over time, the NFT will also lose value.  And an NFT cannot be 'transferred' to another blockchain.

There are Blockchains beyond Ethereum, and some Blockchains are layers on top of Ethereum (L2's).  But a blockchain can only be as decentralized as the network(s) below it.  If an NFT blockchain is an Ethereum Layer 2, this may offer faster transactions or more features, but at the end of the day, the transaction has to make it onto Ethereum in some form.

As such, an NFT minted on the Ethereum blockchain is a bet on that blockchain winning out over others (like Solana).

[Bitcoin is in an asset class by itself and NFTs are not directly related to Bitcoin]

Ethereum Contracts, Transaction, and Blocks

Ethereum operates as a world computer, and it is a decentralized state machine.  Every ~12 to 14 seconds, a new block is mined.  Within each block are transactions, which are changes to the global state.  For example, if a smart contract was executed, a new contract was created, Ethereum was exchanged, or new data was recorded - all of these would change the state of the network, and would be included in a block.

Some operations are more computationally expensive than others, and someone's server out there has to handle the load to execute the changes, so Ethereum has a concept of 'gas' which is a unit of compute.  Gas costs money (measured in Eth) and is paid to the miner who takes care of the computation.

Ethereum block size target is 15k gas, with an upper bound of 30k.  In other words, there is a maximum amount of computation that can be packaged up in each block.  It will resize based on demand on the network, but this offers an upper bound on the overall network.  Every ~12 seconds, the state of the global network is updated for every participating node, complete with any network additions or changes that have taken place.

NFT's are required to be recorded on the Ethereum network.  First a contract must be created and added to the network.  And then the specific NFT data must be sent to the created contract. There are more than 3 million smart contracts on the Ethereum Network.  Of those, ~10,000 contracts are dedicated to being able to create and transfer NFTs.

image

When the crypto kitty craze took off, it accounted for 25% of Ethereum network activity.  Does this make NFT’s or Ethereum valuable?  Maybe... Netflix makes up some 12% of internet traffic, but doesn't accrue all of the value of the network.  But this is a good benchmark for volume, and serves as a demand factor for valuing Ethereum.

Can I Right Click Save an NFT? Truth, Copyright, Ownership, and Value


“Can I right click save an NFT”?  Yes, this is possible.  It is even possible to remint the original image (we will do that in a demo below).  But just like physical artwork or a collectors edition baseball card, the original is where all of the value is - copies are worthless.

With any art, value is all in the eye of the beholder and subject to supply and demand.  The Bored Ape collection has value because they are scarce (only 10k of them).  And the creator and their community matter.  A random person dunking a basketball is not going to command the same as Lebron James doing the same.

image

But who says what the 'authentic' picture of Lebron's dunk is?  There may have been hundreds of people who captured the same dunk on their iPhone. Could they all mint their photos as an NFT and make thousands?  This is again where community, network effects, and ongoing digital rights come into play.  If Lebron himself mints the photo it would have tremendous value.  And if an 'official partner' of the NBA such as Dapper Labs, does the same it too could hold the value.

Beyond just a collectible, NFTs can have Utility Value.  Patrick O'Shaughnessy references this throughout many of his podcast conversations on NFTs and Blockchain - using the idea of a unique digital sword or clothing item that could appear in an online game.

For me personally, one of the most exciting and interesting things about NFTs is the ability to make a unique, verifiable token of anything - and preserve ownership rights.

If I own the private key to a digital item, I can cryptographically prove ownership.  And as this moves from art to things like a car title, housing deed, or certificate of stock in a company, the possibilities are much more real.

Combining smart contracts on Ethereum, a decentralized way to move data on chain (Chainlink), and decentralized storage mechanisms gives us a much clearer path to understand what is 'real' in our evolving digital society.  It gives back a premium and avenue for truth and ownership.

How Do NFTs Actually Work?


Decentralized File Storage

The first step to creating an NFT is to store the data somewhere.  And it has to be decentralized.  The whole point of an NFT is that it is unique, and cannot be changed by anyone.  The data can’t (*shouldn't*) be exclusively stored on AWS or Azure, as this gives the uploader or the cloud platform the ability to modify or restrict the data.

We talked a bit about the Ethereum network constraints.  Every byte that is stored on the Ethereum network costs money (200 gas per byte).  If a 2 Megabyte image (a common iPhone photo size) were to be stored on the blockchain, it would cost nearly 18 Eth - which at today’s prices would be about $50k.  This is infeasible for nearly all digital art, so the NFT can’t be stored directly on the Ethereum blockchain.

So the data can’t be stored on a cloud provider and it can't be stored directly on the blockchain…what are the other options?  Enter IPFS (Interplanetary File System).  IPFS offers a peer to peer decentralized platform for storing any files.  In a way it is a bit like LimeWire used to be.

IPFS works by using Content Addressing.  Any file (which is just 1’s and 0’s) is run through a hashing algorithm to get a unique CID.  If I write 'hello world' in a text file and upload it, it will be the exact same CID as your text file with the same content.  If we change the text and reupload the file, the CID will be completely different.  IPFS and Filebase offer some great background content into the mechanics of how this all works, and Filebase walks through all of the various networks in detail.

Anyone can download IPFS - they make a Desktop GUI Application.  And you can test it out by uploading various files and seeing what the CID is (be careful, these files can theoretically be around forever).

Pinning Data

With this CID the data can now be shared globally using the IPFS platform and protocol.  But who wants to store any files?  File storage costs money and no one does this for free.  This is where the concept of pinning comes in.

With pinning, a storage provider will store the file (identified by CID) on their servers.  Anyone can browse to this file (and repin it) as ong as it remains pinned by someone on the IPFS network.

Just like Ethereum needs to keep its decentralization and network effects, IPFS must maintain the same for any NFTs to preserve their value.

Multiple IPFS Pinning Services and protocols have become available lately.  Some are more centralized than others, and some are blockchain based with their own tokens.  Pinning is not free, so various incentive structures are in place for third parties to offer their pinning (storage) services.

In our demo below we will use both Filebase and Pinata for pinning the files we upload to IPFS.

Minting an NFT

The first step to creating an NFT is to upload the image/file itself to an IPFS provider.  This could be our own instance of IPFS, but we want to make sure the file will stay pinned, so we can also use a service such as Filebase.

After uploading the file to IPFS, we get its CID and will create a metadata file pointing to this new ID.  We then upload that metadata json file back to IPFS, again giving a different CID.

Lastly we need to store our record of ownership of the metadata file, which points to the actual image, on chain.  To do this requires an Ethereum Contract (ERC 721).  After the contract is created, we can then invoke it with the specifics of our Content ID and send all of the data to the Ethereum Network.

Minting an NFT on Ethereum - A Demo with Alchemy, IPFS, and Filebase


To see everything in action, we will walk through minting our own NFT.  The end result is your very own MetaMask wallet with your own collection of NFTs.  (For me, that is a picture of my brother's dog, alongside a couple of reminted Bored Apes)

image

The final code for this tutorial is here.

And the demo NFT Contract and interactions can all be seen on the Ropsten Ethereum network here.

Much of the code and details to deploy an NFT Contract, Mint a new NFT, and view it in a Wallet (MetaMask) are all covered in the fantastic tutorials here from Alchemy and Filebase (all using Hardhat scaffolding).

Rather than go line by line through them, I'll add a few notes, from where I ran into questions, to augment their fantastic resources. And in the spirit of decentralization, there are many great companies that support Ethereum node-as-a-service development. QuickNode is another fantastic provider of all underlying blockchain infrastructure that offers a fast track for NFT contract development and deployment.

  • You can demo IPFS as much as needed by downloading their Desktop GUI here.  Once downloaded, you can upload test files or directories and see how CIDs are created.
  • You can use Filebase and Pinata to create accounts and upload the same files from your local testing.  You can see they get the exact same CIDs even on remote platforms.
  • I was a bit confused seeing different CIDs between Pinata and Filebase - there are two versions of CIDs.  Filebase uses the V1 version and Pinata the V0 version.
  • When creating the metadata files, you can use either version of the IPFS links for the CIDs created.
  • There is another form of centralization to account for, which is IPFS Gateways.  See the next section for more details.
  • To see the metadata and IPFS CIDs for an existing NFT, you can head over to OpenSea, find the NFT, and click the metadata details.  You can then download the data.  Even when uploading the image to your local IPFS, you'll get the same CID (which is expected).
  • Filebase has some great resources about how they handle data storage and compute.  They offer IPFS storage, but also ensure decentralized pinning, taking care of all details to create contracts with storage partners on the Sia Network.  Their docs are great.
  • The NFT Contract deployed in the github code linked is updated a bit from the sample code from Alchemy.  This captures some recent changes to OpenZepplin extensions for ERC 721.
  • To transfer an NFT from one account to another, the contract deployed has inherited methods like transferFrom that can be used (example code here)

image

image

Big thanks to Alchemy and Filebase for their great tutorials and resources.

How Decentralized Are NFTs?


To recap everything so far:

  • NFT's are created by uploading a file to IPFS

  • The IPFS image is then referenced in a metadata file pointing to the IPFS image, which is also uploaded to IPFS

  • The metadata file is linked to the blockchain with an on chain transaction to a deployed ERC 721 contract.

The maximum decentralization of an NFT therefore is limited to how decentralized the Blockchain network is (Ethereum in most cases), how decentralized IPFS is, and how decentralized the interactions between each system is.

The decentralization of the Ethereum network involves many components (soon to be staking and Proof of Stake, roadmap, deployment process), all covered outside of this article.

IPFS is a protocol for file addressing and sharing that enables anyone to host and pin a file in a fully decentralized manner.  While the file may end up pinned on AWS or a third party vendor, or even replicated on another decentralized network, there are protocols in the middle that allow 'sovereign' hosting of any content and the choice of any pinning vendor if desired.

The last piece is the communication between everything, and specifically the IPFS Gateway.  When a file is referenced from the blockchain, it needs an HTTP link to point to the metadata.  In the demo we could use Filebase, which uses the dweb.link gateway, or Pinata, which uses the gateway.pinata.cloud gateway.

I'm not sure of the best way around this gateway centralization.  Any third party gateway requires a centralization of trust.  From what I understand, as more browsers or clients build for the IPFS protocol, this centralization risk of any one gateway being offline or taken down goes away as the client could iterate multiple gateways using the file CID by itself.  So instead of adding a transaction record to the blockchain with a specific CID, we could just use the file CID itself.  The Brave browser for example auto links from a CID to a dweb extension (ie type in this and see the auto redirect): ipfs://QmbUpvyA86q2GLSh1VKKyugNyoJdKFcthX8Joy5mtU2FSv/ There is also an option to self host a gateway that would route back to the underlying CID on the IPFS network. So there are options for decentralization here.

I'll keep digging here and see what I can find, and if you are reading this far please let me know what I may be missing or any other factors to consider.

Conclusion


While the NFT space may be rife with gambling and the occasional scam, and overvalued in 90% of cases, there is already great demonstrated value.  And the underlying principles of cryptographic ownership, decentralization, and transparency will continue to prove invaluable as we all seek truth and digital property rights heading into the next evolution of our digital world.

If you enjoy this kind of content, please subscribe to the Exponential Layers newsletter to get all updates on new videos and articles.

Comments

Signup or Login to Join the Discussion

Tags

Related Stories