Perks Entailing ERC-721A

Azuki has measured the gas costs and prices for mining, where they compared OpenZeppelin’s ERC721Enumerable vs ERC721A which they have documented below. This explains how users are charged an exorbitant amount of gas fee per transaction which adds up to become quite costly.

NUMBER MINTED

GAS USED (ENUMERABLE)

GAS USED (ERC721A)

GAS SAVED

Mint 1

154,814

76,690

78,124

Mint 2

270,339

78,819

191,520

Mint 3

384,864

80,948

303,916

Mint 4

501,389

83,077

418,312

Mint 5

616,914

85,206

531,708

As a result, ERC-721A has brought forth some optimizations in order to reduce the gas prices, which are explained below.

Eliminating (OZ) ERC721Enumerable's Duplicate Storage

The mass usage of OZ implementation of IERC721Enumerable includes redundant storage of each token’s metadata. This alien approach optimizes for read functions at a higher cost than write functions which are not desired because users are much less likely to pay for read functions. In addition to this, Azuki’s tokens are serially numbered from 0 which helps them remove redundant storage from the base implementation.

Updating Owner Balance Once Per Batch Mint Request

The second improvement added by Azuki is the feature to update the owner’s balance once per batch mint request instead of updating per minted NFT. Let us make it simple enough for you to understand. For example, James has 3 tokens and he wants to buy 6 more, in Solidity, it costs gas to update a stored value. So if we are tracking in storage how many tokens James owns, it is cheaper to update James’ holdings from 3 directly to 9 with one update, instead of updating that value 6 times.

While this is a simple notion, the great majority of bulk mints in the NFT ecosystem have yet to embrace it since the OZ default implementation lacks a batch mint API, and it's tempting to utilize an existing solution without altering it. If your project supports batch mints, we strongly advise you to consider this method.

Updating Owner Data Once Per Batch Mint Request

This optimization is pretty similar to the previous one. Suppose James want to buy 3 tokens namely token #200, #201, and #202. Instead of declaring James as the owner 3 times, each time costing us gas, instead, we can preserve the owner value just once, implying that James owns all three tokens conceptually. ERC-721A still expects significant net savings from this since it minimizes the amount of gas used at the mint, reducing the severity of concentrated gas surges for the entire ecosystem during the mint season. Not only will NFT mint costs become cheaper for individual transactions, but there will be reduced network congestion and gas price spikes on the Ethereum network during popular collection drops.

Collections Utilizing ERC-721A

There is a vast variety of collections utilizing ERC-721A including KittyCryptoGang, Azuki Gallery, and XRabbitsClub. This standard is primarily used to save excessive gas fees with the help of batch mining. ERC-721A reduces wasted storage of token metadata and limits the ownership state updates to only once per batch mint instead of once per minted batch. This results in reduced work required to send write transactions which saves on gas as write is more costly than the read function. Therefore, by reducing the number of write transactions, NFT minting cost is reduced drastically.