Chainlink Developers

Welcome to the Chainlink documentation site. You'll find comprehensive guides and documentation to help you start working with Chainlink as quickly as possible, as well as support if you get stuck. Click here for an introductory walkthrough on how to create a Chainlink request on the Ropsten test network!

Building on Chainlink? Click here to get started!

Get Started

ENS

Ethereum Name Service

Chainlink is moving to the Ethereum Name Service (ENS) as the source of truth for Price Feed addresses. ENS is a distributed, open, and extensible naming system based on the Ethereum blockchain, which eliminates the need to copy or type long addresses. Instead, addresses can be obtained in deployed contracts or, alternatively, using off-chain scripts that read the state of the blockchain.

Naming Structure

Chainlink price 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

🚧

Reverse Lookup

Reverse lookup is not supported.

Javascript

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

This example logs the address of the ETH / USD price feed on the Ethereum mainnet.

const Web3 = require("web3");

const web3 = new Web3("https://mainnet.infura.io/v3/<api_key>");
web3.eth.ens.getAddress('eth-usd.data.eth')
  .then((address) => {
    console.log(address)
  })

Solidity

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

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 currently be retrieved from this subgraph.

"ETH / USD" hash: 0xf599f4cd075a34b92169cf57271da65a7a936c35e3f31e854447fbb3e7eb736d

pragma solidity ^0.6.0;

// ENS Registry Contract
interface ENS {
    function resolver(bytes32 node) external view returns (Resolver);
}

// Chainlink Resolver
interface Resolver {
    function addr(bytes32 node) external view returns (address);
}

// Consumer contract
contract ENSConsumer {
    ENS ens;

    // ENS registry address: 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e
    constructor(address ensAddress) public {
        ens = ENS(ensAddress);
    }
    
    // Use ID Hash instead of readable name
    // ETH / USD hash: 0xf599f4cd075a34b92169cf57271da65a7a936c35e3f31e854447fbb3e7eb736d
    function resolve(bytes32 node) public view returns(address) {
        Resolver resolver = ens.resolver(node);
        return resolver.addr(node);
    }
}

Updated 2 days ago


ENS


Ethereum Name Service

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.