Eggstravaganza

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

Use of require for reverts instead of custom errors

Summary

The contracts extensively use require statements with string messages for validation and access control. While functionally correct, this pattern is less gas-efficient and harder to manage in larger codebases compared to using custom errors.

Vulnerability Details

Examples from the contracts include:

require(!gameActive, "Game already active");

Impact

  • Gas Inefficiency: Revert strings increase deployment and transaction costs.

  • Maintainability: Strings are prone to typos and harder to refactor at scale.

  • Readability: Custom errors offer clearer intent and better tooling support for error tracing.

Tools Used

  • Manual code inspection

Recommendations

  • Replace common require(..., "...") statements with custom errors, especially for repetitive checks like ownership, access control, and state transitions.

  • Define custom errors at the top of the contract:

error Eggstravaganza_GameAlreadyActive();
  • Update require statements accordingly:

if (!gameActive) {
revert Eggstravaganza_GameAlreadyActive();
}

This change will result in cleaner code, lower gas usage, and easier error tracking, especially as the contract ecosystem scales.

Updates

Lead Judging Commences

m3dython Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Gas optimization

Strategy to save gas and minimize transaction costs

Support

FAQs

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