NFTs: Seeing Through the Code

EVK
Coinmonks
Published in
4 min readApr 6, 2022

--

NFTs are usually presented as a completely separate phenomenon from the “fungible” tokens that many are more familiar with.

People try to explain what they are by making real-world analogies, likening them to “collectibles,” or to “art,” or to “certificates of authenticity.” These are all decent analogies, but they are shorthand interpretations of a highly multi-faceted underlying phenomena.

The “aha” moment for me came from looking at the code of the underlying token contracts.

Technical Primer on Fungible vs Non-Fungible Tokens

At a technical level, NFTs and their “fungible” counterparts (hereafter simply called “tokens”) are nearly identical (below we cover how this works on Ethereum, but it works basically the same on other smart contract blockchains).

Both kinds of tokens are implemented using smart contracts. Every token, and every NFT collection, is a contract. The only difference between tokens & NFTs are the standard set of methods that the contract must implement (ERC-20 for fungible tokens; ERC-721 for NFTs).

ERC-20 (for fungible tokens)

Fungible token API

ERC-721 (for NFTs)

Non-Fungible Token API

Commonalities

We see that both tokens & NFTs include many contract methods in common:

  • Get Name (e.g. Shiba Inu)
  • Get Symbol (e.g. SHIB)
  • Get Decimals (e.g. 18)
  • Get Total Supply (e.g. 100000000)
  • Get Balance (for fungible tokens, that means how many units wallet ‘x’ holds; for NFTs, it means how many items in the collection wallet ‘x’ holds)

Differences

There are really only two differences:

  • Amounts vs IDs
    -
    For Tokens, wallets can hold or transfer a continuous unit “amount”
    -
    For NFTs, wallets can hold or transfer specific item IDs.
  • Metadata: NFTs have a method to obtain additional information (“metadata”) about specific items. This information is also standardized and contains things like:
    - Item Name
    - Item Description
    - Image URL / YouTube URL
    - Attribute List (Attributes are arbitrary text properties, e.g. Eyes=”Bored”; Earring=”Gold Stud”, etc).

Inscribing Ownership on the Blockchain

When you buy a (fungible) token, your wallet’s account address gets stored into some state variable in the token contract that maps accounts to balances (e.g. “balanceOf” from the WETH contract below). Any changes to these state variables are permanently inscribed on the blockchain.

There’s your WETH! Stored in the “balanceOf” variable

And when you buy an NFT, it’s the same deal. Your wallet’s account address gets stored in a state variable that maps accounts to sets of IDs. (e.g. “_holderTokens” from the Bored Ape Yacht Club contract below):

There’s your ape! Stored in the “_holderTokens” variable
I don’t even see the contract code anymore. I see Bored Apes, CryptoPunks…

Implications

Take a step back and zoom out. Forget what you know about how fungible vs non-fungible tokens are used today. Imagine this is Day 1, and we are giving both these primitives to entrepreneurs and builders worldwide to create value with, however they see fit.

Why would you be bullish on assets constructed via the first mechanism, but not the second? That would make no sense.

It’s all the same blockspace that you’re bidding on. In both cases, when you buy assets, you’re inscribing your account address into the state database that is Ethereum.

The first mechanism (for fungible tokens) is convenient for creating a divisible continuum of value; the second (for NFTs) gives us discrete “points” instead. Furthermore, those discrete “points” can store almost any additional information we want, so they are extremely information-dense.

It’s as if, for years, before NFTs started exploding into popular usage relatively recently, smart contract networks were using less than half of the expressive power of tokens.

The NFT sub-space inside the crypto asset class is extremely under-explored. It shouldn’t be surprising at all to see it growing at a significantly faster rate.

It will be a frustrating & random-seeming exercise for investors to try to predict where and how capital and value will settle across this sub-space, but there is little doubt that relative inflows are going to continue to come.

So calling them “Collectibles”, “Art” — yes, these make perfect sense, but these are just shadows on the cave wall. They are just examples of design patterns in the way we use a powerful underlying primitive, which has a vast, wide-open design space to explore.

Join Coinmonks Telegram Channel and Youtube Channel learn about crypto trading and investing

Also, Read

--

--