Eggstravaganza

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

Token ID 0 is skipped due to pre-increment of `eggCounter`

Vulnerability Details

The eggCounter variable, which determines the tokenId for newly minted NFTs, is incremented before the eggNFT.mintEgg function is called within searchForEgg. Assuming eggCounter starts at 0, this logic ensures the first minted egg will have tokenId 1, the second tokenId 2, and so on, preventing tokenId 0 from ever being minted.

if (random < eggFindThreshold) {
eggCounter++; // Counter incremented here
//@audit-issue tokenId 0 will never be minted as eggCounter is incremented before minting
eggsFound[msg.sender] += 1;
// Mint function called with the already incremented value
eggNFT.mintEgg(msg.sender, eggCounter);
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}

Impact

The NFT with token ID 0 will never be minted.

Recommendation

Increment the eggCounter state variable after calling the eggNFT.mintEgg function to allow minting to begin from token ID 0.

Updates

Lead Judging Commences

m3dython Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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