Home What is an NFT? A Computer Scientist's Perspective
Post
Cancel

What is an NFT? A Computer Scientist's Perspective

NFTs have been all the rage for some time now. Twitter just introduced an NFT profile pictures where you can set your Twitter profile picture to an image that is “linked” to an NFT you own. But what are NFTs? And what can you do with those besides all the scams that are going around at the moment?

Introduction to Blockchains

Before talking about NFTs we need to establish some basics on blockchains. The most famous blockchain is the Bitcoin blockchain. The bitcoin blockchain is based on a peer-to-peer network, meaning there is not a single server or several servers owned by one person or company running the blockchain, but rather multiple different people running parts of the blockchain on their computers without a centralized owner. The Bitcoin blockchain can be seen as a database that stores information. The information stored is the balance of Bitcoin wallets and all the transactions made to transfer Bitcoin from one wallet to another. Every time new transactions are issued, a certain amount of them are bundled into a block, which a miner approves. When a block is approved, it is linked to the block that was approved before it, which forms a chain of blocks, hence the name blockchain. Once a block is approved, it can not be changed, and the information contained in it is forever stored on the blockchain. The whole blockchain, which is several 100GB large, is stored on all the nodes part of the peer-to-peer network and forms a global state machine where each transfer can be interpreted as a state transition.

The Ethereum General-purpose Blockchain

While the global state of the Bitcoin blockchain only stores the balance of wallets, the Ethereum blockchain can store data of any type as key-value pairs. For example, a key-value could be my name “K0nze” (value) references by the key “Author Name” (key) of this article. All those key-value pairs represent the global state of the Ethereum blockchain. A state transition to a new global state, adding, removing, or changing a key-value pair, is not done by transaction but by running code, so-called smart contracts. The smart contract code is executed on the Ethereum Virtual Machine, which we will call EVM from now on.

“The EVM is a global singleton, meaning that it operates as if it were a global, single-instance computer running everywhere” [1]. The EVM provides its own byte code for changing the global state of the blockchain. A compiler usually generates this byte code from a high-level language such as Solidty or Vyper.

For example, a Hello World smart contract in Solidity looks like this, which is very similar to Java:

1
2
3
4
5
6
7
pragma solidity ^0.6.4;

contract HelloWorld {
    function sayHello() pure public returns (string memory) {
        return "Hello, World!";
    }
}

When a smart contract is written and compiled into EVM byte code, it has to be added to the Ethereum blockchain first to run it. Therefore the byte code is sent to the Ethereum address 0x0000000000000000000000000000000000000000 in a contract creation transaction. This creates a new Ethereum account that is not owned by anyone, a so-called externally owned account (EOA) containing the byte code and an ether balance. To interact with the smart contract held by the EOA, one has to initiate a transfer, which does not have to include ether, to the EOA address and some data that specifies the method that is called together with its arguments that should be passed. Then the byte code with the provided arguments is executed on the EVM by miners on the peer-to-peer network. When the execution is successful, meaning the code terminates without errors, and the block the call of the smart contract is in is approved, the global state of the Ethereum blockchain is changed. This could mean adding, changing, or removing a key-value pair or a change in the balance of ether.

Tokens are Smart Contracts

According to the Longman Dictionary of Contemporary English (Affiliate Link) a token is “[…] a formal something that represents a […] fact, event, etc.”. A token has insignificant intrinsic value, such as laundry tokens or arcade game tokens [1].

Blockchain-based tokens can represent ownership, assets, or access rights. Compared to real-world tokens such as laundry tokes, there is only a limited amount of them. But on a blockchain, tokens can be generated on demand and used for multiple different purposes simultaneously.

Tokens are such an integral part of the Ethereum blockchain that there is an official token standard on how a token should be implemented. This standard is the ERC-20 Token Standard which defines what methods and data structures a token contract has to implement. An ERC-20 compliant smart contract can be seen as a bank; it tracks the balance of tokens in different accounts and transfers tokens between them.

The creator of the token contract can decide how and how many tokens are created and what they can be used for. For example, one could earn loyalty tokens for participating in a club’s events while the tokens are later on used to award special privileges depending on the person’s token balance.

Tokens vs. NFTs

As already stated, the ERC-20 Token Standard allows the token creator to create as many tokens as they like and are therefore fungible, meaning that the tokens are all the same and interchangeable, which does not allow for tracking the ownership of a unique thing such as a collectible, house, or in-game items.

While the ERC-20 Token Standard tracks the balance of an account with a mapping: account address -> token balance, the ERC-721 Non-Fungible Token Standard tracks the ownership of a unique ID of an account with a mapping: id -> account address. As ERC-721 does not place any restrictions on what the unique ID / NFT represents, the creator of the NFT contract can add multiple different functions to the ownership of an NFT.

And by the way, when someone says they have an NFT in their wallet, that is technically incorrect because the ownership of an NFT is tracked in the smart contract and not in the balance of someone’s blockchain wallet.

NFT Use Cases (Besides Certificate of Ownership)

The most well-known use case of NFTs these days (2022) is a certificate of digital art ownership. However, as digital art can be copied and shared without any restrictions, such a certificate of ownership mostly has only sentimental value. However, several different other use cases make sense in the real world.

The first example is voting. Whether it be votes in a company or a nationwide election, NFTs can be used to validate that someone has the right to vote by proving the ownership of an NFT and can track that a vote has been cast. Because NFTs are unique, it is impossible to cast more votes than NFTs owned by accounts.

Another great use case for NFTs are in-game items in video games. You could argue how is that different from a simple certificate of ownership? And yes, this can be the primary purpose of an NFT for in-game items. However, as one can enhance NFTs with their functions and properties, the owners can be tracked and as the leveling up of an item can be directly stored in the NFT. Take, for example, a Pokémon game where each Pokémon is unique and has different abilities depending on how it was trained, fed, and treated. Because the NFT associated with a Pokémon is data on the blockchain, the entire progress is tracked automatically.

Closely related to voting are tickets based on NFTs. NFTs establish a cryptographically single point of truth for the owner of the ticket and the organizer of an event. Therefore ticket forgery can be prevented as only the organizer can create tickets. Additionally, scalping of tickets can be prevented by adding a maximum resale price to the smart contract tracking the NFTs. Even after an event, NFT tickets can be used as loyalty tokens that allow for discounts and rewards at subsequent events.

It is not uncommon to order goods coming from another country or even continent in a globalized world such as ours. NFTs could provide means for tracking goods throughout their journey from the seller to the buyer. At each stop on its way, the NFT can track who handled the parcel and where. And it can also be used for authentication where the parcel is only handed over when the receiver proves that they hold the corresponding NFT.

The last example comes from my current line of work, academia. Even in the year 2022, it is pretty standard for German students to get a small piece of paper (Schein) that proves the successful attendance of a course. This Schein is then brought to the administration, which copies the data into an Excel sheet and then files the Schein for eternity in a binder. NFTs could help make those processes easier, faster, more secure, and transparent after a student finishes a course, the teacher adds an NFT holding the grade, semester of attendance, etc., to the student’s account. The student and administration can then quickly assess their performance by just looking up the NFTs that have been collected.

Conclusion

NFTs and the blockchain are still pretty new concepts for most people, and as it is the case with every new piece of technology, there is a lot of skepticism and, sadly, bad actors (see telephones and email scams). It will take several years before blockchain technologies and smart contracts are considered for broader adoption. But with the switch from the proof of work to the proof of stake protocol, the energy required to run the Ethereum blockchain will fall several orders of magnitude and might play in the same ballpark as other online services and become a viable alternative or addition for other technologies.

References

[1] Andreas M. Antonopoulos and Gavin Wood, Mastering Ethereum. Building Smart Contracts and DApps. Sebastopol, CA: O’Reilly Media Inc., 2018. (Affiliate Link)

This post is licensed under CC BY 4.0 by the author.