--credit 8193138
with contracts_deployed as (
select min(event.block_timestamp) as date,
transactionn.tx_receiver
from near.core.fact_actions_events event
inner join near.core.fact_transactions transactionn
on event.tx_hash = transactionn.tx_hash
where action_name= 'DeployContract'
group by transactionn.tx_receiver)
select count(tx_hash) as txns,
count(distinct tx_signer),
tx_receiver
from near.core.fact_transactions
where tx_receiver in (select tx_receiver from contracts_deployed where date >=CURRENT_DATE - 120) and block_timestamp >= CURRENT_DATE - 120
group by tx_receiver
order by txns desc
limit 5