3

When trying to find out if a contract implemented onERC721Received from safeTransferFrom function, are we just safely assuming the contract has all the erc721 related functionalities? such as transfer, etc?

because it is simply just returning an interface identifier 0x150b7a02, not returning whether it can perform transfer tokens or not.

1 Answer 1

6

The interface identifier 0x150b7a02 is for the ERC721TokenReceiver interface. That is, contracts that implement onERC721Received, and just implies that the contract was designed to receive ERC-721 tokens.

This doesn't in any way guarantee that this receiver contract was written to execute any/all of the functions on your ERC-721 Token contract.

4
  • so it just implicitly agrees that it implemented some of the erc721 functionalities.. okay, so security-wise, it would be better to check the contract from etherscan before I send the token to the contract?
    – bbusdriver
    Jul 22, 2019 at 21:30
  • 1
    If the interface check is returning true for 0x150b7a02, then it means the developer who wrote that contract is signalling that they want their contract to receive ERC-721 tokens. I'm not sure what specifically you're concerned about security wise though. The receiver can't pose any risk to your ERC721 token contract, assuming the latter was written correctly. Probably worst case scenario is that the receiver wasn't made right and any tokens that get sent to it get stuck there. Jul 22, 2019 at 22:06
  • yeah i'm talking about your worst case scenario. From my point of view, I can't trust the third-party contract 100% just because it returns 0x150b7a02 though. If the receiver is legit, and everyone trust it then it would be fine. However if a receiver contract has newly been created and no one used it before, how can one trust it only because it returns true for 0x150b7a02?
    – bbusdriver
    Jul 22, 2019 at 22:23
  • Well that's really only a problem for the person who owns the Receiver contract, and therefore the tokens that get sent to it. Tokens can get stuck anyway, like if a person loses their private key. This sort of problem is outside the scope of the ERC-721 standard. Jul 22, 2019 at 23:23

Your Answer

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

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