New Smart Contracts Promise Reduced NFT Gas Costs

Transaction fees are an unfortunate fact of life on the Ethereum mainnet – NFT gas costs even moreso. The success of NFT projects is particularly vulnerable to high fees, as they inflate the cost of the token. A $75+ gas fee is extremely unattractive to someone minting a single 0.05 Ξ NFT, and may even put the user off of the project altogether.

Luckily, developers are starting to implement new smart contracts which promise reduced gas costs. These performance gains come as developers gain enough confidence in Solidity to venture beyond the battle-tested OpenZeppelin implementations and optimize for efficiency.

The new methods were pioneered by @Squeebo, and quickly adopted by a variety of projects, including Alpha Girl Club and Mecha Chaotic Bedlam.

The War on Gas

At a high level, the new wave of smart contracts are innovating in three main areas to reduce NFT gas costs:

  1. Custom ERC-721 implementations
  2. Replacing more powerful but expensive libraries with lean, lightweight code
  3. Cryptographic whitelisting

Custom ERC-721 Implementations

To avoid bugs and risk, and to focus on the unique parts of their projects, developers use existing code libraries to implement the base ERC-721 interface of their NFT projects. (Reminder: ERC-721 is a standard used by most non-fungible tokens).

When it comes to Solidity libraries, there is only one king: OpenZeppelin. This repository of battle-tested smart contracts is an industry standard for fungible and non-fungible tokens alike. The new wave of developers have found gains in the portion of the implementation responsible for assigning a token to an address (state changing), and checking the total supply of NFTs or balance of an address (read only).

OpenZeppelin’s implementation uses equally expensive methods for the state changing – which costs gas – and read only – which does not cost gas – portions of the contract. The emerging variant uses a method which is very cheap and efficient for state changes, and very inefficient to read. However, since reading the state does not cost gas, the user doesn’t care about the efficiency of that operation!

Replacing Libraries

A commonly used OpenZeppelin library, ERC721Enumerable, implements functions to easily track on-chain all tokens owned by an address. In doing so, it introduces extra operations each time the token is minted or transferred. These extra operations cause bloat and cost the user.

Most projects do not require the whole suite of functionality from ERC721Enumerable, only a single function: totalSupply(). Newer smart contracts are using another library, Counters, to implement the totalSupply() functionality, and cut out the unneeded code. This saves the user gas on both minting and transferring.

Cryptographic Whitelisting

Whitelisting is a commonly-used method to avoid gas wars for project mints. The simple way to handle this is to upload all the whitelisted addresses to the smart contract as a list. This results in ballooning gas costs for project teams, as writing to storage on the blockchain is one of the most expensive operations in Ethereum.

Another, cheaper way to allow verification of whitelisting is required. Modern contracts are increasingly using Merkle trees for this function. In a Merkle whitelist, only the root hash of the Merkle tree is uploaded to the contract. Users verify their whitelist by providing a cryptographic proof that their address is part of the Merkle tree.

This method replaces any number of storage operations with a single storage operation, making it an attractive option for large projects with thousands of whitelisted addresses.

Depending on the contract, implementing the above changes can reduce gas costs by 50% or more. The end result of these improvements is to save money – for both the users and the contract deployer. This capital stays available to the ecosystem, increasing the vitality and long term survivability of the project. The innovation ball has been put in OpenZeppelin’s court – time will tell how they respond.

Photo of author

Written By BowTiedPickle

Anonymous cartoon pickle inspired by BowTiedBull. Degen chemical engineer, moonlighting as a Solidity developer.

Disclosure

This article may contain links to third-party websites or other content for information purposes. BowTiedIsland may receive a commission at no cost to you if you purchase a product after clicking one of these links. The Third-Party Sites are not under the control of BowTiedIsland, and BowTiedIsland is not responsible for the content of any Third-Party Site. All information contained herein is the opinion of the writer and does not constitute financial advice. We aim to act as a neutral third party and aid in your research and analysis.


The Jungle


Crypto, Investing, and E-Commerce with BowTied Bull

The future is internet based, therefore we have a triangle based approach with crypto, e-commerce business making and Investing in traditional assets

The Culture War with BowTiedRanger

Whether you’re a political junkie or just interested in current events. 

You’ve come to the right place for analysis of the most relevant current events and political issues.

Fitness With BowTiedOx

BowTiedOx provides you a place to find all of his latest programs and guides.

Weekly newsletters that cover fitness, health, and mindset, all grounded in the fundamentals of physiology.

Media Production with BowTied Turkey and BowTied Tamarin

Video is no longer optional.

Don’t get left behind.

Your brand deserves professional videos to engage your audience.

Art & Graphic Design with BowTied Patriot

BowTied Patriot is a graphic artist who specializes in photography, mixed medium custom artwork, and NFT creation.

Join BowTiedPatriot as he dives into making Art in Web3.0 and The Metaverse.

Cooking with BowTiedOctopod

Learn secrets from a fine dining chef for maximum flavor and time-saving efficiency

Newsletters on Ingredients, Techniques and Flavor hacks that will have you eating better. We will never eat bugs!

Meme Warfare with DgenFren

Increase your online engagement, organically influence narratives, and build your online persona by using marketing that your target audience actually wants: memes.

Learn How to Sell with BowTiedSalesGuy

Sales is one of the most transferrable life skills, yet few know how to actually sell.

Traditional sales tactics don’t cut it in today’s hyper competitive world.

Learn the secrets from a Chad Salesman and change your Life forever.

Ecommerce with BowTiedOpossum

Learn the skills to start and build your first online business.

Want to build a business that travels with you?

Learn from an industry veteran that has worked on and with brands you already know.