ERC-165 Facet
Interface detection for diamonds via ERC-165
- Implements ERC-165 interface detection via
supportsInterface. - Exposes
exportSelectorsfor facet selector discovery. - Operates using diamond storage and routing patterns.
Overview
This facet implements ERC-165 interface detection for diamonds. It exposes the supportsInterface function, allowing external contracts to query diamond capabilities. Calls are routed through the diamond proxy, leveraging shared storage for interface support information.
Storage
ERC165Storage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("erc165")) |
Functions
supportsInterface
Query if a contract implements an interface This function checks if the diamond supports the given interface ID
Parameters:
| Property | Type | Description |
|---|---|---|
_interfaceId | bytes4 | The interface identifier, as specified in ERC-165 |
Returns:
| Property | Type | Description |
|---|---|---|
- | bool | true if the contract implements _interfaceId and _interfaceId is not 0xffffffff, false otherwise |
exportSelectors
Exports the function selectors of the ERC165Facet This function is use as a selector discovery mechanism for diamonds
Returns:
| Property | Type | Description |
|---|---|---|
- | bytes | selectors The exported function selectors of the ERC165Facet |
Best Practices
- Ensure the
ERC165Facetis added to the diamond, and its selectors are correctly registered. - Call
supportsInterfacethrough the diamond proxy address to query the diamond's capabilities. - Use
exportSelectorsduring facet deployment to list the selectors provided by this facet.
Security Considerations
The supportsInterface function is view and has no state-changing implications. The exportSelectors function is pure. No reentrancy risks are present in these functions.