Eggstravaganza

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

Refactor EggstravaganzaNFT::mintEgg() to remove unused return value

Summary

The EggstravaganzaNFT::mintEgg() returns a bool value (true) that is always returned unconditionally and is not used by the caller EggHuntGame::searchForEgg() in the game contract. This leads to redundant code and may mislead developers into thinking the return value holds meaningful logic, which it does not.

Vulnerability Details

Here is the affected function in EggstravaganzaNFT.sol which always returns a bool which is not being used.

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

Here is the caller function in EggHuntGame.sol

function searchForEgg() external {
---
if (random < eggFindThreshold) {
eggCounter++;
eggsFound[msg.sender] += 1;
//Return bool value being ignored
eggNFT.mintEgg(msg.sender, eggCounter);
emit EggFound(msg.sender, eggCounter, eggsFound[msg.sender]);
}
}

Impact

Impact:Low-No functional vulnerability or reentrancy issue, but affects code clarity and gas optimization

Recommendations

Consider removing this return value

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

Lead Judging Commences

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

Gas optimization

Strategy to save gas and minimize transaction costs

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.

Give us feedback!