Afonso_DiazContracts
    Updated 2025-01-27
    with

    main as (
    select
    tx_id as tx_hash,
    block_timestamp,
    event_contract as contract_address,
    'Flow' as chain
    from
    flow.core.fact_events
    where
    block_timestamp::date >= current_date - interval '30 days'
    and tx_succeeded

    union all

    select
    tx_hash,
    block_timestamp,
    origin_to_address as contract_address,
    'Flow EVM' as chain
    from
    flow.core_evm.fact_event_logs
    where
    block_timestamp::date >= current_date - interval '30 days'
    and tx_status = 'SUCCESS'
    )

    select
    chain,
    count(distinct tx_hash) as transactions,
    count(distinct contract_address) as contracts,
    transactions / contracts as tx_per_contract
    from
    main
    group by 1
    QueryRunArchived: QueryRun has been archived