Content pfp
Content
@
0 reply
0 recast
0 reaction

Mahima Thacker pfp
Mahima Thacker
@mahimathacker
Gas-Saving Tip: Use 'unchecked' in Solidity for Leaner Contracts ๐Ÿ’ก In #Solidity, every operation is safe by default, including arithmetic operations from the 0.8th version๐Ÿ‘‡
0 reply
0 recast
0 reaction

Mahima Thacker pfp
Mahima Thacker
@mahimathacker
This means they automatically check for errors like overflows. But with the unchecked keyword, you can bypass these checks when you're certain they're not needed, and save gas in the process.
0 reply
0 recast
0 reaction

Mahima Thacker pfp
Mahima Thacker
@mahimathacker
Take this attached snippet for example ๐Ÿ‘‡
0 reply
0 recast
0 reaction

Mahima Thacker pfp
Mahima Thacker
@mahimathacker
By using unchecked, we're telling Solidity that we know myNumber won't overflow, and it can skip the extra gas it would normally use to check. This tiny change shaves off gas with every call, optimizing our contract for cheaper transactions
0 reply
0 recast
0 reaction