Inside claimFaucetTokens(), the contract stores msg.sender into the state variable faucetClaimer, which is then used throughout the function. This assignment is unnecessary because the function can simply reference msg.sender directly or assign it to a local memory variable.
Each call performs an SSTORE operation (either 5,000 or 20,000 gas), wasting gas on every faucet claim without any functional need.
Likelihood: High
| Factor | Observation | Likelihood Influence |
|---|---|---|
| Frequency | Happens on every faucet claim | High |
| Severity | Minor, but consistently costly | Medium |
| Access | Publicly callable | High |
| Complexity | Simple and deterministic | High |
Impact: Low
| Impact Area | Description |
|---|---|
| Gas Cost | Adds unnecessary 5,000–20,000 gas per claim call. |
| Performance | Reduces overall throughput and faucet efficiency. |
| Maintainability | Misleads developers into thinking faucetClaimer has persistent meaning beyond function scope. |
| Code Quality | Reflects misunderstanding of local vs. storage variables. |
Compare gas usage between the current and optimized versions:
After replacing faucetClaimer = msg.sender; with a local variable, gas usage will drop.
Gas used: 242380
(current implementation)
Gas used: 218876
(replacing with local variable)
Gas used: 218855 (using direclty the msg.sender)
Replacing faucetClaimer = msg.sender; with a local variable or directly using msg.sender all over in the function scope.
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.