What are XRC-721 and XRC-1155: Standards for Creating NFTs on XinFin Network

ruslan wing
5 min readMar 15, 2022

--

Summary

  • The XRC-721 non-fungible token standard is written in Solidity language on the XinFin blockchain and it allows developers to tokenize ownership of any arbitrary data.
  • XRC-1155, an improved standard beyond XRC-721, is another token standard on the XinFin blockchain that facilitates the creation of both kinds of tokens, fungible and non-fungible. The goal is to create a smart contract interface that can represent both types.

One way to represent the cost of exchanging value on a XinFin blockchain network is through asset tokenization, of which the assets can either be fungible or non-fungible. Fungible means they can be divided and exchanged for another. Non-fungible tokens (NFTs), on the other hand, cannot be divided and there are no existing duplicates. On a blockchain like XinFin, two popular standards for creating NFTs exist, XRC-721 and XRC-1155.

What is The XRC-721?

XRC-721 is a non-fungible token (NFT) standard written in Solidity language on the XinFin blockchain. It allows developers to tokenize ownership of any arbitrary data. In particular, the standard aims to create interchangeable tokens. An example of an XRC 721 contract is from OpenZeppelin, which allows developers to track items in their game.

// contracts/GameItem.sol// SPDX-License-Identifier: MITpragma solidity ^0.6.0;import “@openzeppelin/contracts/token/ERC721/ERC721.sol”;import “@openzeppelin/contracts/utils/Counters.sol”;contract GameItem is XRC721 {using Counters for Counters.Counter;Counters.Counter private _tokenIds;constructor() public XRC721(“GameItem”, “ITM”) {}function awardItem(address player, string memory tokenURI)publicreturns (uint256){_tokenIds.increment();uint256 newItemId = _tokenIds.current();_mint(player, newItemId);_setTokenURI(newItemId, tokenURI);return newItemId;}}

XRC-721 token code

Essentially, each XRC 721 token is unique and represents a single asset. Moreover, it allows developers to build a whole new ecosystem of tokens on the XinFin blockchain.

Characteristics of XRC-721 Tokens

The XRC-721 standard structurally resembles the ever-famous XRC-20 token architect. Although the smart contracts of both tokens have somewhat similar functions, some features of XRC-721 are different.

Here are the most prominent features of XRC-721:

  1. Token name: Each XRC-721 token has a name field, which indicates the token name to external applications or contracts.
  2. Ownership: XRC-721 standard has a defined field of functions that defines the ownership of the underlying token and gives directions on how to transfer that ownership.
  3. Token tracking: XRC-721 standard has a field called “tokenOfOwnerByIndex” that allows developers to track tokens through a unique ID.

What is The XRC-1155?

XRC-1155, an improved standard beyond XRC-721, is another token standard on the XinFin blockchain that facilitates the creation of both kinds of tokens, fungible and non-fungible. The goal is to create a smart contract interface that can represent both types. Here is the XRC-1155 token code from OpenZipplin that helps track multiple items in a game.

// contracts/GameItems.sol// SPDX-License-Identifier: MITpragma solidity ^0.6.0;import “@openzeppelin/contracts/token/XRC1155/XRC1155.sol”;contract GameItems is XRC1155 {uint256 public constant GOLD = 0;uint256 public constant SILVER = 1;uint256 public constant THORS_HAMMER = 2;uint256 public constant SWORD = 3;uint256 public constant SHIELD = 4;constructor() public XRC1155(“https://game.example/api/item/{id}.json") {_mint(msg.sender, GOLD, 10**18, “”);_mint(msg.sender, SILVER, 10**27, “”);_mint(msg.sender, THORS_HAMMER, 1, “”);_mint(msg.sender, SWORD, 10**9, “”);_mint(msg.sender, SHIELD, 10**9, “”);}}

XRC-1155 token code

The XRC-1155 standard, in particular, has the same functionality as an XRC-721 and XRC-20 token. However, it improves upon the functionality of both standards and is a more efficient standard overall. In terms of benefits, transactions using the XRC-1155 standard can be bundled together to help reduce the cost of trading tokens.

Benefits of XRC-1155 Tokens

XRC-1155 standard stands out because of the following characteristics:

  • Effective Transfer: The XRC-1155 standard allows users to make massive transfers natively of the tokens within a smart contract. For example, in a smart contract with a series of fungible or non-fungible tokens, a developer can choose to transfer multiple tokens in the same operation. It not only reduces the transaction cost but also minimizes the impact on the XinFin network.
  • Multiple Tokens in A Single Contract: Each XRC-1155 token describes the existence and operation of both the fungible and non-fungible token types. For example, while an XRC-1155 can create one or more NFTs, it can also describe fungible tokens — all within the same contract.
  • Secure Transfer of Tokens: XRC-1155 token standard includes a function that checks whether a transaction is valid or not. If a transaction doesn’t go through, this function returns the token to the issuer. It helps when users accidentally make a mistake in the transcription or send out tokens to the wrong address. The code can automatically revert the transaction.

XRC-721 vs XRC-1155: The Key Differences

1)Smart Contract

First, the XRC-721 standard produces NFTs solely and forces developers to create a smart contract for each new token. On the other hand, XRC-1155 allows developers to develop a single smart contract that can be used to mint either fungible tokens or NFTs.

2 )Efficiency

Since XRC-721 allows a single operation for each transaction, it is expensive and time-consuming. At the same time, it reduces the effectiveness of the XInFin blockchain network with redundant code. Whereas, XRC-1155 allows multiple operations in a single transaction. Therefore, the transactions are cheaper and more efficient. Plus, unlike XRC-721, which utilizes significant space, XRC-1155 uses less storage space on a XinFin blockchain network.

Which Is Better, XRC-721 or XRC-1155?

Both the token standards can mint NFTs. It leaves us with the question: which one should you prefer? It all depends upon your personal preference or the use case. While some art collectors only buy XRC-721 NFTs because they see this token type as the gold standard, other collectors do not have any specific preference. On the flip side, XRC-1155 is cheaper and more efficient as it reduces the gas fees, making it an affordable and approachable way to mint an NFT.

In the meantime, if you have any questions about XinFin Development or you are a DeFi project and want to know more about how to migrate your project to XinFin Network you can always contact me via Telegram @Ruslan_wing

For any support, connect via XDC Network’s Social media communities on Slack, Twitter, and Discord.

--

--

No responses yet