Average Tip in terms of avg gas Fee

Historical data This query uses the realtime dataset (the default), which holds only a recent window - hours to days depending on the cube. For older data add a dataset to the top-level element: EVM(network: eth, dataset: combined) archive full history combined archive + realtime in one result Ar

By Akshat · saved 6 November 2025 · run 2 times · Bitquery API v2

What it returns

Filters

The query

# Historical data
#   This query uses the realtime dataset (the default), which holds only a
#   recent window - hours to days depending on the cube.
#
#   For older data add a dataset to the top-level element:
#
#     EVM(network: eth, dataset: combined)
#
#     archive   full history
#     combined  archive + realtime in one result
#
#   Archive and combined need the historical data add-on:
#   https://bitquery.io/pricing
#
# Datasets:  https://docs.bitquery.io/docs/graphql/dataset/archive/
# Retention: https://docs.bitquery.io/docs/graphql/data-coverage-retention/
#

query MyQuery {
  EVM(network: eth, dataset: realtime) {
    TransactionBalances(
      limit: {count: 10}
      orderBy: {descending: Block_Number}
      where: {TokenBalance: {BalanceChangeReasonCode: {eq: 5}}, Block: {Time: {since_relative: {hours_ago:24}}}}
    ) { 
      Block {
        Number
      }
      TokenBalance {
        BalanceChangeReasonCode
        Currency {
          Name
          Symbol
          SmartContract
        }
      }
      avg_gasfees_in_this_block: average(of: Fee_SenderFee)
      Post: sum(of: TokenBalance_PostBalance)
      Post_USD: sum(of: TokenBalance_PostBalanceInUSD)
      Pre: sum(of: TokenBalance_PreBalance)
      Pre_USD: sum(of: TokenBalance_PreBalanceInUSD)
      Total_tip_native: calculate(expression: "$Post - $Pre")
      Total_tip_usd: calculate(expression: "$Post_USD - $Pre_USD")
      number_of_tips: count
      avg_tip_in_this_block: calculate(
        expression: "$Total_tip_native / $number_of_tips"
      )
      avg_tip_usd_in_this_block: calculate(
        expression: "$Total_tip_usd / $number_of_tips"
      )
      tip_in_terms_of_gasfees: calculate(
        expression: "( $avg_gasfees_in_this_block - $avg_tip_in_this_block ) / $avg_gasfees_in_this_block"
      )
    }
  }
}

Similar queries