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]);
}
}
```