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