Eggstravaganza

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

The mintEgg() function in the EggstravaganzaNFT contract has an unused return value, causing unnecessary gas consumption

Description

The mintEgg() function in the EggstravaganzaNFT contract is vulnerable due to an unused return value, which unnecessarily increases gas fees. To optimize, the return value should either be used or explicitly discarded

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

Impact

The unused return value in the mintEgg() function increases gas fees.

Proof of code

Below is the test case that shows how gas fees are consumed by the unused return value:

  • Without Return Value: Gas fees consumed: 80,913

  • With Return Value: Gas fees consumed: 80,921

Tools Used

1) VS Code

2) Aderyn

Recommendations : If you don't use the return value, either remove it or utilize it

Updates

Lead Judging Commences

m3dython Lead Judge about 2 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope
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.