Query editor
WITH event_data AS (SELECT375 + -- Base gas cost for every log(COALESCE(length(topic0), 0) + COALESCE(length(topic1), 0) + COALESCE(length(topic2), 0) + COALESCE(length(topic3), 0)) / 32 * 375 + -- 375 gas cost for every log topicCOALESCE(length(log.data), 0) * 8 AS gas_cost_per_log -- Gas cost for the log data in gas units, without conversionFROM ethereum.logs logJOIN ethereum.transactions tx ON log.tx_hash = tx.hashWHERE log.block_time >= CURRENT_DATE - INTERVAL '30' DAY),gas_cost_data AS (SELECTSUM(gas_cost_per_log) AS total_gas_cost -- Sum of gas cost for all logs in gas unitsFROM event_data)SELECT SUM(total_gas_cost) AS total_gas_cost -- Aggregate sum of gas cost in gas unitsFROM gas_cost_data;