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?
Asked
Active
Viewed 317 times
1 Answers
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.
ashhanai
- 516
- 2
- 7
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 Oct 12 '21 at 18:04