Eggstravaganza

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

Minting an NFT from outside of the `EggHuntGame` contract can break all minting

[H-2] Minting an NFT from outside of the EggHuntGame contract can break all minting

Description: If an NFT with a is minted outside the game contract and the tokenId is low enough the game will try to mint the same tokenID and revert.
Impact: The game contract only increments the eggCounter value after a successsful mint. If a mint reverts, that counter will never increment and the game contract can not mint any more NFTs.
Recommended Mitigation: Add a function exists in the EggstravaganzaNFT contract and check if an NFT with the tokenId exists before trying to mint in the searchForEgg() function

if (random < eggFindThreshold) {
eggCounter++;
eggsFound[msg.sender] += 1;
+ while(eggNFT.exists(eggCounter)) {
eggCounter++;
}
+ eggCounter++;
+ }
eggNFT.mintEgg(msg.sender, eggCounter);
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}
Updates

Lead Judging Commences

m3dython Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Appeal created

graves Submitter
8 months ago
m3dython Lead Judge
8 months ago
m3dython Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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

Give us feedback!