Eggstravaganza

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

Gas Optimization Missed: Storage vs Immutable

Summary:

The EggHuntGame smart contract enables players to find and mint NFTs during a limited-time egg hunt game. The game interacts with an EggstravaganzaNFT contract and an EggVault contract to facilitate minting and storing of egg NFTs.

The contract is well-structured and readable, but there are some areas where gas optimizations and security improvements can be made.

Vulnerability Details:

EggstravaganzaNFT public eggNFT;
EggVault public eggVault;
  1. Both eggNFT and eggVault are contract references that are set once in the constructor and never change.

  2. Currently, they are stored in contract storage, leading to high gas usage on each read (SLOAD = ~2100 gas).

  3. These variables should be marked as immutable for efficient bytecode-level storage and low-cost access.

Impact:

Gas inefficiency: Repeated SLOAD operations in heavily-used functions such as searchForEgg and depositEggToVault cause unnecessary gas spending.

Tools Used

Mannual code review

Recommendations:

EggstravaganzaNFT public immutable eggNFT;
EggVault public immutable eggVault;
Updates

Lead Judging Commences

m3dython Lead Judge 9 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.

Give us feedback!