This article will show you what the underlying technologies of NFT are.

This article will show you what the underlying technologies of NFT are.

write in front

I don't know since when, NFT suddenly became popular. From time to time, you will see a news that a certain digital collection of NFTs has been bought for hundreds of thousands of dollars, as if NFTs are wealth codes.

If you follow this industry, you must have heard of the Boring Ape Yacht Club (BAYC). BAYC has about 10,000 NFT s on opensea, and the images are all kinds of apes. such as the following

Articles about various consultations on NFT are everywhere, but there are relatively few underlying technologies. This article will take you to understand which technologies support this industry with a global transaction scale of tens of billions of dollars. (According to the third-party data agency nonfungible statistics, NFT in 2021 Deal size reaches $14 billion)

However, it should be emphasized that I will not elaborate on a certain technical detail. For example, when it comes to blockchain, I will not be detailed enough to tell you about the consensus algorithm. This article is just a guide. If you are interested, you can learn about a certain knowledge point by yourself. Check it out.

Related underlying technologies

NFT is the abbreviation of Non-Fungible Token, which means non-fungible pass (or token). There is a concept here called non-homogenization, which means different. The currencies we usually use, such as RMB and U.S. dollars, or some digital currencies such as BTC, are all homogenized, they can be exchanged and replaced, because we only care about the face value of the currency, not the unique code on the banknote.

The non-homogenization of NFT means that each NFT is unique, encrypted and irreplaceable. And one of the biggest features is that it is inseparable. Its characteristics are a bit like the real estate deeds, contracts, bills and the like in our daily life.

The position of NFT in the blockchain technology stack is roughly as follows:

The bottom layer is of course the blockchain, which mainly provides infrastructure, such as consensus algorithms and P2P networks. This chain can be a public chain, a consortium chain, or even a private chain.

Of course, in the public chain field, we must first mention Ethereum, which is the earliest public chain of NFT. However, due to the congestion of the Ethereum main network later, some other public chains appeared later, such as flow, SOLANA, etc. For the background and background of Ethereum congestion, if you want to know more, you can read the following article:

Vernacular ETH2.0: Everything you need to know is here

Like the BAYC we mentioned earlier, it is the NFT issued on the Ethereum main network.

The blockchain itself is a decentralized distributed ledger, and the hash encryption algorithm it uses is pre-image resistant and sub-preimage resistant. The NFT we issue on the blockchain itself is confirmed on the chain Transaction, then once the transaction is confirmed to form a block and join the main chain, this NFT cannot be maliciously tampered with, and it has a unique identity.

Looking further up, it is the virtual machine EVM. EVM (ETHereum Virtual Machine) is the abbreviation of "Ethereum Virtual Machine". The existence of EVM is to enable the smart contract code we write to be parsed and run in the public chain environment. . For some details in EVM, you can read an article I wrote before:

What is the Ethereum Virtual Machine EVM?

The next technical point to talk about is smart contracts. Blockchain-based smart contracts use Turing's complete scripting language to achieve compatibility of complex functions, and rely on consensus algorithms for execution to ensure consistency. Smart contracts make it possible to conduct fair transactions without relying on third-party credit intermediaries, and realize cross-industry, cross-domain, and cross-ecological value interaction.

The essence of NFT is actually a non-homogeneous digital asset token created, maintained and executed by smart contracts. To create an NFT, you must first have a smart contract, which will have a unique address on the Ethereum main chain, such as the aforementioned BAYC, whose smart contract address is


We can view this address in the Ethereum browser:

Then based on this contract, we can create NFTs. Adding s here means that multiple different NFTs can be created. For example, BAYC has 10,000 different apes. The difference between each ape is that their metadata is different, so the Show different image effects.

With smart contracts, if we want to create NFT s, we usually follow a certain protocol. The commonly used protocols are ERC721, ERC1155 and ERC998. The use of different protocols to create NFTs is generally based on different usage scenarios. For example, the transaction speed of ERC1155 is higher than that of ERC721. We only need to pay attention to the method of creating NFTs for one of the protocols, and the others are not difficult.

So here I will take ERC721 as an example to briefly explain the process of creating NFT. The following will show a small part of the code, the syntax of which is solidity, a language for writing smart contracts in Ethereum. It doesn't matter if you don't know the language, you can probably understand what it means.

The ERC721 protocol defines a set of interface methods and events. As long as you write a smart contract and implement these methods and events, it is an NFT smart contract.


    function balanceOf(address _owner) external view returns (uint256);
    function ownerOf(uint256 _tokenId) external view returns (address);
    function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable;
    function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable;
    function transferFrom(address _from, address _to, uint256 _tokenId) external payable;
    function approve(address _approved, uint256 _tokenId) external payable;
    function setApprovalForAll(address _operator, bool _approved) external;
    function getApproved(uint256 _tokenId) external view returns (address);
    function isApprovedForAll(address _owner, address _operator) external view returns (bool);

Just pick a few ways to explain,

ownerOf function, the parameter is _tokenId, it returns the address of the holder of the token

approve function, which can grant another person the right to transfer tokens


    event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
    event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId);
    event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);

The above are standard interfaces, and there are some extended interfaces, which can be implemented according to needs. For example, there is also the ERC721Metadata interface, which is the metadata interface. We also mentioned metadata earlier.

/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See
///  Note: the ERC-165 identifier for this interface is 0x5b5e139f.
interface ERC721Metadata /* is ERC721 */ {
    /// @notice A descriptive name for a collection of NFTs in this contract
    function name() external view returns (string _name);

    /// @notice An abbreviated name for NFTs in this contract
    function symbol() external view returns (string _symbol);

    /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
    /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
    ///  3986. The URI may point to a JSON file that conforms to the "ERC721
    ///  Metadata JSON Schema".
    function tokenURI(uint256 _tokenId) external view returns (string);

There are also enumeration related interfaces,

/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
/// @dev See
///  Note: the ERC-165 identifier for this interface is 0x780e9d63.
interface ERC721Enumerable /* is ERC721 */ {
    /// @notice Count NFTs tracked by this contract
    /// @return A count of valid NFTs tracked by this contract, where each one of
    ///  them has an assigned and queryable owner not equal to the zero address
    function totalSupply() external view returns (uint256);

    /// @notice Enumerate valid NFTs
    /// @dev Throws if `_index` >= `totalSupply()`.
    /// @param _index A counter less than `totalSupply()`
    /// @return The token identifier for the `_index`th NFT,
    ///  (sort order not specified)
    function tokenByIndex(uint256 _index) external view returns (uint256);

    /// @notice Enumerate NFTs assigned to an owner
    /// @dev Throws if `_index` >= `balanceOf(_owner)` or if
    ///  `_owner` is the zero address, representing invalid NFTs.
    /// @param _owner An address where we are interested in NFTs owned by them
    /// @param _index A counter less than `balanceOf(_owner)`
    /// @return The token identifier for the `_index`th NFT assigned to `_owner`,
    ///   (sort order not specified)
    function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256);

Below this link, you can see an example that implements ERC721:

This example is part of OpenZeppelin, which is an open-source smart contract library. We can easily write our own NFT by directly inheriting some of its well-implemented classes, such as:

 pragma solidity ^0.8.0;

   import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
   import "@openzeppelin/contracts/utils/Counters.sol";
   import "@openzeppelin/contracts/access/Ownable.sol";
   import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

   contract MyNFT is ERC721URIStorage, Ownable {
       using Counters for Counters.Counter;
       Counters.Counter private _tokenIds;

       constructor() ERC721("MyNFT", "NFT") {}

       function mintNFT(address recipient, string memory tokenURI)
           public onlyOwner
           returns (uint256)

           uint256 newItemId = _tokenIds.current();
           _mint(recipient, newItemId);
           _setTokenURI(newItemId, tokenURI);

           return newItemId;

This code is very short, it contains a counter (Counter), a constructor (constructor), and a function (mintNFT). Yes, with these codes we have implemented a simple NFT. This is thanks to ERC721URIStorage, the OpenZeppelin contract class, which has helped us implement most of the methods in the protocol interface mentioned earlier.


At present, the main application of global NFT is still in the field of digital collections, and the aforementioned BAYC belongs to this field. I personally think that the bubble in this field is relatively serious, and there is a lot of speculation and speculation. In the future, if NFT wants to develop rapidly, it still needs to implement some scenarios that really solve social problems, such as some tool applications, authentication of personal information, etc. Otherwise, the final fate is likely to be short-lived like the ico of the year.

refer to:


Posted by darcuss on Tue, 31 May 2022 04:47:24 +0530