0

I hope you are all well :)

I have a question about the _checkOnERC721Received function of the ERC721 smart contract of Openzeppelin.

I don't understand this part:

try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
               return retval == IERC721Receiver.onERC721Received.selector;

What must be implemented in the onERC721Received function?

Thank you for your help

Take care

Pierre

1 Answer 1

0

This is specified in https://eips.ethereum.org/EIPS/eip-721#specification

A wallet/broker/auction application MUST implement the wallet interface if it will accept safe transfers.

It can simply implement this function and not do anything. The signature is

function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes _data) external returns(bytes4);

This allows the NFT token contract to ensure that it is sending to a contract that is expecting to receive tokens (i.e. avoiding "stuck" tokens").

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.