Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Incorrect Error Message in withdrawPredictionFees Function

Summary

The function withdrawPredictionFees is designed to allow only the organizer to withdraw prediction fees. However, it returns the error message ThePredicter__NotEligibleForWithdraw() instead of the more appropriate ThePredicter__UnauthorizedAccess() when an unauthorized user attempts to withdraw funds.

Impact

Confusion and Miscommunication: Users or developers interacting with the contract might be misled by the incorrect error message. They may not understand that the failure is due to unauthorized access rather than eligibility for withdrawal.

  • Debugging Difficulty: Incorrect error messages complicate debugging and troubleshooting, leading to potential delays in resolving issues.

  • Security Implications: Although the primary function and security of the contract are not directly compromised by this issue, clear and precise error handling is a best practice in contract development, which ensures better security and maintainability.

Recommendations

Modify the error message to accurately reflect the reason for the failure. Replace ThePredicter__NotEligibleForWithdraw() with ThePredicter__UnauthorizedAccess() to provide clear and precise feedback.

function withdrawPredictionFees() public {
if (msg.sender != organizer) {
revert ThePredicter__UnauthorizedAccess(); // Correct error message
}
uint256 fees = address(this).balance - players.length * entranceFee;
(bool success, ) = msg.sender.call{value: fees}("");
require(success, "Failed to withdraw");
}

}

Updates

Lead Judging Commences

NightHawK Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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