The EggHuntGame
contract contains two state variables, eggNFT
and eggVault
, which are set in the constructor and never modified afterward. However, these variables are not declared as immutable
, resulting in unnecessary storage reads and higher gas costs.
The contract references are defined as regular state variables instead of immutable variables:
These references are initialized in the constructor and never changed throughout the contract's lifecycle:
Increased gas costs for all functions that read these variables
Missed optimization opportunity that would benefit users of the contract
Slightly higher deployment costs
Every time a function like searchForEgg()
or depositEggToVault()
is called, the contract must read these variables from storage, which costs more gas than reading from immutable variables that are stored in the contract bytecode.
Manual review
Declare the contract references as immutable
to save gas and improve contract efficiency:
This change will reduce gas costs for users interacting with the contract and is a best practice for variables that are set once and never changed.
Strategy to save gas and minimize transaction costs
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.