0xHaM-dContracts' Overview copy
    Updated 2024-06-15
    -- forked from Contracts' Overview @ https://flipsidecrypto.xyz/edit/queries/75590bec-febe-4b1a-91b8-d1ef92f41524

    -- forked from hess / Overview of Contracts @ https://flipsidecrypto.xyz/hess/q/opKCaCur3-3w/overview-of-contracts

    with contract as (
    select
    a.block_timestamp,
    a.tx_hash,
    a.origin_from_address,
    tx_fee,
    PROJECT_NAME,
    LABEL_TYPE,
    contract_address
    from kaia.core.fact_event_logs a
    join kaia.core.fact_transactions b on a.tx_hash = b.tx_hash
    join kaia.core.dim_labels c on a.CONTRACT_ADDRESS = c.ADDRESS
    WHERE LABEL_TYPE != 'token'
    )

    select
    PROJECT_NAME,
    count(DISTINCT origin_from_address) as "Users",
    count(DISTINCT tx_hash) as "Transactions",
    sum(tx_fee) as "Total Fees",
    avg(tx_fee) as "Avg Fee",
    median(tx_fee) as "Median Fee",
    max(tx_fee) as "Max Fee"
    from contract
    group by 1
    order by 3 desc
    LIMIT 5



    QueryRunArchived: QueryRun has been archived