smizBSC Smart Contracts with Highest Gas per Tx. in the Last 2 Weeks
    Updated 2024-07-06
    --this CTE calculates high-level stats by recipient addresses
    -- note the "having" clause, which requires
    -- the recipient address to have at least 100 distinct sending addresses
    -- within the given time period
    with address_activity as (
    select
    to_address as tx_recipient_address,
    sum(gas_used) as total_gas_used,
    sum(gas_used) / count(distinct tx_hash) as avg_gas_used_per_tx,
    sum(gas_used) / count(distinct from_address) as avg_gas_used_per_sending_address,
    count(distinct from_address) as sending_addresses_count,
    count(distinct tx_hash) as txs_count
    from
    bsc.core.fact_transactions
    WHERE
    block_timestamp >= dateadd(day, -14, getdate())
    and status = 'SUCCESS'
    group by
    1
    having
    sending_addresses_count > 100
    ),
    contract_addresses as (
    select
    *
    from
    bsc.core.dim_contracts
    ),
    -- this CTE limits the first CTE to only those identified contract addresses
    -- using an inner join
    contract_address_activity_joined as (
    select
    tx_recipient_address as contract_address,
    total_gas_used,
    avg_gas_used_per_tx,
    avg_gas_used_per_sending_address,
    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived