NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Use unchecked {++i} and don't declare i=0

Summary

Since the default value of a uint in solidity is 0 and not null, there is no need to declare i=0 when using loops.

++i costs less gas compared to i++ or* i += 1* for an unsigned integer, as pre-increment is cheaper (about 5 gas per iteration). This statement is true even with the optimiser enabled.

it’s safe to put the ++i increment under the unchecked {…} wrap without losing on security.

Vulnerability Details

Gas optimisation that could help optimize the contracts.

Impact

Cheaper for the users.

Tools Used

Main review.

Recommendations

Change the loops : "for (uint256 i = 0; i < arg1; i++)" to "for (uint256 i; i < arg1;)" and add "unchecked{++i}"

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational / Gas

Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.