0

How to detect whether a contract can handle ERC20 or not. I have a scenario where I have to send royalties to contracts but how can I know if that contract can handle ERC20 tokens? There is an ERC721Receiver interface for the ERC721 standard that I can implement and that other contracts can use to check if the contract can handle ERC721 or not but I didn't find a such thing for ERC20.

By “handle” I mean that the contract can withdraw tokens and tokens are not locked in it.

0

1 Answer 1

1

It's unclear what you mean by "handle", but assuming you mean "react to an ERC-20 transfer", this is not possible.

The ERC-20 standard did not specify callbacks (a.k.a. hooks), unlike other token standards such as ERC-777.

4
  • Hey! Thank you for your reply. Basically, I mean that I'd like to be sure that receiving contract can withdraw tokens by sending them to another account and that tokens are not locked in the contract.
    – AGJoYy
    Commented Nov 28, 2022 at 14:52
  • So basically, the external contract has to have a function like "transfer" or "withdraw" where it calls the token's contract function "transfer"
    – AGJoYy
    Commented Nov 28, 2022 at 14:54
  • This is not possible. There's an infinite amount of ways in which a withdraw functionality can be implemented in a Turing-complete system like Ethereum. Commented Nov 28, 2022 at 14:57
  • What you may actually want is a way to recover the ERC-20 tokens if they end up in the wrong contract? take a look at my ERC20Recover contract. Commented Nov 28, 2022 at 14:57

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.