ERC721G — A Creative and Utilitarian Approach to Batch Minting

The Creative Process

To write ERC721G comes from two inefficient mappings, and 1 conceptual theory.

The Inefficient Mappings

The New Efficient Mappings

To use these available bytes, we used Structs that can make use of these wasted data slots.

  • Tracking the last transfer time
  • Stake the NFT
  • Track the total amount of time staked

The Conceptual Theory

The Conceptual Theory that we will be using is that — given a function’s arguments, a smart contract behavior is derived. If we are able to derive the smart contract behavior in such a way that the outside interactions (generally, through read functions) is as expected, optimizations can be performed.

The Efficient Implementation

However, SSTORE packing, either through Structs or bytecode, can achieve the above result without trade-offs as well, by implementing efficient usage of available bytes and packing multiple variables in Structs — exactly what we did with ERC721G

Batch Minting

Batch minting is a method to mint multiple NFTs using a single SSTORE write. This generally is done through lookup tracing and phantom minting.

Batch Minting + Staking

In addition to batch minting, ERC721G implements a creative innovation that allows batch minting and staking at once. This has minimal gas impacts to batch minting, and efficiently mints and stakes multiple tokens at once for a fraction of the cost.

Unstaking

If anyone has done staking before, then they will know that they will have to store the staker address of the token ID to the smart contract in order to figure out who has the ability to unstake.

Keeping Track of Total Time Staked

In addition to staking and unstaking, I figured a useful metric that we can measure for an NFT is the total time staked, which is used in some staking implementations such as MoonBirds’ “nesting” logic.

Encouraging HODLing

Last but not least, each token comes with their own tracker for the last timestamp of transfer. Project owners can use this logic to determine how long a token has been held and do creative things with it.

Modularity

ERC721G’s functions are divded into nice modules of internal functions.

  • _mint
  • _mintAndStake
  • _transfer
  • _stake
  • _unstake

Summarizing ERC721G

And there you have it! A token standard that does:

  • Batch Minting
  • Batch Mint and Stake
  • Single-Contract Staking
  • Single-Contract Unstaking
  • Keep track of Total Time Staked
  • Keep track of Last Transfer Time

A more Business-Oriented Description

For a more business-oriented description, consult this segment.

  • Batch Minting — a gas-efficient method of minting
  • Batch Mint and Stake — a gas-efficient method of minting and staking, potentially 2 to 3 times more efficient than Batch Minting alone
  • Single-Contract Staking — a gas-efficient method of staking an NFT
  • Single-Contract Unstaking — a gas-efficient method of unstaking an NFT
  • Keep track of Total Time Staked — a useful metric tracker for NFTs that can be implemented for holding and staking rewards down the line
  • Keep track of Last Transfer Time — a useful metric tracker for NFTs that can be used to encourage HODLing and reward users who held their NFTs for extensive periods of time

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
0xInuarashi

0xInuarashi

Crypto Enthusiast, Writer, Developer.