ERC165Facet
Supports ERC-165 interface detection for diamonds
Key Features
- Exposes
supportsInterfacefor ERC-165 compliance. - Utilizes a fixed storage slot for ERC-165 state.
- No external dependencies beyond standard Solidity.
Overview
This facet implements ERC-165 interface detection for diamonds. It exposes the supportsInterface function, allowing external contracts to query if the diamond supports specific interface IDs. This facet utilizes a fixed storage slot for its state, adhering to the diamond storage pattern.
Storage
ERC165Storage
State Variables
| Property | Type | Description |
|---|---|---|
STORAGE_POSITION | bytes32 | Diamond storage slot position for this module (Value: keccak256("compose.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 |
Best Practices
Best Practice
- Ensure the
ERC165Facetis added to your diamond during initialization. - Call
supportsInterfacethrough the diamond proxy to query interface support. - Verify storage compatibility if upgrading facets that interact with ERC-165 state.
Security Considerations
Security
The supportsInterface function is view-only and does not modify state. Input validation for _interfaceId is handled by standard Solidity bytes4 comparisons. Follow standard Solidity security practices.
Was this helpful?
Last updated: