Query editor
WITH chain_list AS (SELECT'ethereum' as blockchain,'Ethereum' as blockchain_name-- FROM op_chains.chain_list-- WHERE blockchain = 'ethereum'), totals as (SELECTblockchain_name, COUNT(*) AS total_num_txs, SUM(gas_used) AS total_gas_used, SUM((gas_used/1e9*gas_price/1e9)) AS total_eth_fees, COUNT(DISTINCT t."from") AS total_num_tx_from_addressesFROM ethereum.transactions tINNER JOIN chain_list clON /*t.blockchain*/ 'ethereum' = cl.blockchainWHERE gas_price > 0AND t.block_time > NOW() - interval '{{Summary - Trailing Num Days}}' dayGROUP BY 1), by_project AS (SELECT blockchain_name, contract_type--, bot_label_if_unknown, COUNT(*) AS num_txs, SUM(tx_gas_used) AS tx_gas_used-- , SUM(trace_gas_used) AS trace_gas_used, SUM(tx_eth_fees) AS tx_eth_fees, COUNT(DISTINCT tx_from_address) AS num_tx_from_addresses-- , MAX_BY(example_contracta, tx_gas_used) AS example_contracta, MAX_BY(example_contract, tx_gas_used) AS example_contract, MAX_BY(example_creator, tx_gas_used) AS example_creatorFROM (SELECTblockchain_name, tx_hash, tx."from" AS tx_from_address, tx.gas_used AS tx_gas_used, (tx.gas_used/1e9*gas_price/1e9) AS tx_eth_fees, COALESCE(contract_project, token_symbol, cast(cm.creator_address as varchar) /*'- Unmapped -'*/) AS contract_type-- , CASE WHEN COALESCE(contract_project, token_symbol) IS NULL THEN COALESCE(mev.name, 'Likely ' || INITCAP( REPLACE( REPLACE(lbl.name, ' address', ''), ' contract','') ) ) ELSE NULL END AS bot_label_if_unknown, COUNT(*) AS num_calls-- , MAX(t.gas_used) AS trace_gas_used, MAX_BY(t.to, t.gas_used + tx.gas_used) AS example_contract, MAX_BY(cm.creator_address, t.gas_used + tx.gas_used) AS example_creator-- , MAX_BY(trace_to, tx.gas_used) AS example_contractbFROM ethereum.traces tINNER JOIN ethereum.transactions txON tx.hash = t.tx_hashAND tx.block_number = t.block_numberAND tx.block_time = t.block_timeINNER JOIN chain_list clON /*t.blockchain*/ 'ethereum' = cl.blockchainINNER JOIN contracts.contract_mapping cmON t.to = cm.contract_addressAND /*t.blockchain*/ 'ethereum' = cm.blockchain