OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: low
Likelihood: low
Invalid

Functions Marked public Instead of external Despite No Internal Usage

Functions Marked public Instead of external Despite No Internal Usage

Description

Several functions in the OrderBook contract are marked public, even though they are never called internally. In Solidity, marking such functions as external is more gas-efficient for external callers and more accurately communicates the developer's intent.

Using public unnecessarily:

  • Slightly increases gas costs when called externally

  • Expands the ABI unnecessarily

  • Reduces code clarity and increases maintenance burden

This pattern was identified via Solidity Metrics.

Affected Functions

Function Visibility Internal Usage
createSellOrder() public
amendSellOrder() public
cancelSellOrder() public
buyOrder() public
getOrder() public
getOrderDetailsString() public

Recommended Mitigation

Change visibility from public to external for all functions that are not called internally:

- function createSellOrder(...) public returns (...) {}
+ function createSellOrder(...) external returns (...) {}
- function buyOrder(...) public {}
+ function buyOrder(...) external {}

This adheres to gas optimization best practices and reduces the contract's external surface area.

Updates

Lead Judging Commences

yeahchibyke Lead Judge 4 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.