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

  • 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.
// 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;}}
  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.
// 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, “”);}}
  • 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.




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Blockchain and The Great Game of Attention

Introducing Pendulum: smart blockchain connecting Fiat and DeFi

Machu Picchu: blockchain 101 for humanitarians

What is the Hyperledger Fabric?

WORLDCORE: Experience in Financial Markets, Banking Services, Electronic Finances and IT.

Decentralization is the Hero People Deserve

Why Checkpoint Is Releasing NFTs on Polygon

Checking will be releasing NFTs on Polygon soon.

RiteStream x Alpha Hunt

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ruslan wing

ruslan wing

More from Medium

Life Cycle of a XinFin XDC Network Transaction

PoS Validator Node Delegation Guide

Introducing Spacewalk: The trust-minimized bridge between Stellar and Polkadot

Global Trade Finance and the XDC Network