|
| 1 | +--- |
| 2 | +eip: 7996 |
| 3 | +title: Contract Feature Detection |
| 4 | +description: Method to publish and detect contract features that lack an ERC-165 interface |
| 5 | +author: raffy.eth (@adraffy) |
| 6 | +discussions-to: https://ethereum-magicians.org/t/erc-7996-contract-feature-detection/24975 |
| 7 | +status: Draft |
| 8 | +type: Standards Track |
| 9 | +category: ERC |
| 10 | +created: 2025-07-07 |
| 11 | +requires: 165 |
| 12 | +--- |
| 13 | + |
| 14 | +## Abstract |
| 15 | + |
| 16 | +Creates a standard method `supportsFeature(bytes4)` in the same spirit as `supportsInterface(bytes4)` to publish and detect what features a smart contract implements that lack a derivable [ERC-165](./eip-165.md) interface. |
| 17 | + |
| 18 | +## Motivation |
| 19 | + |
| 20 | +Ethereum Name Service (ENS) has maintained backwards compatibility with contracts created in 2016 through extensive use of ERC-165. Unfortunately, not all contract capabilities can be expressed through an unique interface. |
| 21 | + |
| 22 | +Features allow expression of contract capabilities that preserve existing interfaces. This proposal standardizes the concept of features and standardizes the identification (naming) of features. |
| 23 | + |
| 24 | +Defining a new standard avoids unnecessary pollution of the ERC-165 selector namespace with synthetic interfaces representing features. |
| 25 | + |
| 26 | +## Specification |
| 27 | + |
| 28 | +The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC 2119](https://www.rfc-editor.org/rfc/rfc2119) and [RFC 8174](https://www.rfc-editor.org/rfc/rfc8174). |
| 29 | + |
| 30 | +### How Features are Identified |
| 31 | + |
| 32 | +For this standard, a *feature* is any property of a contract that cannot be expressed via ERC-165. |
| 33 | + |
| 34 | +A feature name SHOULD be a reverse domain name that uniquely defines its implication, eg. `eth.ens.resolver.extended.multicall` is the multicall feature for an extended ENS resolver contract. |
| 35 | + |
| 36 | +A feature identifier is defined as the first four-bytes of the keccak256-hash of its name, eg. `bytes4(keccak256("eth.ens.resolver.extended.multicall")) = 0x96b62db8`. |
| 37 | + |
| 38 | +### How a Contract will Publish the Features it Implements |
| 39 | + |
| 40 | +A contract that is compliant with this specification SHALL implement the following interface: |
| 41 | + |
| 42 | +```solidity |
| 43 | +interface IERC7996 { |
| 44 | + /// @notice Check if a feature is supported. |
| 45 | + /// @param featureId The feature identifier. |
| 46 | + /// @return `true` if the feature is supported by the contract. |
| 47 | + function supportsFeature(bytes4 featureId) external view returns (bool); |
| 48 | +} |
| 49 | +``` |
| 50 | + |
| 51 | +The ERC-165 interface identifier for this interface is `0x582de3e7`. |
| 52 | + |
| 53 | +### How to Detect if a Contract Implements Features |
| 54 | + |
| 55 | +1. Check if the contract supports the interface above according to [ERC-165](./eip-165.md#how-to-detect-if-a-contract-implements-erc-165). |
| 56 | + |
| 57 | +### How to Detect if a Contract Implements any Given Feature |
| 58 | + |
| 59 | +1. If you are not sure if the contract implements features, use the above procedure to confirm. |
| 60 | +1. If it implements features, then call `supportsFeature(featureId)` to determine if it implements the desired feature. |
| 61 | + |
| 62 | +Note: a contract that implements features MAY implement no features. |
| 63 | + |
| 64 | +## Rationale |
| 65 | + |
| 66 | +Since feature names cannot be derived from a contract interface, they are derived from a reverse domain name to reduce collisions and permit a human-readable representention that briefly describes its implication. |
| 67 | + |
| 68 | +## Backwards Compatibility |
| 69 | + |
| 70 | +Callers unaware of features or any specific feature experience no change in behavior. |
| 71 | + |
| 72 | +ENS already implements this ERC. |
| 73 | + |
| 74 | +## Security Considerations |
| 75 | + |
| 76 | +As with ERC-165, declaring support for a feature does not guarantee that the contract implements it. |
| 77 | + |
| 78 | +## Copyright |
| 79 | + |
| 80 | +Copyright and related rights waived via [CC0](../LICENSE.md). |
0 commit comments