PapasotTerra
    Updated 2022-03-08


    with lst_wallets_90 as (
    select tx_from[0] as wallet
    ,min(block_timestamp)::date as min_date
    from terra.transactions
    group by 1
    having min_date>=CURRENT_DATE-90
    ),
    tx_ids as (
    select tx_id
    from terra.transactions join lst_wallets_90
    on lst_wallets_90.wallet = tx_from[0]
    -- where tx_status = 'true'
    group by 1
    ),
    contracts as (
    select msg_value:contract::string as contract ,
    BLOCK_TIMESTAMP::date as day,
    count(DISTINCT m.tx_id) as tx_count
    from terra.msgs m join tx_ids t
    on m.tx_id = t.tx_id
    where msg_value:contract::string is not NULL
    group by 1,2
    )
    select day , label , tx_count
    from contracts join terra.labels
    on address = contract
    where label is not NULL
    Run a query to Download Data