October 26, 2021

ERC1155 – Exploring the ERC-1155 Token Standard

Table of Contents

ERC1155, short for “Ethereum Request for Comments 1155”, is a token standard mainly used for NFTs (non-fungible tokens). With NFTs increasing in popularity and more artists wanting to create NFTs, it’s beneficial to have a token standard such as the ERC1155 to regulate these tokens. Moreover, for those aspiring to get started in blockchain development and wanting to create NFTs, learning about the ERC-1155 token standard, one of the leading standards on Ethereum, makes up an essential part of their development journey. Therefore, follow along as we explore the ERC-1155 token standard, learn what ERC1155 is, and discover the key differences between the various token standards. As such, you’ll be ready to start your journey in creating ERC1155 NFTs using the ERC-1155 token standard.

Before diving deeper into NFT token development, it’s advisable to understand well-known NFT standards to strengthen your foundation. Early NFT enthusiasts used ERC-721 because it was the first popularized non-fungible token standard under Ethereum. However, Ethereum’s community found ways to improve ERC-721 and widen its capabilities. ERC1155 has emerged as the latest NFT standard promising interesting improvements. In this article, you’ll see why developers today favor the ERC-1155 standard.

You’ll find that the ERC-1155 token standard borrows from previous fungible and non-fungible token standards such as ERC-20 and ERC-721. However, it offers several new advantages, including the ability of its smart contract to represent multiple tokens at the same time. Moreover, certain batch operations make it more efficient compared to older standards. Solidity developers and NFT creators will appreciate how the updates of ERC1155 make transactions easier to manage. They also make transactions cheaper because they lead to lower Ethereum gas fees. Furthermore, ERC1155 brings together fungible, non-fungible, and semi-fungible token properties, allowing for more flexibility. 

A Concise Introduction to ERC-1155

To get a concise video explanation of ERC-1155, watch this clip from Moralis’ YouTube channel:

What is ERC1155?

ERC1155 is more than just an NFT token standard. It sets the stage for multi-token management and transactions. With ERC1155, single deployed contracts can include varied combinations of non-fungible, fungible, and semi-fungible tokens. 

Created by the Enjin team, the ERC1155 token standard drew ideas from token standards like ERC20 and ERC721 token. It also introduced improvements of its own. Previously, under ERC-20 or ERC-721, you had to deploy a separate contract for each fungible or non-fungible token. This causes Ethereum’s blockchain to be riddled with redundant bytecode. Also, by separating each contract into individual addresses, the older standards limited certain functionalities. 

For the NFT and wider token ecosystem to grow and expand into other applications, it was clear that the community needed to create a new standard. If gaming platforms and other types of token-based dApps (decentralized applications) wanted to include NFTs into the mix, they would have to find a new way to minimize the volume of transactions and the inefficiencies of the contracts. Thus, ERC1155 was born. 

With ERC1155, it is now possible to transfer different types of tokens in a single instance, saving on transaction costs. Moreover, it is also possible to create trades in the form of atomic swaps and escrows of multiple tokens on top of the ERC1155 standard. The system no longer needs to approve token contracts individually as ERC1155 has eliminated this redundant step.

Fungible, Non-Fungible and Semi-Fungible

To further explore ERC1155, let’s briefly review the definitions of fungible, non-fungible, and semi-fungible tokens and their corresponding token standards.

Fungible Tokens

Fungible tokens adopt the properties of currencies and can be used in the same way as you use fiat. As such, fungible tokens are not unique; meaning, you can exchange one token for another of the same kind. Moreover, there is no programmed difference. In the same way that a dollar is a dollar, one fungible coin or token can be interchanged for another, and the perception of value is the same. Fungible tokens are mainly used as units of money, fees, or payments of some kind. 

Fungibility and Divisibility

When something is fungible, it is also divisible. For example, one Bitcoin (BTC) can be divided into fractions as small as 0.00000001 BTC. In other words, BTC was programmed to be divisible for up to eight decimal places, with the smallest fraction called a “Satoshi”. Therefore, while Bitcoin has soared in value in the past years, it can still be used for micropayments. 

Moreover, it’s important to remember that with cryptocurrency or crypto tokens, divisions, or smaller units, can be set beforehand through a smart contract. Other examples of fungible cryptocurrencies or tokens include Dogecoin, Litecoin, Monero, Ethereum ERC-20 tokens, and BEP20 (Binance Smart Chain) tokens. However, there are many more out there than those just mentioned.

ERC-20 Token Standard

ERC-20 is a standard on Ethereum used to code a class of fungible tokens.

Use cases of fungible tokens include:

  • Digital currency or mediums of exchange such as stablecoins.
  • Security tokens or crypto assets that are programmed to be stocks and bonds of the same class.

Non-Fungible Tokens (NFTs)

As mentioned, ERC1155 is a standard for creating NFTs. But what are NFTs in the first place? NFTs are the opposite of fungible tokens. They are tokens with unique properties and are therefore non-interchangeable with each other. Each token represents a unique, independent, and different value, property, or asset.

If you have noticed NFTs going up in price recently, it’s because they represent a unique form of value. Furthermore, they also represent exclusivity, which is a big use case in the digital art world. Moreover, while digital creations might be considered to be abundant, NFTs add information and provenance to them, transforming them into something that’s digitally one of a kind.

How is this possible? Through the power of smart contracts, you can create built-in signatures that serve as proof of ownership and a method of authentication. Moreover, smart contracts hold NFTs metadata and the link to the artwork or unique creation itself. This is all contained in code, which is written in Solidity and is usually on Ethereum’s blockchain, although platforms such as BNB Chain, Polygon (formerly MATIC) are catching up. These alternative blockchains are gaining popularity among NFT platform builders alongside the massive growth of NFT-based Ethereum dapps.

Today’s growing Web3 ecosystem provides you with many ways to start your NFT token infrastructure. Furthermore, Moralis allows you to build NFTs on various platforms. Moreover, as an ultimate Web3 development platform, Moralis provides a full suite of support that includes Moralis NFT API, and much more so you can create NFTs or build NFT games in record time.

ERC-721 vs ERC-1155

The most popular standards for NFTs are ERC-721 and ERC-1155. 

As the first widely-used token standard in NFTs, the ERC-721 token standard is the most easily recognizable NFT token standard. Moreover, this standard allows apps to use Moralis’ EVM API for NFTs.

Technically, ERC-721 defines the minimum interface that a smart contract has to implement. This minimum interface allows unique tokens to be owned, traded, and managed. ERC-721 does not require a standard for metadata connected to the token. Furthermore, it does not restrict adding functions that supplement the minimum requirement.

ERC-721 started as a draft EIP (Ethereum improvement proposal) by Dieter Shirley, the CTO of Dapper Labs, and later on became the basis for the game CryptoKitties. The recognized authors of the ERC-721 standard are Dieter Shirley, William Entriken, Jacob Evans, and Nastassia Sachs.

It’s important to remember that a key feature of NFTs smart contracts is that they do not contain the artwork, images, or files themselves, but only the links or URIs to them and their metadata. Such tokens reference off-chain resources for such files and information so that the blockchain itself is not responsible for hosting this data.

ERC-1155 is in some ways an improvement of ERC-721 since its code does not only work for non-fungible tokens (NFTs) but semi-fungible ones as well, as we’ll see in the next section.

Semi-Fungible Tokens with ERC1155

ERC1155 is a new way to create semi-fungible tokens. However, what are semi-fungible tokens? These are new types of tokens that merge different properties of the token standards that came before them. Think of it as having the best of both worlds. Let’s take this useful analogy: you’re able to create a store coupon – thus a fungible token – which holds the value until you redeem it. After redeeming the coupon, it has zero dollar value and you can not trade it as a regular fungible token. Therefore, the redeemed coupon, with altered properties, becomes unique with information about the item redeemed, the customer, the price, and so on. Hence, it becomes non-fungible. However, a semi-fungible token standard such as ERC1155 is capable of representing both attributes.

According to the Enjin blog, ERC1155 is a novel approach to defining tokens. Multiple items can be stored in a single contract with the least amount of data necessary to distinguish them from the others. Furthermore, Enjin writes that “the contract state contains configuration data per token ID and all the behavior governing the collection.”

Therefore, this new token standard lets you create utility tokens such as BNB, for example, and NFTs such as CryptoPunks or CryptoKitties. Its optimizations also make transactions more efficient and safer. Unlike in ERC-721, ERC1155 bundles transactions together, thus reducing gas fees. Furthermore, its ability to create efficient NFTs and fungible tokens at the same time shows that it is an evolution from both ERC-20 and ERC-721. 

ERC1155 Contracts

With ERC1155 contracts, it is now possible to transfer multiple types of tokens at the same time. You can build multiple functionalities such as atomic swaps and escrows (useful in trading) of various tokens on top of the ERC1155 standard. With this, you eliminate the need to authorize individual token contracts separately, as done with ERC-721. Moreover, as mentioned, you can combine several NFT and fungible token types in one ERC1155 contract.

In this simple diagram created by Enjin, you can see how this new standard simplifies a token swap of any number of tokens (such as different kinds of NFTs representing unique items), a use case that is valuable in gaming:

Atomic Swap of Multiple Tokens

As you can see, the entire batch is get approval and transacts in two simple steps, which is proof that ERC1155 contracts can save you on Ethereum gas fees.

ERC1155 contracts also allow you to send many items to multiple recipients in one go. This type of ERC1155 transaction is easily comprehensible in the following diagram, also created by Enjin:

Moving Multiple Tokens to Different Accounts in a Single Transfer

As you can see, transferring different types of items to multiple users only takes one contract and one transaction. ERC1155 is light, efficient and it removes redundancies. Moreover, from this illustration, you now understand that ERC1155 is fungibility-agnostic. 

ERC1155 Contract Sample

Here is an example of a simple contract of tokenized items in a game:

// contracts/GameItems.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";

contract GameItems is ERC1155 {
    uint256 public constant COPPER = 0;
    uint256 public constant CRYSTAL = 1;
    uint256 public constant ELDER_SWORD = 2;
    uint256 public constant KNIFE = 3;
    uint256 public constant WAND = 4;

    constructor() public ERC1155("https://game.example/api/item/{id}.json") {
        _mint(msg.sender, COPPER, 10**18, "");
        _mint(msg.sender, CRYSTAL, 10**27, "");
        _mint(msg.sender, ELDER_SWORD, 1, "");
        _mint(msg.sender, KNIFE, 10**9, "");
        _mint(msg.sender, WAND, 10**9, "");
    }
}

This initializes an ERC1155 contract. Furthermore, the game items in this contract are both fungible and non-fungible. In this case, copper is fungible, while the “Elder_Sword” is non-fungible. 

Under “GameItems”, you can also observe that each item corresponds to a number. This simply means that each integer, such as “copper” or “crystal”, is practically just an alias for “0”, “1”, and so on. Under the hood, these names are simply read as “0”,”1”,”2”,”3” and “4”. 

In the constructor part of the ERC1155 contract, you find several “mint calls”. The mint calls create new token types. Here, as game currency, copper is minted in the quantity of “1018”, and crystal is minted in the quantity of “1027”. The elder sword is minted as a single quantity or “1”, which indicates that this item is an NFT. It is unique and rare because there is only one of it available. Although the knife and wand mint in high quantities, they may also be NFTs, because they represent individual items that are separate from one another and are not currency. What’s more, you can keep adding items to the same contract, and you don’t need to create a new one. 

ERC1155 – The Gold Standard

Large NFT marketplaces use versions of smart contracts. ERC1155 allows users to create new items without having to deploy new contracts on these marketplaces. Thus, ERC1155 presents an edge when you build dapps on Ethereum. Furthermore, it makes more sense in NFT marketplace builds, making it the new superior standard for NFT platforms created today. Alongside Moralis, which offers new powerful ways to optimize your NFT dApps and platforms, ERC1155 can take your blockchain development game to the next level. 

With such advantages, there is little to no reason to go back to the older and more burdensome standard; however, it is still an option in simple projects and a useful learning tool for any novice blockchain developer or NFT programmer. 

ERC1155 – Exploring the ERC-1155 Token Standard – Summary

With all the unique advantages it presents, ERC1155 is now considered the “gold standard” for NFT platform development. It allows you to bring together multiple token types and accommodate multiple users or recipients in a single deployed contract and transaction. It is truly an improvement on past NFT standards, with many new features of its own, such as the creation of semi-fungible tokens.

Combined with Moralis’ powerful Web3 development tools that allow you to set up a blockchain node quickly, transfer backend work to its infrastructure, and build dApps quickly, ERC1155 can help you create the next generation of successful NFT games, marketplaces, and platforms!

Register your free Moralis account now and embark on your new exciting ERC1155 development journey with Moralis’ exceptional support and unparalleled Web3 infrastructure!

Moralis Money
Stay ahead of the markets with real-time, on-chain data insights. Inform your trades with true market alpha!
Moralis Money
Related Articles
September 6, 2023

Linea Goerli Faucet – What is the Linea Mainnet & Where to Find a Free Linea Faucet?

February 1, 2023

Exploring Enterprise Blockchain Solutions – Full Web3 Guide

November 2, 2023

Create Chiliz Chain Dapps with Moralis’ Chiliz API 

December 18, 2022

Exploring Ethereum Python Implementation for Dapp Development

August 2, 2022

How to Create an NFT Candy Machine

March 9, 2023

xNFT – What is an xNFT (Executable NFT)?

February 6, 2024

Blockchain Data Analytics – Turn Blockchain Data Into Engaging Insights & Analysis with Discovery API 

September 25, 2022

Full Guide: How to Build an Ethereum Dapp in 5 Steps

October 19, 2023

How to Set Up Notifications for NFT Sales