tiloyeTop gas guzzlers
    Updated 2023-06-12
    with eth_price as (
    select
    hour,
    price
    from ethereum.core.fact_hourly_token_prices
    where hour >= current_date - interval '30 days'
    and token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
    ),

    transactions_base as (
    select
    block_timestamp,
    tx_hash,
    to_address,
    gas_price,
    gas_used,
    (tx_fee * price) as tx_fee_usd
    from ethereum.core.fact_transactions
    left join eth_price
    on date_trunc('hour', block_timestamp) = hour

    where block_timestamp >= sysdate() - interval '1 month'
    and tx_fee > 0
    and price > 0
    and to_address is not null
    ),

    transactions_base_agg as (
    select
    to_address,
    sum(tx_fee_usd) as tx_fee_usd_1_month,
    avg(gas_price) as avg_gas_price_1_month,
    sum(gas_used) as total_gas_used_1_month
    from transactions_base
    group by to_address
    order by tx_fee_usd_1_month desc
    Run a query to Download Data