Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

save gas by using require instead of validate by if statement and revert

Summary

Vulnerability Details

if (msg.sender != s_owner) {
revert PasswordStore__NotOwner();
}

The gas cost for this code can be broken down as follows:

The gas cost of evaluating the conditional statement.
The gas cost of executing the revert function.

Impact

unnecessary gas cost

Tools Used

foundry testing

Recommendations

Using require instead of if statement then revert can optimize gas usage. When using require, gas is consumed only if the condition is not met,

require(msg.sender == s_owner, "NotOwner");
Updates

Lead Judging Commences

inallhonesty Lead Judge
about 2 years ago
inallhonesty Lead Judge about 2 years ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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