Max0x90 pfp
Max0x90
@maxcoto
5 Gas Optimization Patterns I Learned Building NFT Protocols. After deploying 10+ NFT contracts, here are the patterns that actually save gas: 🧵
1 reply
0 recast
0 reaction

Max0x90 pfp
Max0x90
@maxcoto
1/8 First, the obvious but crucial: Use packed storage Before: 813,562 gas ⛽️ After: 793,147 gas ⛽️ Code comparison 👇
1 reply
0 recast
0 reaction

Max0x90 pfp
Max0x90
@maxcoto
2/8 Unoptimized:
1 reply
0 recast
0 reaction

Max0x90 pfp
Max0x90
@maxcoto
3/8 Optimized:
1 reply
0 recast
0 reaction

Max0x90 pfp
Max0x90
@maxcoto
4/8 Use unchecked blocks for safe math. Example: incrementing tokenId in mint function Saves ~35 gas per mint:
1 reply
0 recast
0 reaction

Max0x90 pfp
Max0x90
@maxcoto
5/8 Batch mint operations using ERC721A. Regular mint (5 NFTs): ~874,542 gas ERC721A mint (5 NFTs): ~254,763 gas
1 reply
0 recast
0 reaction