Adapter

BSC Fees

Binance Smart Chain is an inexpensive, EVM-compatible chain

Sub-Adapters 1

Preview and test each sub adapter.

Binance Smart Chain (bsc)

Metadata

ID
bsc
icon
category

"l1"

name

"Binance Smart Chain"

shortName

"BSC"

description

"Binance Smart Chain is an inexpensive, EVM-compatible chain"

feeDescription

"Transaction fees are paid to validators"

blockchain

"BSC"

source

"Etherscan"

website

"https://binance.org"

tokenTicker

"BNB"

tokenCoingecko

"binancecoin"

protocolLaunch

"2020-09-11"

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1export const name = 'BSC Fees';
2export const version = '0.1.0';
3export const license = 'MIT';
4
5export function setup(sdk: Context) {
6  async function getBSCData(date: string): Promise<number> {
7    const query = `query txFees($startOfDay: Int!, $endOfDay: Int!){
8      startOfDay: fee(id: "1", block: { number: $startOfDay }) {
9        totalFees
10      }
11      endOfDay: fee(id: "1", block: { number: $endOfDay }) {
12        totalFees
13      }
14    }`;
15
16    const data = await sdk.graph.query('dmihal/bsc-validator-rewards', query, {
17      variables: {
18        startOfDay: await sdk.chainData.getBlockNumber(date, 'bsc'),
19        endOfDay: await sdk.chainData.getBlockNumber(sdk.date.offsetDaysFormatted(date, 1), 'bsc'),
20      },
21    })
22
23    const bnbFees = data.endOfDay.totalFees - data.startOfDay.totalFees;
24
25    const bnbPrice = await sdk.coinGecko.getHistoricalPrice('binancecoin', date);
26
27    return bnbFees * bnbPrice;
28  }
29
30  sdk.register({
31    id: 'bsc',
32    queries: {
33      oneDayTotalFees: getBSCData,
34      networkFeesByDayUSD: getBSCData,
35    },
36    metadata: {
37      icon: sdk.ipfs.getDataURILoader('QmNVJfveVQVBR5vw298by22h6M1PCw44mvQV4GdkZrmb1n', 'image/svg+xml'),
38      category: 'l1',
39      name: 'Binance Smart Chain',
40      shortName: 'BSC',
41      description: 'Binance Smart Chain is an inexpensive, EVM-compatible chain',
42      feeDescription: 'Transaction fees are paid to validators',
43      blockchain: 'BSC',
44      source: 'Etherscan',
45      website: 'https://binance.org',
46      tokenTicker: 'BNB',
47      tokenCoingecko: 'binancecoin',
48      protocolLaunch: '2020-09-11',
49    },
50  });
51}
52
53

It's something off?

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

Adapter Info

Version

0.1.0

License

MIT

IPFS CID

QmbuxBU8ziFG3admMyu5U2kWLAGdTUtAfmene7KYFfJqJA

CID (source)

QmUknXxXSjD8hJxhjD59ac2NjhNX1NJjySYCzdEU7wRixm

Author

mihal.eth