Sub-Adapters 1
Preview and test each sub adapter.
ENS (ens)
Metadata
- ID
- ens
- name
"ENS"
- icon
- protocolLaunch
"2020-08-07"
- category
"other"
- description
"ENS is a naming protocol for wallets, websites and more."
- feeDescription
"Registration fees are paid to the DAO treasury."
- blockchain
"Ethereum"
- source
"The Graph Protocol"
- website
"https://ens.domains"
- events
[ { "date": "2021-11-09", "description": "ENS DAO & token launched" } ]
Queries
Adapter Code
Check the entire code written for the Adapter.
Source code
Showing TS source.
1export const name = 'Ethereum Name Service';
2export const version = '0.1.3';
3export const license = 'MIT';
4
5export function setup(sdk: Context) {
6 const getFees = async (startDate: string, endDate: string): Promise<number> => {
7 const startOfDayBlock = await sdk.chainData.getBlockNumber(startDate);
8 const endOfDayBlock = await sdk.chainData.getBlockNumber(endDate);
9
10 const data = await sdk.graph.query(
11 'dmihal/ens-fees',
12 `query txFees($startOfDay: Int!, $endOfDay: Int!){
13 startOfDay: ens(id: "ens", block: {number: $startOfDay}) {
14 usdCollected
15 }
16 endOfDay: ens(id: "ens", block: {number: $endOfDay}) {
17 usdCollected
18 }
19 }`,
20 {
21 variables: {
22 startOfDay: startOfDayBlock,
23 endOfDay: endOfDayBlock,
24 },
25 },
26 );
27
28 const fees = parseFloat(data.endOfDay.usdCollected) - parseFloat(data.startOfDay.usdCollected);
29
30 return fees;
31 }
32
33 const getOneDayFees = (date: string) => {
34 const nextDay = sdk.date.offsetDaysFormatted(date, 1);
35 return getFees(date, nextDay);
36 }
37
38 sdk.register({
39 id: 'ens',
40 queries: {
41 oneDayTotalFees: getOneDayFees,
42 oneDayProtocolFees: getOneDayFees,
43 dateRangeTotalFees: getFees,
44 dateRangeProtocolFees: getFees,
45
46 },
47 metadata: {
48 name: 'ENS',
49 icon: sdk.ipfs.getDataURILoader('QmcVVHX9MmeJkATvuhNBhVUL4sXqNuU5eT6m6W47E2yxnN', 'image/svg+xml'),
50 protocolLaunch: '2020-08-07', // Don't currently have data before this
51 category: 'other',
52 description: 'ENS is a naming protocol for wallets, websites and more.',
53 feeDescription: 'Registration fees are paid to the DAO treasury.',
54 blockchain: 'Ethereum',
55 source: 'The Graph Protocol',
56 website: 'https://ens.domains',
57 events: [
58 {
59 date: '2021-11-09',
60 description: 'ENS DAO & token launched',
61 },
62 ],
63 },
64 })
65}
66
It's something off?
Report it to the discussion board on Discord, we will take care of it.