Mystery Box

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

Missing Event Emissions for Critical Functions

Summary

Critical functions like setBoxPrice, buyBox, and changeOwner do not emit events, which makes it difficult to track important state changes off-chain. Without event emissions, it is harder to monitor and audit contract actions.

Vulnerability Details

Each of these functions should emit an event when executed.

Tools Used

manual

Recommendations

Add event definitions and emit statements:

event BoxPriceSet(uint256 newPrice);
event BoxPurchased(address buyer);
event OwnerChanged(address newOwner);
function setBoxPrice(uint256 _price) public {
require(msg.sender == owner, "Only owner can set price");
boxPrice = _price;
emit BoxPriceSet(_price);
}
function buyBox() public payable {
require(msg.value == boxPrice, "Incorrect ETH sent");
boxesOwned[msg.sender] += 1;
emit BoxPurchased(msg.sender);
}
function changeOwner(address _newOwner) public {
require(msg.sender == owner, "Only the owner can change ownership");
owner = _newOwner;
emit OwnerChanged(_newOwner);
}
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!