Pieces Protocol

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

Return value of `TokenDivider::onERC721Received` should be `IERC721Receiver.onERC721Received.selector`

Description:
The ERC721 standard specifies that when an NFT is transferred to a smart contract via the safeTransfer function, the receiver contract should implement the onERC721Received function, which will have to return its own selector. For this reason, the return value should be the exact selector of the function defined in the standard. TokenDivider::onERC721Received returns this.onERC721Received.selector, which refers to the implementation of the function, and not to the original function defined in IERC721Receiver.

Impact:
Since the TokenDivider contract inherits from IERC721Receiver, the implementation for the function TokenDivider::onERC721Received is equal to the function defined in the standard. To avoid potential compability issues, it is recommended to follow the best practices and return the exact value expected by the safeTransfer function, hence IERC721Receiver.onERC721Received.selector.

Tools Used:
Manual review

Recommended Mitigation:
It is recommended to return the exact selector for onERC721Received function defined in IERC721Receiver.

function onERC721Received(
address /* operator */,
address /* from */,
uint256 /* tokenId */,
bytes calldata /* data */
) external pure override returns (bytes4) {
// Return this value to confirm the receipt of the NFT
- return this.onERC721Received.selector;
+ return IERC721Receiver.onERC721Received.selector;
}
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.