Eggstravaganza

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

EggHuntGame.searchForEgg() ignores return value by eggNFT.mintEgg(msg.sender,eggCounter)

Summary

EggHuntGame.searchForEgg() ignores return value by eggNFT.mintEgg(msg.sender,eggCounter)

The function EggHuntGame::searchForEgg

function searchForEgg() external {
require(gameActive, "Game not active");
require(block.timestamp >= startTime, "Game not started yet");
require(block.timestamp <= endTime, "Game ended");
uint256 random = uint256(
keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter))
) % 100;
if (random < eggFindThreshold) {
eggCounter++;
eggsFound[msg.sender] += 1;
@> eggNFT.mintEgg(msg.sender, eggCounter);
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}
}

The function EggstravaganzaNFT::mintEgg has a return doesn't used

function mintEgg(address to, uint256 tokenId) external returns (bool) {
require(msg.sender == gameContract, "Unauthorized minter");
_mint(to, tokenId);
totalSupply += 1;
@> return true;
}

Vulnerability Details

check is needed to ensure that the minting is successful

Impact

The return value of an external call is not stored in a local or state variable.

Tools Used

Slither

Recommendations

Ensure that all the return values of the function calls are used.

```diff
function searchForEgg() external {
require(gameActive, "Game not active");
require(block.timestamp >= startTime, "Game not started yet");
require(block.timestamp <= endTime, "Game ended");
uint256 random = uint256(
keccak256(abi.encodePacked(block.timestamp, block.prevrandao, msg.sender, eggCounter))
) % 100;
if (random < eggFindThreshold) {
eggCounter++;
eggsFound[msg.sender] += 1;
- eggNFT.mintEgg(msg.sender, eggCounter);
+ (bool success) = eggNFT.mintEgg(msg.sender, eggCounter);
+ require(success, "Minting failed");
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}
}
```

Updates

Lead Judging Commences

m3dython Lead Judge 2 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Unused return value

Returns a boolean value that isn't utilized by its caller

Support

FAQs

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