-- forked from b4891876-416e-4a5c-b657-e56be50becc4
select
name as "Contract",
sum(tx_fee) as "Total fees",
count (distinct x.tx_hash) as "Number of txns",
avg(tx_fee) as "Average fee per txn"
from avalanche.core.fact_transactions x join avalanche.core.fact_event_logs y on x.tx_hash = y.tx_hash
join avalanche.core.dim_contracts z on y.contract_address = z.address
where x.block_timestamp >= '{{From_Date}}'
and x.block_timestamp <= '{{To_Date}}'
GROUP BY 1
ORDER BY 2 DESC
LIMIT 100