Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Duplicate zero address check in `transferErcTokens` wastes gas

Summary:

The transferErcTokens function contains an unnecessary duplicate zero address check, wasting gas.

Vulnerability Details:

The transferErcTokens function checks if the to address is equal to the zero address twice, which is unnecessary and results in wasted gas.

Impact:

Repeatedly checking the same condition in the function consumes more gas than necessary, increasing the cost for users and reducing the overall efficiency of the contract.

Tools Used:

Solidity, Foundry.

Recommendations:

Remove the duplicate zero address check in the transferErcTokens function to save gas and improve efficiency.

Example:

function transferErcTokens(address nftAddress, address to, uint256 amount) external {
// First check
if (to == address(0)) {
revert TokenDivider__CantTransferToAddressZero();
}
// ... other checks ...
// Remove duplicate check
// if(to == address(0)) {
// revert TokenDivider__CantTransferToAddressZero();
// }
// ... rest of function
}
Updates

Lead Judging Commences

fishy Lead Judge 5 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.