Adapter

Graph Protocol

The Graph is an indexing protocol for querying networks like Ethereum and IPFS. Anyone can build and publish open APIs, called subgraphs, making data easily accessible.

Sub-Adapters 1

Preview and test each sub adapter.

Graph Protocol (Graph)

Metadata

ID
Graph
name

"Graph Protocol"

icon
protocolLaunch

"2020-12-17"

category

"Network Protocol"

subcategory

"Indexing"

description

"The Graph is an indexing protocol for querying networks like Ethereum and IPFS. Anyone can build and publish open APIs, called subgraphs, making data easily accessible."

feeDescription

"Query fees are partially burnt and remainder are paid to indexers, delegators, and curators."

blockchain

"Ethereum"

source

"The Graph Protocol"

website

"https://thegraph.com/en/"

tokenTicker

"GRT"

tokenCoingecko

"the-graph"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'Graph Protocol';
2export const version = '0.0.2';
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      'hepnerthomas/graph-protocol-revenues',
12      `query txFees($startOfDay: Int!, $endOfDay: Int!){
13        startOfDay: graph(id: "graph", block: {number: $startOfDay}) {
14          usdCollected
15        }
16        endOfDay: graph(id: "graph", 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: 'Graph',
40    queries: {
41      oneDayTotalFees: getOneDayFees,
42      dateRangeTotalFees: getFees,
43    },
44    metadata: {
45      name: 'Graph Protocol',
46      icon: sdk.ipfs.getDataURILoader('QmbLBNdhEgjAWXzrhGNk8cbQNiwX8HqmD8grYZLrvvJTw4', 'image/png'),
47      protocolLaunch: '2020-12-17', 
48      category: 'Network Protocol',
49      subcategory: 'Indexing', 
50      description: 'The Graph is an indexing protocol for querying networks like Ethereum and IPFS. Anyone can build and publish open APIs, called subgraphs, making data easily accessible.',
51      feeDescription: 'Query fees are partially burnt and remainder are paid to indexers, delegators, and curators.',
52      blockchain: 'Ethereum',
53      source: 'The Graph Protocol',
54      website: 'https://thegraph.com/en/',
55      tokenTicker: 'GRT',
56      tokenCoingecko: 'the-graph',
57
58    },
59  })
60}

It's something off?

Report it to the discussion board on Discord, we will take care of it.

Adapter Info

Version

0.0.2

License

MIT

IPFS CID

QmRcACAdMPnNRNF2pdD3SJALJ8SCy18cKra1Rwy3g3hkqJ

CID (source)

QmPeDWQrgxj2T6Pze8DTp1mUPqiipSwstwZqvqDoB71EgB

Collections

web3-revenue

Author

0x1a171a91B4Aa1A669e2397D6670746DDcDd4fbBe