ERC-1844 ENS interface discovery

Stagnant · Names & metadata · created 2019-03-15

A standard that lets you look up which functionality (interface) is associated with an ENS name or address. It helps locate functionality provided by another contract when a token contract does not implement it directly.

Why it is needed

EIP-165 only answers whether a contract at a given address supports a particular interface. However, there was no standard way to discover related functionality implemented elsewhere rather than in the contract itself. For example, a token contract might not implement atomic swap functionality directly, yet another contract could provide it. Embedding such links directly in each contract would require every contract to maintain its own interface list, require new access control to manage edits to that list, and require planning for such support at design time, meaning it could not be added later to an already deployed contract and could only support a single canonical list. As a result, there was no standard way to tell an already deployed contract where to find a new piece of functionality.

What to implement

In depth

Define the ENS resolver profile

This ERC defines a single new profile for ENS resolvers: the function interfaceImplementer(bytes32 node, bytes4 interfaceID) external view returns (address). The EIP-165 interface ID for this interface itself is 0xb8f2bbb4.

Return value rules

If there is no corresponding interface for a given node and interfaceID, the function returns 0. The address returned by interfaceImplementer MUST point to a smart contract, and that contract SHOULD implement EIP-165.

Fallback strategy

Resolvers MAY optionally use a fallback strategy. If there is no explicit interface mapping specified by the user, they look up the contract returned by addr(); if that contract supports the requested interface, they return its address, and otherwise return 0. If this fallback is implemented, the resolver MUST return 0 rather than reverting even if the target contract reverts.

Applies to both forward and reverse resolution

This field can be used for both forward resolution, which finds an address from a name, and reverse resolution, which finds a name from an address.

Comparison with embedding this in the contract itself

Adding this functionality directly to the target contract has four drawbacks: each contract must maintain its own interface list, which requires access control for modifying that list where none previously existed; support must be planned for at contract design time and cannot be added later; and only a single canonical list can be supported. Using an ENS resolver removes these constraints and lets anyone attach interfaces to an arbitrary name.

Implementation example

PublicResolver in the ensdomains/resolvers repository implements this interface.

Proposal status

This proposal is in Stagnant status, meaning it is no longer actively discussed or progressing. It may or may not change or be adopted going forward.

Original ERC · ← ERCs