The transferErcTokens
function in the TokenDivider contract performs redundant zero address validation, checking the same condition twice. This leads to unnecessary gas consumption and reduces code maintainability.
Severity: Low
In the transferErcTokens
function, there are two identical checks for the zero address:
The second check is completely redundant as:
If to
is the zero address, the function will revert at the first check
The value of to
cannot change between the two checks
The second check can never be reached if to
is the zero address
The redundant check results in:
Increased gas consumption (~1256 gas per transaction as demonstrated in tests)
Reduced code maintainability
Potential confusion for developers reviewing or maintaining the code
While this is not a critical security vulnerability, it represents an unnecessary inefficiency in the contract.
Manual code review
Foundry testing framework
Custom test suite (DoubleCheckTest.t.sol)
Gas measurement using Foundry's gas tracking
Remove the second zero address check, keeping only the first validation. The function should be refactored to:
This change will:
Reduce gas costs
Improve code readability
Maintain the same security guarantees
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.