Gas Usage & Fees Generated

Returns transactions and DEX trades by token on Ethereum, where transaction to is 0x582d…def1, currency smart contract is 0x582d…def1 and block time since 2024-01-01: count, sum of transaction gas, sum of transaction cost in USD, average of transaction gas price and average of transaction cost in USD.

By chantha · saved 18 July 2025 · Bitquery API v2

What it returns

Filters

The query

query GetGasAndFees($contract_address: String, $start_date: DateTime, $end_date: DateTime) {
  EVM(dataset: combined, network: eth) {
    # Gas usage for token transactions
    Gas_Usage: Transactions(
      where: {
        Transaction: {To: {is: $contract_address}}
        Block: {Time: {since: $start_date, till: $end_date}}
      }
    ) {
      count
      total_gas_used: sum(of: Transaction_Gas)
      total_fees_usd: sum(of: Transaction_CostInUSD)
      avg_gas_price: average(of: Transaction_GasPrice)
    }
    
    # Fees for DEX trades involving the token
    DEX_Fees: DEXTradeByTokens(
      where: {
        Trade: {Currency: {SmartContract: {is: $contract_address}}}
        Block: {Time: {since: $start_date, till: $end_date}}
      }
    ) {
      total_fees: sum(of: Transaction_CostInUSD)
      avg_fee_per_trade: average(of: Transaction_CostInUSD)
    }
  }
}

Variables

{
  "contract_address": "0x582d872a1b094fc48f5de31d3b73f2d9be47def1",
  "pool_address": "0x6a9c4fc2b35ee398e7a0e75d982872466ba93cb8",
  "start_date": "2024-01-01T00:00:00Z",
  "end_date": "2024-12-31T23:59:59Z"
}

Similar queries