forked from smartcontractkit/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathens.html
More file actions
235 lines (205 loc) · 11.6 KB
/
ens.html
File metadata and controls
235 lines (205 loc) · 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
---
layout: nodes.liquid
section: ethereum
date: Last Modified
title: "Using ENS with Data Feeds"
permalink: "docs/data-feeds/ens/"
excerpt: "Ethereum Name Service"
metadata:
description: "How Chainlink uses the Ethereum Name Service for Data Feed contract addresses."
image:
0: "/files/7c891b4-link.png"
---
<script src="https://cdnjs.cloudflare.com/ajax/libs/web3/1.3.0/web3.min.js" integrity="sha512-ppuvbiAokEJLjOUQ24YmpP7tTaLRgzliuldPRZ01ul6MhRC+B8LzcVkXmUsDee7ne9chUfApa9/pWrIZ3rwTFQ==" crossorigin="anonymous"></script>
<script src="/ens.js"></script>
Chainlink is moving to the <a href="https://docs.ens.domains/" target="_blank">Ethereum Name Service (ENS)</a> as the source of truth for Data 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.
<div>
<div>
<h3>Lookup</h3>
<div class="col-xs-12 col-md-4">
<b>Pair:</b><br>
<select class="cl-select" onchange="getDropdownAddress()" name="pairs" id="pairs">
<option value="">Choose Pair</option>
<option value="aave-eth.data.eth">AAVE / ETH</option>
<option value="aave-usd.data.eth">AAVE / USD</option>
<option value="ada-usd.data.eth">ADA / USD</option>
<option value="adx-usd.data.eth">ADX / USD</option>
<option value="ant-eth.data.eth">ANT / ETH</option>
<option value="aud-usd.data.eth">AUD / USD</option>
<option value="bal-eth.data.eth">BAL / ETH</option>
<option value="bat-eth.data.eth">BAT / ETH</option>
<option value="bch-usd.data.eth">BCH / USD</option>
<option value="bnb-usd.data.eth">BNB / USD</option>
<option value="bnt-eth-bancor.data.eth">BNT / ETH (Bancor)</option>
<option value="bnt-eth.data.eth">BNT / ETH</option>
<option value="bnt-usd.data.eth">BNT / USD</option>
<option value="brent-usd.data.eth">BRENT / USD</option>
<option value="btc-ars.data.eth">BTC / ARS</option>
<option value="btc-difficulty.data.eth">BTC Difficulty</option>
<option value="btc-eth.data.eth">BTC / ETH</option>
<option value="btc-usd.data.eth">BTC / USD</option>
<option value="busd-eth.data.eth">BUSD / ETH</option>
<option value="bzrx-eth.data.eth">BZRX / ETH</option>
<option value="chf-usd.data.eth">CHF / USD</option>
<option value="comp-eth.data.eth">COMP / ETH</option>
<option value="comp-usd.data.eth">COMP / USD</option>
<option value="cro-eth.data.eth">CRO / ETH</option>
<option value="crv-eth.data.eth">CRV / ETH</option>
<option value="dai-eth.data.eth">DAI / ETH</option>
<option value="dai-usd.data.eth">DAI / USD</option>
<option value="dash-usd.data.eth">DASH / USD</option>
<option value="dmg-eth.data.eth">DMG / ETH</option>
<option value="dot-usd.data.eth">DOT / USD</option>
<option value="enj-eth.data.eth">ENJ / ETH</option>
<option value="eos-usd.data.eth">EOS / USD</option>
<option value="etc-usd.data.eth">ETC / USD</option>
<option value="eth-usd.data.eth">ETH / USD</option>
<option value="eth-xdr.data.eth">ETH / XDR</option>
<option value="eur-mwh.data.eth">EUR / MWh</option>
<option value="eur-usd.data.eth">EUR / USD</option>
<option value="fast-gas-gwei.data.eth">Fast Gas / Gwei</option>
<option value="fil-usd.data.eth">FIL / USD</option>
<option value="fnx-usd.data.eth">FNX / USD</option>
<option value="ftm-eth.data.eth">FTM / ETH</option>
<option value="ftse-gbp.data.eth">FTSE / GBP</option>
<option value="gbp-usd.data.eth">GBP / USD</option>
<option value="jpy-usd.data.eth">JPY / USD</option>
<option value="knc-eth.data.eth">KNC / ETH</option>
<option value="knc-usd.data.eth">KNC / USD</option>
<option value="lend-eth.data.eth">LEND / ETH</option>
<option value="lend-usd.data.eth">LEND / USD</option>
<option value="link-eth-bancor.data.eth">LINK / ETH (Bancor)</option>
<option value="link-eth.data.eth">LINK / ETH</option>
<option value="link-usd.data.eth">LINK / USD</option>
<option value="lrc-eth.data.eth">LRC / ETH</option>
<option value="ltc-usd.data.eth">LTC / USD</option>
<option value="mana-eth.data.eth">MANA / ETH</option>
<option value="mkr-eth.data.eth">MKR / ETH</option>
<option value="mln-eth.data.eth">MLN / ETH</option>
<option value="n225-jpy.data.eth">N225 / JPY</option>
<option value="nmr-eth.data.eth">NMR / ETH</option>
<option value="orchid.data.eth">Orchid</option>
<option value="oxt-usd.data.eth">OXT / USD</option>
<option value="ren-eth-bancor.data.eth">REN / ETH (Bancor)</option>
<option value="ren-eth.data.eth">REN / ETH</option>
<option value="ren-usd.data.eth">REN / USD</option>
<option value="rep-eth.data.eth">REP / ETH</option>
<option value="rlc-eth.data.eth">RLC / ETH</option>
<option value="scex-usd.data.eth">sCEX / USD</option>
<option value="sdefi-usd.data.eth">sDEFI / USD</option>
<option value="snx-eth.data.eth">SNX / ETH</option>
<option value="snx-usd.data.eth">SNX / USD</option>
<option value="susd-eth.data.eth">SUSD / ETH</option>
<option value="sxp-usd.data.eth">SXP / USD</option>
<option value="total-marketcap-usd.data.eth">Total Marketcap / USD</option>
<option value="trx-usd.data.eth">TRX / USD</option>
<option value="tusd-eth.data.eth">TUSD / ETH</option>
<option value="tusd-reserves.data.eth">TUSD Reserves</option>
<option value="tusd-supply.data.eth">TUSD Supply</option>
<option value="uma-eth.data.eth">UMA / ETH</option>
<option value="uni-eth.data.eth">UNI / ETH</option>
<option value="uni-usd.data.eth">UNI / USD</option>
<option value="usdc-eth.data.eth">USDC / ETH</option>
<option value="usdk-usd.data.eth">USDK / USD</option>
<option value="usdt-eth.data.eth">USDT / ETH</option>
<option value="wnxm-eth.data.eth">WNXM / ETH</option>
<option value="wom-eth.data.eth">WOM / ETH</option>
<option value="wti-usd.data.eth">WTI / USD</option>
<option value="xag-usd.data.eth">XAG / USD</option>
<option value="xau-usd.data.eth">XAU / USD</option>
<option value="xhv-usd.data.eth">XHV / USD</option>
<option value="xmr-usd.data.eth">XMR / USD</option>
<option value="xrp-usd.data.eth">XRP / USD</option>
<option value="xtz-usd.data.eth">XTZ / USD</option>
<option value="yfi-eth.data.eth">YFI / ETH</option>
<option value="yfi-usd.data.eth">YFI / USD</option>
<option value="zrx-eth.data.eth">ZRX / ETH</option>
</select>
</div>
<div class="col-xs-12 col-md-4">
<b>ENS Name:</b><br>
<a id="address1-label-link" target="_blank">
<pre><code id="address1-label" class="language-none">-</code></pre>
</a>
</div>
<div class="col-xs-12 col-md-8">
<b>Address:</b><br>
<a id="address1-link" target="_blank">
<pre><code id="address1" class="language-none">-</code></pre>
</a>
</div>
<div class="col-xs-12 col-md-8">
<b>Hash ID:</b><br>
<a id="address1-hash-link" target="_blank">
<pre><code id="address1-hash" class="language-none">-</code></pre>
</a>
</div>
</div>
</div>
<hr>
<div>
<h3>Manual Lookup<h3>
<div class="col-xs-12 col-md-4">
<input id="asset-1" type="text" value="ETH" size="5"></input>
<span>/</span>
<input id="asset-2" type="text" value="USD" size="5"></input>
</div>
<div class="col-xs-12 col-md-8">
<a id="get-price-button" href="javascript:getManualAddress();" class="cl-button--ghost cl-button--ghost-sm">Lookup</a>
</div>
<div class="col-xs-12 col-md-4">
<b>ENS Name:</b><br>
<a id="address2-label-link" target="_blank">
<pre><code id="address2-label" class="language-none">-</code></pre>
</a>
</div>
<div class="col-xs-12 col-md-8">
<b>Address:</b><br>
<a id="address2-link" target="_blank">
<pre><code id="address2" class="language-none">-</code></pre>
</a>
</div>
</div>
{% markdown %}
# 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 (-).
|Pair|ENS Domain Name|
|:---|:---|
|ETH / USD|`eth-usd.data.eth`|
|BTC / USD|`btc-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 Addresses|Subdomain Prefix|Example|
|:-----------|:------------------|:---------|
|Proxy|`proxy`|`proxy.eth-usd.data.eth`|
|Underlying aggregator|`aggregator`|`aggregator.eth-usd.data.eth`|
|Proposed aggregator|`proposed`|`proposed.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`.
|Network|Resolver Address|
|:-----------|:------------------|
|Ethereum Mainnet|<a href="https://app.ens.domains/address/0x122eb74f9d0F1a5ed587F43D120C1c2BbDb9360B/" target="_blank">`0x122eb74f9d0F1a5ed587F43D120C1c2BbDb9360B`</a>|
## 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 <a href="https://docs.ens.domains/dapp-developer-guide/resolving-names" target="_blank">ENS documentation</a> for the full list of languages and libraries libraries that support ENS.
This example logs the address of the data feed on the Ethereum mainnet for ETH / USD prices.
```javascript
{% include 'samples/PriceFeeds/ENSConsumer.js' %}
```
## Solidity
In Solidity, the address of the ENS registry must be known. According to <a href="https://docs.ens.domains/ens-deployments" target="_blank">ENS documentation</a>, this address is the same across Mainnet and Goerli networks:
ENS registry address: <a href="https://etherscan.io/address/0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" target="_blank">`0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e`</a>.
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 <a href="https://thegraph.com/explorer/subgraph/ensdomains/ens" target="_blank">this subgraph</a> or via this npm package <a href="https://www.npmjs.com/package/@ensdomains/eth-ens-namehash" target="_blank">eth-ens-namehash</a>.
"ETH / USD" hash: `0xf599f4cd075a34b92169cf57271da65a7a936c35e3f31e854447fbb3e7eb736d`
```solidity
{% include 'samples/PriceFeeds/ENSConsumer.sol' %}
```
{% endmarkdown %}