Mystery Box

First Flight #25
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Gas Optimization Issues in MysteryBox

Summary

The addReward function in the MysteryBox contract employs the push method to add rewards individually to the rewardPool array. This approach can lead to high gas costs, especially when multiple rewards are added in succession.

function addReward(string memory _name, uint256 _value) public {
require(msg.sender == owner, "Only owner can add rewards");
rewardPool.push(Reward(_name, _value));
}

Impact

High gas costs may deter users from interacting with the contract, negatively affecting user experience and participation rates.

Tools Used - auditX

Recommendations

To optimize gas usage, it is recommended to implement a bulk addition function that allows the addition of multiple rewards in a single transaction. This change can significantly reduce gas consumption and enhance the overall user experience.

Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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

Give us feedback!