cimenActive Addresses
    Updated 2023-01-04
    with days as (select generated_date as block_timestamp from (select -1 + row_number() over(order by 0) i, start_date + i generated_date
    from (select '{{from_date_next}}'::date start_date, '{{to_date_prev}}'::date end_date)
    join table(generator(rowcount => 10000 )) x
    qualify i < 1 + end_date - start_date)),
    t1 as (select from_address, to_address, block_timestamp, contract_address from ethereum.core.ez_eth_transfers tt
    where block_timestamp >= '{{from_date_next}}' and block_timestamp < '{{to_date}}'),
    t2 as (select from_address as wallet_address, block_timestamp, contract_address from t1
    union select to_address as wallet_address, block_timestamp from t1),
    metrics_table as (select date_trunc('{{res_query}}', t2.block_timestamp) as block_timestamp,count(distinct(wallet_address)) as activeaddresses, contract_address from t2
    group by contract_address, date_trunc('{{res_query}}', t2.block_timestamp))
    --insert into metricvalues (created_at, metricid, resolution, value, contractaddress)
    select d.block_timestamp as created_at, {{metricid}} as metricid, '{{resolution}}' as resolution, coalesce(m.activeaddresses,0) as value, '{{contract}}' as contractaddress from metrics_table m
    right join days d on d.block_timestamp = m.block_timestamp;

    Run a query to Download Data