Using ENS with Data Feeds

Lookup

Manual Lookup

/

Naming structure

Chainlink data feeds fall under the data.eth naming suffix. To obtain a specific feed address, prefix this with the assets in the feed, separated by a dash (-).

PairENS Domain Name
ETH / USDeth-usd.data.eth
BTC / USDbtc-usd.data.eth
......

Subdomains

By default, the base name structure (eth-usd.data.eth) returns the proxy address for that feed. However, subdomains enable callers to retrieve other associated contract addresses, as shown in the following table.

Contract AddressesSubdomain PrefixExample
Proxyproxyproxy.eth-usd.data.eth
Underlying aggregatoraggregatoraggregator.eth-usd.data.eth
Proposed aggregatorproposedproposed.eth-usd.data.eth

Architecture

Resolver

For each network, there is a single Chainlink resolver, which does not change. Its address can be obtained using the data.eth domain. This resolver manages the subdomains associated with data.eth.

NetworkResolver Address
Ethereum Mainnet0x122eb74f9d0F1a5ed587F43D120C1c2BbDb9360B

Listening for address changes

When a new aggregator is deployed for a specific feed, it is first proposed, and when accepted becomes the aggregator for that feed. During this process, the proposed and aggregator subdomains for that feed will change. With each change, the resolver emits an AddrChanged event, using the feed subdomain (for example: eth-usd.data.eth) as the indexed parameter.

Example: If you want to listen for when the aggregator of the ETH / USD feed changes, set up a listener to track the AddrChanged event on the resolver, using a filter like this: ethers.utils.namehash('aggregator.eth-usd.data.eth').

Obtaining addresses

Javascript

The example below uses Javascript Web3 library to interact with ENS. See the ENS documentation for the full list of languages and libraries that support ENS.

This example logs the address of the data feed on the Ethereum mainnet for ETH / USD prices.

undefined

Solidity

In Solidity, the address of the ENS registry must be known. According to ENS documentation, this address is the same across Mainnet and testnet:

ENS registry address: 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e.

Also, instead of using readable string names like eth-usd.data.eth, resolvers accept bytes32 hash IDs for names. Hash IDs can be retrieved from this subgraph or via this npm package eth-ens-namehash.

"ETH / USD" hash: 0xf599f4cd075a34b92169cf57271da65a7a936c35e3f31e854447fbb3e7eb736d

undefined

Get the latest Chainlink content straight to your inbox.