In my transfer function, I want to only allow the
to address to be a contract that implements a certain interface.
I used this to check:
require(IERC165(to).supportsInterface(0xabcdef), "Wrong interface");
This works correctly if
to is a contract address that implements ERC165. But when
to is an EOA or a contract that doesn't implements ERC165, the statement will revert without any revert message. It seems like
supportsInterface might have been "undefined" and hence the error. I might not have done the check safely and correctly since
to really can be any address.
How should I do a check for the interface in a safe and more graceful way?