Raisebox Faucet

First Flight #50
Beginner FriendlySolidity
100 EXP
Submission Details
Impact: high
Likelihood: high
Invalid

Inefficient Use of Storage Variable for faucetClaimer

Author Revealed upon completion

Root + Impact

The faucetClaimer address is unnecessarily stored as a state variable in contract storage, even though it’s only used temporarily inside the claimFaucetTokens() function.

Normally, transient data such as the caller’s address should be held in memory (stack) variables to save gas and avoid accidental persistence.

function claimFaucetTokens() external {
@> address faucetClaimer = msg.sender; // can be memory, not storage
...
}

However, in this implementation, faucetClaimer appears to be declared as a state variable, which means each assignment incurs an expensive SSTORE operation on the blockchain. This wastes gas and could cause unintentional overwriting if reused elsewhere.// Root cause in the codebase with @> marks to highlight the relevant section

Risk

Likelihood:

  • Occurs on every faucet claim transaction.

  • Happens consistently whenever any user claims tokens.

Impact:

  • Unnecessary gas consumption due to persistent storage writes.

  • Possible confusion or unintended persistence if reused across functions.

Proof of Concept

Deploy the contract and observe the gas cost difference in two versions of the same function:

address faucetClaimer; // declared globally (storage)

vs

function claimFaucetTokens() external {
address faucetClaimer = msg.sender; // local variable
}

The first will incur SSTORE costs (~20,000 gas), while the second is free beyond stack usage.

Recommended Mitigation

- address public faucetClaimer;
+ // Remove unnecessary state variable. Use local memory variable instead ==> address faucetClaimer;
Updates

Lead Judging Commences

inallhonesty Lead Judge 3 days ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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