messariAvalanche Dapps per Address
    Updated 2023-10-02
    with
    contracts as (
    select
    distinct el.contract_address as contract,
    case
    when dl.project_name is not null then dl.project_name
    when el.contract_address = '0xf9ad3f5eab7e9214387c75d58ce40d3a6d05b930' then 'project galaxy'
    when el.contract_address in ('0x3b3e4b4741e91af52d0e9ad8660573e951c88524','0x51af494f1b4d3f77835951fa827d66fc4a18dae8','0xc22fbb3133df781e6c25ea6acebe2d2bb8cea2f9') then 'woofi'
    else el.contract_address
    end as dapp
    from
    avalanche.core.fact_decoded_event_logs el
    left join
    avalanche.core.dim_labels dl
    on el.contract_address = dl.address
    ),
    dapps_per_address as (
    select
    ft.from_address as address,
    count(distinct c.dapp) as unique_dapps
    from
    avalanche.core.fact_transactions ft
    left join
    avalanche.core.fact_decoded_event_logs el
    on ft.tx_hash = el.tx_hash
    left join
    contracts c
    on el.contract_address = c.contract
    where date(ft.block_timestamp) between '{{Start_date}}' and '{{End_date}}'
    group by 1)
    select
    unique_dapps as dapps_interacted_with,
    count(unique_dapps) as number_of_addresses
    from
    dapps_per_address
    group by 1
    Run a query to Download Data