Eggstravaganza

First Flight #37
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

`eggFindThreshold` in `EggHuntGame` contract should be constant to save gas.

Summary

The eggFindThreshold value is never changed, so it should be marked as constant to save gas.

Vulnerability Details

In the EggHuntGame contract, eggFindThreshold is declared as a state variable. Storing this as a state variable unnecessarily consumes gas.

uint256 public eggFindThreshold = 20; // Default is a 20% chance

Impact

Making the variable constant instead of a state variable saves gas.

Tools Used

manual code review.

Recommendations

uint256 public CONSTANT EGG_FIND_THRESHOLD = 20;
Updates

Lead Judging Commences

m3dython Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope
Assigned finding tags:

Gas optimization

Strategy to save gas and minimize transaction costs

Support

FAQs

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