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👇
2 replies
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.
1 reply
0 recast
0 reaction

Mahima Thacker pfp
Mahima Thacker
@mahimathacker
Take this attached snippet for example 👇
1 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
1 reply
0 recast
0 reaction

Mahima Thacker pfp
Mahima Thacker
@mahimathacker
⚠️ Caution: Only use unchecked when you're sure there won't be overflows, as it could lead to vulnerabilities! #SmartContracts #GasOptimization
0 reply
0 recast
0 reaction