Skip to main content
ERC-165 standard interface detection for smart contracts.
Implements ERC-165 interface detection mechanism.

Overview

ERC-165 enables contracts to declare which interfaces they support. Interface IDs are computed by XORing function selectors, creating a unique 4-byte identifier for each interface.

getInterfaceId

getInterfaceId(selectors: SelectorLike[]): InterfaceIdType

Calculates ERC-165 interface ID by XORing function selectors. Parameters:
  • selectors: SelectorLike[] - Array of function selectors (4 bytes each)
Returns: InterfaceIdType - 4-byte interface ID Example:

Standard Interface IDs

ERC165_INTERFACE_ID

Interface ID for supportsInterface(bytes4) function itself.

ERC20_INTERFACE_ID

Interface ID for ERC-20 token standard. Functions:
  • balanceOf(address)
  • transfer(address,uint256)
  • approve(address,uint256)
  • transferFrom(address,address,uint256)
  • allowance(address,address)
  • totalSupply()

ERC721_INTERFACE_ID

Interface ID for ERC-721 NFT standard.

ERC1155_INTERFACE_ID

Interface ID for ERC-1155 multi-token standard.

Usage Patterns

Check Interface Support

Custom Interface

Specification

Defined in: src/primitives/Abi/interface/ See also: