Eggstravaganza

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

State Variable Could Be Immutable

Summary

State variables eggNFT and eggVault in the EggHuntGame contract are only set in the constructor and never modified afterwards. These variables should be declared as immutable to reduce gas costs.

Vulnerability Details

The following state variables are only assigned values in the constructor and are never changed throughout the contract's lifecycle:

EggstravaganzaNFT public eggNFT;
EggVault public eggVault;

These variables are referenced in multiple functions, and each access costs more gas than necessary because they're stored in the contract's storage rather than in the bytecode itself.

Impact

Low impact (gas inefficiency). This issue doesn't affect the security or functionality of the contract, but it does result in higher gas costs for users interacting with the contract, particularly when calling functions that reference these variables.

Tools Used

Manual code review - Aderyn and slither

Recommendations

Declare these state variables as immutable to reduce gas costs:

EggstravaganzaNFT public immutable eggNFT;
EggVault public immutable eggVault;

This change will reduce the gas cost of reading these variables, as immutable variables are stored in the contract bytecode rather than in storage. The gas savings will apply to every function that reads these variables, providing a cumulative benefit over the contract's lifetime.

Updates

Lead Judging Commences

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
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.