with tab1 as (
select distinct
TX_HASH as ids,
ACTION_NAME as Name_of_actions
from near.core.fact_actions_events
where ACTION_NAME='AddKey'
),
tab2 AS
(select
TX_HASH as trans_id,
TX_RECEIVER as sm_contract,
min(BLOCK_TIMESTAMP)
from near.core.fact_transactions
group by 2, 1
)
select
distinct (sm_contract),
count(sm_contract)
from tab2
inner join tab1 on tab2.trans_id = tab1.ids
group by 1
order by 2 desc
limit 10000