The transferAdmin
function in the Adminable
contract is marked as public
but can be declared as external
, which is more gas-efficient.
In the Adminable
contract, the transferAdmin
function is currently defined with public
visibility. This allows the function to be called both internally (from within the contract) and externally (from other contracts or users). However, since this function is not intended to be called from within the contract itself, it should be declared as external
.
Using public
instead of external
can result in unnecessary gas costs for users, as Solidity uses different mechanisms for calling functions based on their visibility. When a function is marked as external
, it can only be called from outside the contract, leading to slightly lower gas usage because of the optimizations the Solidity compiler applies for external function calls.
While this issue does not directly break any security guarantees, it can lead to higher gas costs for users. In a smart contract environment, where gas prices can fluctuate, this might discourage users from interacting with the contract.
Current Function Declaration:
Proposed Change: Change the visibility from public
to external
.
This issue is classified as low severity since it does not affect the contract's functionality or security but can lead to increased costs for users. Efficient gas usage is important in smart contracts to enhance user experience and optimize interaction costs.
Here is the existing function declaration that can be improved:
By changing the visibility to external
, it would look like this:
To fix this issue, modify the visibility of the transferAdmin
function from public
to external
. This change will optimize gas costs without altering the intended functionality of the contract.
Adminable.sol
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.