Mystery Box

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

No Refund Mechanism for Excess Ether in buyBox function

Description

If users send more Ether than the boxPrice, the transaction reverts.

require(msg.value == boxPrice, "Incorrect ETH sent");

Impact

  • User Inconvenience: Transactions fail unnecessarily.

  • Poor User Experience: Users may be confused about the failure.

Recommendations

Allow for excess Ether and refund the difference:

require(msg.value >= boxPrice, "Not enough ETH sent");
uint256 excess = msg.value - boxPrice;
if (excess > 0) {
(bool refundSuccess,) = msg.sender.call{value: excess}("");
require(refundSuccess, "Refund failed");
}
boxesOwned[msg.sender] += 1;
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!