Ethereum’s Standards for Non-Fungible Tokens: ERC-721 and ERC-1155

As we have already explored in one of our last posts, Ethereum’s smart contracts revolutionized the world of cryptocurrencies and blockchain. The popular platform for building decentralized apps currently aims to “standardize” the industry. The majority of blockchain enthusiasts have heard about the popular ERC-20 (or ERC20) tokens, which are basically cryptocurrencies built on the Ethereum platform, following all the standards proposed in that particular technical document.

However, there is plenty of Ethereum Request for Comments out there, as the developers want to define a set of rules for all kinds of things built on the platform, and one of them is non-fungible tokens (NFTs).

The standard used for building NFTs on Ethereum is called ERC-721. However, as NFTs popularity increased, developers also came up with ERC-1155. Finally, one of the most recent documents is EIP-2309, and we’re going to look at it briefly as well.

ERC-721

ERC-721 is the essential set of rules for NFTs, defining them as a way to identify something or someone in a unique way. The ERC basically introduces a standard for building NFTs on Ethereum.

NFTs are unique tokens and have a different value from other tokens that are part of the same smart contract. 

Let’s compare them to standard ERC20 tokens shortly. If Mike and Joe both have 1 ETH, both Ethers will be worth the same — $2,400, for example. However, if Mike has one NFT — say, a common sword from a game that uses this technology, and Joe has an extremely rare type of blade, Joe’s NFT will be worth a lot more.  

Their value can change due to various impacts, including rarity, age, or even visual factors.

If all in-game items are tokenized, they become unique and cannot be replaced. However, some items are rarer, others are older, and some are just visually more appealing. That’s why some of them are going to be more expensive than others, even though they are part of the same smart contract.

That’s basically one of the ERC-721’s main goals — to make tokens different.

All of that is part of the code that is governed by ERC-721. For example, every NFT needs to have an uint256 variable named tokenId. Therefore, the pair contract address, unit256 must be globally unique for all ERC-721 contracts. Dapps will then use converters for tokenId, which will serve as an input or output of a specific image, which can be literally anything visual, such as weapons, armor, or even pieces of art, if it’s applied outside the gaming industry.

ERC-721 History

Ethereum Request for Comments 721 was proposed by Nastassia Sachs, Jacob Evans, Dieter Shirley, and William Entriken. They came up with an EIP in January 2018, proposing a standard that aims to implement an API for NFTs within smart contracts.

Like many other ERCs, this one also provides some of the functionalities to NFTs. For instance, it makes NFT transactions from one account to another possible. Moreover, ERC-721 provides an ability to get the account’s current token balance, the total supply of tokens on the network, specific token owner information, and more. 

Some additional functionalities are added besides that, making ERC-721 a thorough document. Smart contracts that have ERC-721 implemented are referred to as ERC-721 Non-Fungible Token Contracts, and they have to keep track of all tokens created on Ethereum.

Let’s take a look at some of the methods and events that are part of ERC-721.

Events

Of course, NFT creators can play around with the code, and one of the best examples of this is a game called CryptoKitties. Its goal is simple — players need to breed kittens and trade them with other players. Each kitty is unique — it’s an NFT, and some of them happen to be more popular than others. However, apart from the standard events, CryptoKitties also has some additional ones, such as Pregnant and Birth.

ERC-1155

This standard is commonly named the Crypto Item Standard, but before taking a look at its advantages, let’s quickly address why we need it.

In case you haven’t figured out by now, the gaming industry is all in when it comes to the idea of NFTs, but this has raised several alarming issues when ERC-721 is applied. The standards such as ERC-20 and ERC-721 are based on deploying a separate smart contract for every token type or collection. The result of this is plenty of redundant bytecode that would further strain the Ethereum blockchain. 

Simply put, some games are now creating thousands of different types of tokens, and every new type uses a separate contract, which is why the need for ERC-1155 was born in the first place.

And here’s how that is solved:

The main thing that ERC-1155 adds is for each token ID to represent a new token type that’s configurable and may have various attributes of its own, including supply, metadata, and more. This aims to reduce the amount of data required for distinguishing one token from other ones.

ERC-1155 addresses several other issues.

Swapping in-game NFTs that are created by the ERC-20 or ERC-721 rules and set in separate contracts is a difficult process that takes at least four steps before it’s executed. By introducing ERC-1155, these are turned into the so-called atomic swaps that allow 2-step transactions.  

Moreover, ERC-1155 allows sending several types of NFTs in a single transaction instead of making a separate transaction for every different token. This reduces congestion, as well as the gas cost, which ultimately reduces the fee you have to pay to a minimum.

Perhaps one of the biggest advantages that ERC-1155 brings to the world of games is that it addresses both fungible and non-fungible tokens in games. Simply put, some in-game items can have a unique index, while others can be fungible and are not unique. Items such as in-game coins, health kits, ammo, and more are meant to be fungible, and ERC-1155 allows it.  

Final Thoughts: EIP-2309 and other Ethereum Improvement Proposals

The entire idea of non-fungible tokens is still quite new, and it’s being explored by some of the most talented Ethereum developers around the globe (and not just Ethereum, as there are several other similar platforms working on NFTs).

Improvements are suggested from time to time. One such modification is EIP-2309, suggested by Sean Papanikolas, which proposes adding a standardized event emitted in the case of creating or transferring one or several NFT by using consecutive token identifiers.