Project Ririsu! smart contract’s contribution to the NFT space

Project Ririsu!
4 min readFeb 14, 2022

Every serious NFT projects attempt to offer a gas-optimized minting experience to their community. Usually, projects use the same contract code as their predecessors. Others try to tweak it to have slight gains from minor optimizations.

We could have used the same contracts that we see other teams are using, from standard ERC721 contracts to the most recent innovation from Azuki which settled a new standard known as ERC721A.

We felt we could do things differently, both for teams and the users. While the gas cost for the minting operation is important, we believe that improvements can revolve around the other functions and utilities of the ERC721 contract.

In no way are we trying to sound superior to what Azuki team did with ERC721A. Their innovation is really impressive in regards to multiple mints, especially when a member has to mint 3+ NFT at the same time. We will try to rationally compare what we did differently to ERC721A as this is the newest standard of the moment.

We believe that every improvement brought to the space will benefit the entire NFT community in the future. As such, we are thankful for Squeebo’s contribution to the NFT space with his implementation called ERC721B which we took a lot of inspiration from.

A deep dive in our attempt to create something different

The Ririsu! smart contract is the product of days of research to find the most efficient smart contract setup that would reduce user friction into the Ririsu ecosystem. Gas is a crucial aspect of Ethereum, and it is based on the number and type of instructions executed by a smart contract. Among these instructions, writing data to the blockchain is by far the most expensive operation.

ERC721A (Azuki) contract is notable for reducing the cost of minting multiple NFT, as they came up with a way to reduce batch minting gas fees by only explicitly assigning ownership for the first token in the batch. The way this works is the underlying data structure doesn’t have to be sequentially assigned, so if you mint 4 tokens, ownership of the first token is explicitly assigned to you, and the contract utilizes lookback if it encounters a token that does not explicitly have an owner. These items can not stay implicitly set though and they must explicitly be set at some point. This means this just passes the gas fees off to a different part of the contract. An example of this is transferring an implicitly owned token, or when the team calls a “cleanup” function to explicitly set owners. Again, the gas is passed on somewhere else in the contract, not wholly avoided altogether.

Innovation isn’t all about the cost of minting an NFT though. There is a limit where that action can be optimized and we believe that there are many areas where improvements could be made.

The Ririsu! contract utilizes a completely different data structure for storing token ownerships and balance information. ERC721A and most other contracts use two separate variables, one for balances and the other for token ownership. Every time you mint or transfer a token, both of these structures are written to the contract.

We also implemented a cryptographic allowlist. This allows us to create “mint passes” that can only be used by the address they are created for. By doing this, wallet addresses do not need to be uploaded to the contract for the allowlist, reducing the gas cost incurred by the team executing an allowlist by ~98%.

Furthermore, the data passed to the contract to verify someone’s “mint pass” is less than that associated with Merkle tree-based allowlists

This is because to implement a Merkle tree allowlist, one would need to generate a Merkle proof for every address, and each of those addresses would then need to provide their proof when minting. For an allowlist of 7 addresses, we would need to generate a proof that contains 3 hashes in the Merkle proof. Because data passed into smart contract functions also costs gas, this passes the cost of the allowlist on to the minter. We can already see here that the array of hashes containing 3 elements would be more expensive to upload than the ECDSA based allowlist.

The ECDSA based allowlist mechanism is cost constant, meaning no matter how big the allowlist is, it will always cost the same amount for both the minter and the founding team, as it is just one signed message of a fixed length. The Merkle proof-based allowlist grows relative to the size of the allowlist, and thus so does the cost.

Recall that writing and storing data is the most expensive instruction there is on Ethereum. The Ririsu! contract uses a single data structure for both addresses and ownerships, and this enables minting and transfers under the Ririsu! contract to write ~50% of the data on-chain while losing no resolution into the token’s ownership information.

On top of all of this, we also take advantage of gas-less OpenSea approvals, reducing user fees and secondary market friction. If you’re curious about this, you can read more here: https://docs.opensea.io/docs/1-structuring-your-smart-contract#opensea-whitelisting-optional

By all these improvements, we hope we will create a legacy to the next projects that are coming and to the entire NFT space.

--

--

Project Ririsu!

https://www.ririsu.io/ — Ririsu NFT is a project driven to give utility back to the holders.