0

I want to see if a contract supports an interface that is a superset of a current interface. In specific, I want make sure that any arbitray contract supports "SafeTransferFrom(address,address,uint)". What's the best way to check for this?

1 Answer 1

1

There is an ERC165 standard, which implements supportsInterface function. If contract implements ERC165 standard, it should return true for any supported interface that the contract implements. But it's still applicable only to whole interfaces, not individual functions. You can read more about the EIP-165 here: https://eips.ethereum.org/EIPS/eip-165

If the contract doesn't implement ERC165, there is no 100% way to determine that the contract implements some function. If a function has a return value, you can try to static call it and if returns nothing, the contract is probably not implementing it.

2
  • So if an interface is defined, it will only return true for an exact match? Or as long as another interface implements all of the features of the child interface, it's true?
    – antioi
    Commented Oct 12, 2021 at 17:33
  • I don't know what you mean by child interface, but in general I would say yes. It doesn't matter what is the interface name. Important are methods, their selectors in particular (basically hash of their signatures, eg bytes4(keccak256('myMethod(uint256,address)'))). This is how you define interface identifier (from EIP-165): We define the interface identifier as the XOR of all function selectors in the interface..
    – ashhanai
    Commented Oct 12, 2021 at 18:04

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.