handsome pfp
handsome
@wizard
🔥 Day 2 of #30daysweb3security @Web3SecurityDAO Today I learnt THREE interesting gas saving tips 🧵: 1. Changing a uint from zero to non-zero cost 20k gas, but only 5k gas when changed from non-zero to non-zero. So, start your NFT totalSupply from 1 instead of 0!
2 replies
0 recast
0 reaction

handsome pfp
handsome
@wizard
3. Reading from storage is expensive! If we write to a local variable, then update storage at the end, we can save some gas. See before and after below! p.s. but doing this does increase contract size https://i.imgur.com/Q5EIrFT.png
0 reply
0 recast
0 reaction