NFT Operations on Efinity: Minting and Batch Transactions

Designing safe, affordable transactions on Efinity will create faster ledgers and push the democratization of disruptive technologies like NFTs.

Efinity produces safe, affordable transactions, the democratization of troublesome technologies like non-fungible tokens (NFTs), and the creation of swifter ledgers.

Every blockchain developer aims to develop with minimal costs while retaining speed and security.

Efinity can be optimised to adapt to users’ needs, with innovations that ultimately improve users’ experience.

This article shares one of the vital optimisations that have been applied to Efinity that significantly advances the experience of users and game adopters:

  • Minting a significant amount of NFTs
  • Batch transfers of an incredible amount of NFTs

Enhancing NFT Transactions 

The Problem: I/O Movement

Efinity (designed using Substrate) will be displayed as a parachain (on Polkadot). When the benchmark of the transaction (extrinsic) of the runtime is done, access to the storage (reading or writing the state of the blockchain) is critical.

Here, the goal is reducing the amount of I/O operations on the storage to a minimal level, which will create a spontaneous decrease in the user’s fees.

The storage of NFT balance in an account can be done with this structure:

This will help to query or store the balance of the given token for the target account’s specified asset. Iterating over the storage and enumerating the tokens that belong to an account can be done in substrate whether the asset is fixed or not.

Notwithstanding, the core of this representation is the amount of I/O operations required for a significant amount of batch transfers and minting. For example, to develop 1 million tokens for a new game, at least 1 million writes will be required into the storage.

Similarly, batch transfers are impaired, taking one read plus two writes (one in the source account and another in target) for every transfer.

The Solution: Batches/ Chunks of Tokens

By putting a group of tokens in one structure (chunk), the I/O on the storage can be reduced.

In a chunk, sequential tokens are grouped, sharing an index.

Here’s an example: assuming a chunk is defined to have 512 elements(the chunk size), dividing the token ID by 512 will give the chunk index.

Applying this to the previous example reduces the I/O from 1,000,000 to 1,954.

Taking a Step Further: Ranges

Having reduced the amount I/O, the space and fees taken up to store the token IDs can also be reduced. By taking the advance of the sequential token IDs, chunks can be compressed. 

Ranges can be written in place of token IDs in a chunk. A range is a continuing group of token IDs. For example; [0,436], which represents 0,1,2,…,436.

In the best case, a chunk can be defined using only two IDs. For instance, this uncompressed chunk: [0,1,2,3,4,5,6,7,8,9] can be compressed to a range: [0,10]. While the first required ten integers, the second only needed two.

A worse case occurs when the token IDs in a chunk are only odd or even integers, which requires about 512 IDs to constitute ranges for 256 tokens. For example, where a chunk has elements like [0, 2, 4, 6], (non-sequential elements), more space will be needed for a compressed range representation: such as { [0,1), [2,3), [4,5), [6,7) }.

In operations like subtraction and addition (required for transfers between accounts), the use of ranges expands complexity. However, the nature of this complexity is an order of magnitude lesser than I/O operations.

Performance

Note importantly: the optimisation test is proof of figures on a benchmark.

A proof of transactions affected by the optimization is the table below. The omitted extrinsic of the pallet was not affected in terms of performance:

Important Highlights

•In the first draft, 120,000,000 NFTs were minted in one single block. This is an improvement of 99.8%.

•Using new API functions, any smart wallet can utilise this optimisation.

•An improvement of x2 was seen where NFT transfers were batched. However, better figures can be gotten in specific use cases, as shown by the standard error deviation.

Conclusions

Efinity’s democratisation of NFTs (through micro-fees) will create a revolutionary change for businesses and developers who need optimisation on large scale operations.

This kind of optimization is also useful in other areas. Where liquidity and security are maintained at optimal levels, those figures are still on L1.

Like? Share with your friends!

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on whatsapp
WhatsApp
Share on telegram
Telegram