-
Notifications
You must be signed in to change notification settings - Fork 829
Add ERC: Contract Feature Detection #1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+80
−0
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
879f6a5
move to ercs
adraffy 652accb
make abcoathup modifications, rename file
adraffy 75e240e
satisfy walidator?
adraffy 6910232
minor: interfaces -> features, eip -> erc
adraffy afb9d62
Apply suggestions from code review
adraffy f6ba2e9
Update erc-7996.md
SamWilsn ae79671
changes for SamWilsn
adraffy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
| title: Contract Feature Detection | ||
| description: Standard method to publish and detect contract features that lack an ERC-165 interface | ||
| author: raffy.eth (@adraffy) | ||
| discussions-to: https://ethereum-magicians.org/t/eip-discussion-contract-feature-detection/24975 | ||
adraffy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| status: Draft | ||
| type: Informational | ||
adraffy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| created: 2025-07-07 | ||
| requires: 165 | ||
| --- | ||
|
|
||
| ## Abstract | ||
|
|
||
| Creates a standard method to publish and detect what features a smart contract implements that lack an [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface. | ||
|
|
||
| ## Motivation | ||
|
|
||
| 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. | ||
|
|
||
| Features allow expression of contract capabilities that preserve existing interfaces. This proposal standardizes the concept of features and standardizes the identification (naming) of features. | ||
|
|
||
| ## Specification | ||
|
|
||
| ### How Interfaces are Identified | ||
|
|
||
| For this standard, a *feature* is any property of a contract that cannot be expressed via ERC-165. | ||
|
|
||
| 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. | ||
|
|
||
| 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`. | ||
|
|
||
| ### How a Contract will Publish the Interfaces it Implements | ||
|
|
||
| A contract that is compliant with this specification shall implement the following interface: | ||
|
|
||
| ```solidity | ||
| interface IFeatureSupporter { | ||
| /// @notice Check if a feature is supported. | ||
| /// @param featureId The feature identifier. | ||
| /// @return `true` if the feature is supported by the contract. | ||
| function supportsFeature(bytes4 featureId) external view returns (bool); | ||
| } | ||
| ``` | ||
|
|
||
| The ERC-165 interface identifier for this interface is `0x582de3e7`. | ||
|
|
||
| ### How to Detect if a Contract Implements Features | ||
|
|
||
| 1. Check if the contract supports the interface above according to [ERC-165](https://eips.ethereum.org/EIPS/eip-165#how-to-detect-if-a-contract-implements-erc-165). | ||
|
|
||
| ### How to Detect if a Contract Implements any Given Feature | ||
|
|
||
| 1. If you are not sure if the contract implements features, use the above procedure to confirm. | ||
| 1. If it implements features, then call `supportsFeature(feature)` to determine if it implements the desired feature. | ||
|
|
||
| Note: a contract that implements features may implement no features. | ||
|
|
||
| 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). | ||
|
|
||
| ## Rationale | ||
|
|
||
| Defining a new standard avoids unnecessary pollution of the ERC-165 selector namespace with synthetic interfaces representing features. | ||
|
|
||
| ## Backwards Compatibility | ||
|
|
||
| Callers unaware of features or any specific feature experience no change in behavior. | ||
|
|
||
| ENS already implements this EIP. | ||
|
|
||
| ## Security Considerations | ||
|
|
||
| As with ERC-165, declaring support for a feature does not guarantee that the contract implements it. | ||
|
|
||
| ## Copyright | ||
|
|
||
| Copyright and related rights waived via [CC0](../LICENSE.md). | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.