ArkDev Profile picture
24 Nov, 10 tweets, 2 min read
🚨 Stop Paying High Gas Fees With NFT Mints 🚨

We just launched the presale mint for @grayboysdao.

The average mint tx fee was under 0.01 eth, and in many cases closer to 0.008 eth to mint 3 Gray boys in 1 tx.

This is a thread on the optimizations we did to achieve that.
1/

First off, any project that has high gas fees to mint and is not doing any special with on chain generation or on chain data is proooobably not gonna make it (lol).

Regardless, some of these optimization tips apply to pretty much every nft project so read thoroughly.
2/

The easiest optimization is not using ERC721Enumerable unless you need it.

Most "How-to" guides online for writing NFT projects use this, but it's not a requirement and most projects don't even utilize the extra functionality.

This reduces gas by ~70% PER TOKEN MINTED.
3/

Minimize iterative loops. Every bit of computation required during contract function execution requires gas.

"for" & "while" loops are often the biggest culprits for ballooning gas fees. Do not use these unless absolutely necessary.
4/

TRIM. THE. FAT.

Any mint function modifiers you're using, make absolutely sure that you actually need them.

Oftentimes this may be using something like Reentrency Guard for example as a precaution when it may not necessary depending on the surrounding context.
5/

Remove unnecessary libraries to further trim fat.

This could be things like SafeMath in later solidity compiler versions that implement it by default, or helper libraries that have unoptimized implementations or hidden loops that cause ballooning gas fees.
6/

Explicitly label your functions as "external" where possible. This will force function parameter storage to use calldata instead of memory, further optimizing gas fees.
7/

Optimizing data type usage.

uint should be used in place of strings WHEN POSSIBLE.

uint256 ironically takes less gas to store than a uint8

bytes should always be used over byte[]

If bytes length has a known maximum length, use the lowest length possible. bytes1 to bytes32
8/

More on loops.

DO NOT DO COMPLEX OPERATIONS IN LOOPS UNLESS ABSOLUTELY NECESSARY, PERIOD.

THEY ARE EXPENSIVE.
9/

There's more little things, but these tips are going to give you the biggest savings for the least amount of effort.

There's not really an excuse for a project having high gas fees if they're simply minting and not doing on-chain generation, or on-chain data.

Follow 4 more!

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with ArkDev

ArkDev Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Thank you for your support!

Follow Us on Twitter!

:(