#1 TOKENIZATION PLATFORM

NFT creation using Ethereum 1155 token standard

Non-fungible tokens or NFTs are now being used all over the world to represent ownership of various assets like digital artwork, music, and even real estate. They have helped investors, brands, crypto enthusiasts and developers explore myriad new avenues in the blockchain space.

In fact, several popular brands have now jumped on the NFT bandwagon. For example, Taco Bell has recently started offering NFTs of their own by creating digital collectibles for sale. If you would like to get a better idea about what NFTs are and how they work, you can refer to our article ‘What are non-fungible tokens or NFTs?’.

If you are already aware of NFTs and the various benefits that they offer, then creating an NFT of your own is definitely something that would interest you. In this article, we will take a look at how to create non-fungible tokens with Ethereum 1155 standard.

Here, we’ll help you gain better insights into the below topics:

What is a token standard?

A token standard is a collection of guidelines that describe the data and as a result, of the functions that each token can perform. Currently, the most popular NFT standards in use are ERC-721 and ERC-1155. ERC-721 is the foremost standard that enables us to develop unique non-fungible tokens for digital collectibles.

NFT token standard
NFT token standard

If you’re looking to get a better idea about how to create an NFT with Ethereum 721 standard, you can have a look at our article on ‘How to create an NFT or Non-Fungible Token? Part 1 ERC-721 Standard’

Limitations of ERC-721 token

Despite the popularity of Ethereum 721, there are a few major limitations associated with this standard. One of the primary examples would be the difficulty level of transactions with such tokens. While using ERC-721, acquiring a token identifier directly is not possible, which makes transactions much harder. Imagine a situation where you would like to send 20 NFTs to someone. You will need to execute twenty different transactions, along with an individual additional charge for each transaction. This means that the transaction costs associated with this standard are extremely high. The load operations of the network often get compromised as well, which greatly affects the usability of the Ethereum network.

Another major limitation that we can see is traversing ERC-721 tokens. To do this efficiently, every single token in the contract will need to be traversed so that a response can be given to the dApp and the user. So, if an ERC-721 contract has 1 million tokens under its registration, a user will have to send a transaction to the network to know the status of their tokens. This will involve sifting through millions of tokens to match them with the user’s address and deliver a response, which is an extremely time-consuming and inefficient process.

What is ERC-1155 and how does it compare to ERC-721?

Although the ERC-721 standard works well for tokenization and the creation of unique assets that can be transferred between users, a collection of such tokens are often slow and inefficient. This is why many have now turned towards ERC-1155, as it takes care of many of the limitations that are seen with the use of ERC-721. ERC-1155 tokens have often been lauded for their multi-token approach. They support batch transfers of multiple tokens at once at much higher speeds than an ERC-721 token.

We can compare ERC-1155 tokens to a vending machine. Each developer can deploy a single smart contract that is often used to mint unlimited fungible and non-fungible tokens. On the other hand, ERC-721 tokens standard only produces non-fungible tokens, which means that developers need to deploy a new smart contract for each new token.

Developers will use the ERC-1155 token standard to deploy a single smart contract and then mint new tokens in seconds. They will keep using the one smart contract indefinitely, minting an unlimited number of fungible and non-fungible tokens.

Users can also send batch transfers of multiple fungible and non-fungible tokens using ERC 1155 in one go:

Additionally, users can also swap any amount of tokens easily and efficiently by following these steps-

swap any amount of tokens easily

There are various advantages associated with using ERC-1155 when compared to other token standards like ERC-20 and ERC-721. It allows developers to consolidate the logic in one contract and build an ecosystem around a single address. It also enables users to execute batch transfers in the same contract, and all of this is possible at much lower costs.  The primary idea behind ERC-1155 is that a single smart contract can govern an infinite number of tokens.

Need help with NFT token development?

Reach out to us today and get started!

Reach out

Features of ERC-1155 tokens

  • Batch transfers:

ERC-1155 allows users to send several tokens in one single transaction. This allows them to save up on costs and time. By using this standard, you will be able to build Atomic Swaps with the same design as well. This can help you exchange one kind of token for another with absolute security from fraud and no intermediate party involved.

  • Strict rules:

This standard follows a very strict set of rules. By sending a token to an address, the tokens will perform a deterministic smart contract function. For example, if you send a token to a DEX exchange address, the exchange could immediately return another token to the sender’s address. Similarly, if a blockchain game receives an ERC-1155 token from a user will execute a game feature. Without needing to access ABIs or communicate with the smart contract directly, tokens could be wrapped, transformed, designed, or escrowed.

  • ID substitution:

A user can now point to an infinite number of token URIs without storing any additional data on-chain by using the substitution string “{id},”. This string can also be used inside the JSON itself to automatically link to imagery for each token. As a result of this, the Developers’ overhead for displaying metadata for large sets of tokens is greatly reduced.

  • Localization:

Since token information is specified in JSON format, localization for multiple languages is now possible using {locale}. Alternate versions of token names, images, and any other data can be displayed in wallets and applications that support multiple languages.

Creating an NFT token with ERC-1155 standard

The multi-token support option offered by ERC-1155 is one of its prime features. Imagine a scenario where every single airline possesses a unique token. If you’re looking to book a flight with three different connecting flights from various airlines, you would need to pay for each airline ticket individually. There could be many problems associated with this. To overcome these issues, you can create a single multi-token contract that holds the individual tokens for every airline? That’s exactly what ERC-1155 allows you to do. Instead of just one token class, you can add as many as you want. Let us take a look at how to implement the ERC-1155 token with Openzeppelin contracts for this example. Install them with npm or directly in Remix by importing the GitHub URL.

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
 
contract AirlineTokens is ERC1155 {
  address public governance;
  uint256 public airlineCount;	
  modifier onlyGovernance() {
    	require(msg.sender == governance, "only governance can call this");    	
    	_;
  }
 
  constructor(address governance_) public ERC1155("") {
    	governance = governance_;
    	airlineCount = 0;
  }
  
  function addNewAirline(uint256 initialSupply) external onlyGovernance {
    	airlineCount++;
    	uint256 airlineTokenClassId = airlineCount; 
    	_mint(msg.sender, airlineTokenClassId, initialSupply, "");    	
  }
}

Now all you need to do is call AirlineTokens.safeBatchTransferFrom(myBuyerAddress, sellerAddress, [airlineId1, airlineId2, airlineId3], [firstFlightPrice, secondFlightPrice, thirdFlightPrice], ‘”). After this, you can pay in each airline currency in a single transaction.

Need help with crypto fundraising?

Reach out to us today and get started!

Reach out

Author

Rahul A R is a technologist and full stack developer who specializes in Blockchain technologies and Cryptocurrencies. Though he’s worked within numerous privacy and security sectors, Rahul’s recent emphasis has been on solutions built on Ethereum, Tezos, smart contracts, and smart signatures, in particular, decentralized self-sovereign identity. He’s Helped clients, from start-ups to Fortune 500 companies, across North America and Asia, develop their blockchain strategy and build several decentralized applications using blockchains and smart contracts.

Get Started

ICOs and STOs are disrupting the business finance realm. Wait no more, reach out to us today to discuss how to launch an ICO or STO for your project.