ERC-165
Standard Interface Detection
Last updated
Standard Interface Detection
Last updated
ERC165 is a standard to detect and publish what interfaces a smart contract implements.
Creates a standard method to publish and detect what interfaces a smart contract implements.
This helps prevent tokens from getting stuck, when they are sent to contracts which do not support that token
Like sending ERC20 to contracts that does not support ERC20, so they get stuck.
We need to know if the necessary methods exist on the target function
Keccak256 and XOR
Keccak256(method_1) ^ Keccak256(method_2) ^ Keccak256(method_3)
we will hash all the methods of an interface and XOR them -> with XOR the order will not matter
you can think of this hexadecimal as the bytes4 fingerprint of an interface or group of methods.
interfaceid: type(IERC721).interfaceId
Inherit ERC165.sol
override the supportsInterface
function accordingly
In ERC165:
In ERC721:
we override the inherited function on ERC165 and IERC165
the child implementation checks for support on ERC712, ERC712Metadata, and ERC165 (super.supportsInterface
)