TwentyOne

First Flight #29
Beginner FriendlyGameFiFoundrySolidity
100 EXP
View results
Submission Details
Severity: low
Invalid

public functions not used internally could be marked external

Summary:** In Solidity, functions marked as public are accessible externally and internally. If a function is never called internally within the contract, it is recommended to mark it as external to optimize gas usage and improve clarity.**

Vulnerability Details: When functions that are only intended for external use are declared public, the Solidity compiler generates code that allows these functions to be called both externally and internally. This results in unnecessary overhead because public functions require additional mechanisms to handle both types of calls.

function startGame() public payable returns (uint256) {
function hit() public {
function call() public {
function getPlayerCards(address player) public view returns (uint256[] memory) {
function getDealerCards(address player) public view returns (uint256[] memory) {

Impact: Marking functions public unnecessarily:

  • Increased Gas Costs: The compiled bytecode for public functions is slightly larger, increasing deployment and execution costs.

  • Code Clarity: The intended use of the function is less explicit, which can make the contract harder to understand or audit.

Tools Used: Aderyn

Recommendations: For functions not used internally, change the visibility modifier from public to external.

Updates

Lead Judging Commences

inallhonesty 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.