mariyaTop 10 Contracts With Most Active Wallets
    Updated 2022-05-08
    WITH adresses AS (
    SELECT DISTINCT tx_from[0] AS wallet
    FROM terra.transactions
    WHERE block_timestamp::date >= '2022-01-01'
    AND tx_status = 'SUCCEEDED'
    ),
    protocols AS (
    SELECT msg_value:contract as contract,
    count(DISTINCT msg_value:sender) as total_addresses,
    count(*) as total_transactions
    from terra.msgs
    where msg_value:sender in (SELECT wallet from adresses)
    AND msg_value:sender IS NOT NULL
    and block_timestamp::date >= '2022-01-01'
    AND contract IS NOT NULL
    GROUP by 1
    order by 2 desc
    limit 10
    )

    SELECT (case when contract = 'terra1sepfj7s0aeg5967uxnfk4thzlerrsktkpelm5s' then 'ANC'
    when contract = 'terra1vs9jr7pxuqwct3j29lez3pfetuu8xmq7tk3lzk' then 'Unknown Contract'
    when contract = 'terra1xj49zyqrwpv5k928jwfpfy2ha668nwdgkwlrg3' then 'Astroport'
    when contract = 'terra1tndcaqxkpc5ce9qee5ggqf430mr2z3pefe5wj6' then 'LUNA-UST Pair'
    when contract = 'terra1hzh9vpxhsk8253se0vv5jj6etdvxu3nv8z07zu' then 'aUST'
    when contract = 'terra146ahqn6d3qgdvmj8cj96hh03dzmeedhsf0kxqm' then 'Anchor Airdrop'
    when contract = 'terra14z56l0fp2lsf86zy3hty2z47ezkhnthtr9yq76' then 'ANC Token'
    when contract = 'terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp' then 'bLUNA'
    when contract = 'terra1m6ywlgn6wrjuagcmmezzz2a029gtldhey5k552' then 'LUNA-UST Astro Port'
    when contract = 'terra1tmnqgvg567ypvsvk6rwsga3srp7e3lg6u0elp8' then 'Anchor Overseer'
    end) as contract_name,contract, total_addresses, total_transactions from protocols

    Run a query to Download Data