2

I am struggling to understand this below implementation of the ERC-165 standard by OpenZeppelin. This is by default imported in the ERC721 token smart contract of OZ. I do get the aim of the ERC-165 standard but not this code snippet. And what does "type(IERC721)" function is actually doing ? Thanks a lot in advance for your help.

 function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC721).interfaceId
            || interfaceId == type(IERC721Metadata).interfaceId
            || super.supportsInterface(interfaceId);

1 Answer 1

2

The expression type(A) is used to retrieve information about A. In this case

type(I).interfaceId

A bytes4 value containing the EIP-165 interface identifier of the given interface I. This identifier is defined as the XOR of all function selectors defined within the interface itself - excluding all inherited functions.

For other properties available see the type() documentation.

1
  • Thanks a lot. Indeed, I missed this one in the documentation. May 11, 2021 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.