HRC721 Tokens
Introduction to Non-Fungible Tokens - NFTs
Last updated
Introduction to Non-Fungible Tokens - NFTs
Last updated
Background
In November 2017, a DApp game named CryptoKitties brought about a storm of excitement to the world of cryptocurrency. It’s a collectible game in which people can collect digital kitties and exchange them with others. The price of some of these digital kitties even rose to $300,000. At its peak, CryptoKitties was contributing an average of 30% of the daily transaction volume, congesting the entire Ethereum network. Afterward, when the number of active users in CryptoKitties dropped down, many similar games came out and dominated the DApp market. Behind the popularity of blockchain collectible games, there’s an underlying concept connecting them all: the concept of NFTs (Non-Fungible Tokens).
What is a Non-Fungible Token?
A non-fungible token is defined as a kind of token which is uniquely identifiable and distinguishable during interaction and circulation.
In the blockchain area, digital assets can be divided into two categories: coins and tokens. The former, such as Bitcoin, Qtum, Hydra, etc., have a blockchain, using transactions to maintain its ledger; the latter such as BOT, INK, LOC, etc., runs on an existing blockchain, using smart contracts to record data. These tokens can further fall two types: fungible and non-fungible.
FT (Fungible Token), usually based on the standard of ERC20 or QRC20, is a token that can be split into pieces and replaced by each other. NFT, on the contrary, is a kind of token which is unique and can not be split, such as kitties and so on.
The features of FT make it useful to represent anything replaceable in the real world, such as currency, reward points, stocks and more. These things need to be split and then exchanged between different owners. In the blockchain area, FT is widely used to issue new digital currencies. These digital currencies are usually linked to shares of a company or rights to access a product, so as to attract buyers or even speculators.
As the cryptocurrency market gradually returns to rationality, people begin to realize the limitation of FT: most valuable things in the real world are indivisible and irreplaceable, such as a commodity, a contract, a qualification. These assets are unable to be represented by FT.
Compared to FT, the key innovation of NFT is providing a method to record ownerships of indivisible and unique assets. Such kind of ownership can be kept in a blockchain, making it transparent and tamper-resistant. NFTs don’t prevent others from accessing the ownership, it simply capture it and discover its value as well as relationships with all other information in the blockchain.
Due to the non-fungible feature of NFTs, it can be used to represent a large number of real-world goods, such as a ticket, a bottle of wine, a piece of jewelry and so on. NFTs enable us to tokenize anything valuable and trace the ownership of it, thus to build a connection between information and value.
Applications of NFTs
NTF is a kind of blockchain-based non-fungible digital asset, and a NTF-compatible blockchain is like a database which keeps information of valuable things. In theory, NFT can connect to anything with non-fungible characteristic, realize tokenization of the real world, and form a world of digital assets with value exchange.
Some applications of NFTs are listed as follows:
Collectibles — Like the CryptoKitties app we mentioned above, there could be many other extensions from the idea of NFT-based collectible games. We can store the information of artworks, jewelry, and other collections onto the blockchain in the form of an NFT for the purpose of updates, circulation, and exchanges. For example, we can develop an NFT for artworks such as paintings and sculptures which have been certified by experts. Its owner only needs to show the NFT’s metadata to declare his ownership of the work when he wants to sell it. The certification is digitally traceable since the ownership of the art assets is recorded in the blockchain, which also prevents forgery and fraud of the artwork.
Game props — NFTs are also revolutionizing the world of online games. In general, when playing games, characters will get tradable items such as weapons, clothes, pets. Creating an NFT for each item allows these props to be traded with points in the game or even real-world cash, and finally constructs an online digital economy for virtual goods. These NFTs are stored in the blockchain, so their metadata, ownership and all transaction records are transparent and cannot be destroyed or tampered.
Digital ticketing — If I get a ticket to a music concert or own a basketball ticket, they are the same type of item which defines permission of participation in an activity at a certain time and place, but the rights they represent are not convertible. Due to this kind of uniqueness, the ticket can be represented by NFT in nature, and it has become one of the typical scenarios of NFT. NFT ensures that each ticket is valid and it can be transferred from one to another. Meanwhile, tokenization will also prevent fake tickets. So the ticket is an area which can be rebuild by NFT.
Identity authentication — We can apply NFT to identity authentication to achieve a full record of personal behavior. For example, you will own NFTs like a birth certificate, a passport and a driving license. Although such kind of NFT isn’t tradable, identity verification can be realized by adding access control to these NFTs. We can verify the identity of a person through interacting with his NFTs to inquire about his university diploma when recruiting, or apply for a doctor’s identity information to authenticate his qualifications when consulting the doctor. Everyone will be tokenized through identity authentication, and all attributes and behavioral history will be recorded.
Digital certificates — NFT provides a way to store contracts, patents and other documents to the blockchain, so as to prevent counterfeiting and make them traceable. The validity of these documents can be further proved by means of electronic signatures. Digital certificate can effectively record the value of intellectual property, copyright, etc. Furthermore, NFT can make these values tradable on the blockchain, which also facilitates the circulation of these values.
Implementation of NFTs
From the emergence of cryptocurrencies, the entire industry keeps trying to tokenize real-world entities. The popularity of color coin in 2013 was the first attempt to record NFTs in a blockchain. Color coins are build on Bitcoin and usually used to represent assets in the real world, such as houses, stocks and commodities. Later when Ethereum came out, smart contracts allow users easily creating their own assets on a blockchain. Under this background, several standards are proposed for NFT.
ERC721 standard is the most popular and recognized implementation of a NFT. ERC721 is an EIP (Ethereum Improvement Proposal) which was proposed by developers of Ethereum, and it became one of ERCs (Ethereum Request for Comment) after it was passed by the Ethereum committee. The official introduction of ERC721 is: A standard interface for non-fungible tokens, also known as deeds.
ERC721 suggests that a standard NFT on Ethereum should realize the interfaces in ERC721 and ERC165. These interfaces are defined as follows. In addition to standard interfaces, there are also some extended interfaces. For example, the interfaces defined in ERC721Metadata contract hold some basic information of the NFT, and the interfaces in ERC721Enumerable add some enumeration functions.
It should be noted that when using ERC721, you must implement some additional functions, such as a mint operation to create a new NFT, a burn operation to destroy a NFT, etc. Then you can apply ERC271 tokens to your own scenarios, and freely add specific business logic to enrich the application.
ERC875 standard (https://eips.ethereum.org/EIPS/eip-875) ⚠ This EIP has been withdrawn.
While other standards allow the user to transfer a non-fungible token, they require one transaction per token, this is heavy on gas and partially responsible for clogging the ethereum network. Thus a simple non fungible token standard was proposed that allows batching tokens into lots and settling p2p atomic transfers in one transaction.
ERC998 standard (https://eips.ethereum.org/EIPS/eip-998) ⚠This EIP is not recommended for general use or implementation as it is likely to change.
Allows composable tokens which make possible to compose lists or trees of ERC721 and ERC20 tokens connected by ownership. Any such structure will have a single owner address at the root of the structure that is the owner of the entire composition. The entire composition can be transferred with one transaction by changing the root owner.
ERC1155 is a novel token standard that aims to take the best from previous standards to create a fungibility-agnostic and gas-efficient token contract.
Multi Token Standard — The distinctive feature of ERC1155 is that it uses a single smart contract to represent multiple tokens at once.
Batch Operations — Because all state is held in a single contract, it is possible to operate over multiple tokens in a single transaction very efficiently.
Constructing an ERC1155 Token Contract
An excellent example of an ERC1155 Token Contract is presented in the OpenZeppelin project
https://docs.openzeppelin.com/contracts/4.x/erc1155#api:presets.adoc#ERC1155PresetMinterPauser
Contract template ERC1155PresetMinterPauser
OpenZeppelin set of interfaces and contracts related to the ERC1155 Multi Token Standard
https://docs.openzeppelin.com/contracts/4.x/api/token/erc1155