Token Standards - II

7D1t...morE
5 Jan 2024
19


In my previous article, I gave information about ERC20 and ERC721 token standards. In this article, I will talk about ERC721A and ERC721R variants developed based on ERC721.





ERC721A Variant

This variant was developed by Chiru Labs at the beginning of 2022 in line with the needs of the AZUKI project, an NFT project they developed to meet their own needs and to make it available to other contract developers. The purpose of the development of this variant is to reduce the gas value during the minting process and they aim to solve it by coding it in their own way instead of the Enumarable Interface of ERC721. The letter A in the ERC721A variant comes from AZUKI.




This variant has the following methods and structures in addition to the ERC721 structure.

TokenOwnership: This struct is used to store ownership related information and to perform operations.

_startTokenId()

Returns the initial value of the tokens. If no initial value is assigned, it returns 0.

_nextTokenId()

Returns the next value after the last Token Id of the NFT.

_totalMinted()

Returns the total amount of NFTs minted.

_totalBurned()

Returns the total number of NFTs burned.

_numberBurned(owner)

Returns the number of NFTs burned by the account given as a parameter.

_getAux(owner)

Returns the data in the "_packedAddressData" mapping of the account given as a parameter.

_setAux(owner, aux)

Assigns the following information to the account given as a parameter. A 256 bit data is kept and the bitwise equivalent of this data is below.

  • Balance information between [0...63]
  • Number of NFTs minted between [64...127]
  • Number of NFTs burned between [128...191]
  • Between [192...255] other data called aux



_ownershipOf(tokenId)

Returns which account owns the NFT with the given tokenId value as a parameter.

_ownershipAt(index)

Returns the ownership information of the NFT with the index value given as a parameter.

_initiliazeOwnershipAt(index)

If there is no value in the index value given as a parameter, it makes the necessary assignment.

_exists(tokenId) internal

Checks if the tokenId value given as a parameter exists and returns true if it does.

_safeMint(to, quantity, data) internal

This method mints the amount given as quantity parameter to the "to" account given as parameter. If extra data is entered, the data parameter is filled and the call is made.

_mint(to, quantity) internal

It is the method that mints the amount given as quantity parameter to the "to" account given as parameter.

_mintERC2309(to, quantity) internal

It is the method that transfers the amount given as the quantity parameter to the "to" account given as a parameter in accordance with the ERC2309 standard by minting it.

_burn(tokenId, approvalCheck) internal

This method burns the tokenId value given as a parameter. The tokenId value must be present when calling this method, otherwise an error will be thrown. When the approvalCheck value given as a parameter is sent as true, the account that performs this operation performs the burn operation by checking that it must either have ownership or transaction authorization on the tokenId.

_msgSenderERC721A() internal

If the msgSender value is assigned, it returns the value of the msg.sender global variable by default.

_extraData(from, to, previousData) internal

Each NFT transfer is assigned 24 bits of data.

_setExtraDataAt(index, extraData) internal

Performs the assignment of the 24-bit extraData value given as a parameter for the NFT in the index field given as a parameter.

IERC2309-ConsecutiveTransfer

Defines the event in ERC2309 standard as "event ConsecutiveTransfer( uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to )".


ERC721R Variant

In short, this variant is a variant developed to implement on ERC721 the ability for people to return a product after a certain period of time after purchasing it, either because they don't like it or for any other reason. The letter R in the ERC721R variant stands for Refund. Below are the benefits of this variant for both collectors and creators.

  1. Points that may be useful for collectors:


  • It may prevent rug pull: The creator(s) of the project will not have access to mint fees ahead of time, which will keep people who want to do rug pulls away.
  • Low risk of acquisition: The collector who has invested in the project can withdraw his/her investment for any reason (including a bona fide reason).


2. For creators:It will be useful in establishing credibility and trust between community
members and collectors.




Methods and structures added in addition to ERC721 are as follows.

_mintAtIndex(to, index) internal

It is the method that allows the to account given as a parameter to mint the NFT in the index parameter

getAvailableTokenAtIndex(indexToUse, updatedNumAvailableTokens) internal

This is the method where Fisher-Yates shuffle algorithm is applied.

getAvailableTokenId(to, updatedNumAvailableTokens) internal

This is the method that calls the getAvailableTokenAtIndex method with a random index and returns a random tokenId value.

_mintRandom(to, _numToMint)

It is the method that performs an NFT mint operation to the to account given as a parameter as much as the value given in the _numToMint parameter.

_mintIdWithoutBalanceUpdate(to, tokenId)

It is the method to assign to the mapping named _owners in the contract.

Source:

Write & Read to Earn with BULB

Learn More

Enjoy this blog? Subscribe to btcmillionaire

3 Comments

B
No comments yet.
Most relevant comments are displayed, so some may have been filtered out.