Eggstravaganza

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

No way of knowing if the search is successful or not

Summary

When a player searches for eggs calling the searchForEggs() function, there is no direct way of knowing if the search was successful or not. The function doesn't return a find status.
Unless they check their wallet, check eggsFound or locking through transaction details.

Vulnerability Details

No feedback for players on performed searches

Impact

Negative impact on players experience

Tools Used

Forge Test, Remix, Manual review

Recommendations

Add return messages for succesfull/unsuccessful searches

/// @notice Participants call this function to search for an egg.
/// A pseudo-random number is generated and, if below the threshold, an egg is found.
function searchForEgg() external returns (string memory searchStatus) {
require(gameActive, "Game not active");
require(block.timestamp >= startTime, "Game not started yet");
require(block.timestamp <= endTime, "Game ended");
require(10 <= eggFindThreshold, "Threshold must be >= 10"); // Values lower than 10 not allowed
// Pseudo-random number generation (for demonstration purposes only)
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]);
return "Congratulations! You found one egg!"; // Message to signal a successful search
} else {
return "Unsuccsessful search! Try again!"; // // Message to signal a unsuccessful search
}
}

This can also be done in the front end side.

Updates

Lead Judging Commences

m3dython Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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