Pieces Protocol

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

Inconsistent Use of Modifiers and Checks

Summary

The `onlyNftOwner` modifier is redundant in the divideNft function where it was applied twice.
Same as the check for `address(0)` in the `transferErcTokens` function
```solidity
if (to == address(0)) {
revert TokenDivider__CantTransferToAddressZero();
}`
```

Vulnerability Details

Impact

1. Code Clarity: Removing or using unused code improves readability and maintainability of the contract.
2. Gas Optimization: While the impact on gas might be minimal for a single unused error, maintaining a clean codebase can help in reducing the overall bytecode size, potentially saving gas costs in deployment or interactions.
3. Future Proofing: Keeping the code free from unused elements helps in understanding the contract's behavior more clearly, which is crucial for audits, upgrades, or when new developers join the project.

Tools Used

Manual Review

Recommendations

Remove the duplicate modifier and the dupilicate check to reduce gas costs and improve readability.
Code Snippet:
```solidity
function divideNft(address nftAddress, uint256 tokenId, uint256 amount) onlyNftOwner(nftAddress, tokenId) external {
// Remove the second `onlyNftOwner` here
//Remove the second
if (to == address(0)) {
revert TokenDivider__CantTransferToAddressZero();
}
```
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.