with contract_deploy_date as (
select
tx_receiver, min(t.block_timestamp) as "Date"
from near.core.fact_transactions t
inner join near.core.fact_actions_events d on t.tx_hash = d.tx_hash
inner join near.core.fact_actions_events_function_call f on t.tx_hash = f.tx_hash
where METHOD_NAME = 'new' and d.action_name = 'DeployContract'
group by TX_RECEIVER
),
top_contracts as (
select
tx_receiver,
count(distinct tx_hash) as tx_count
from near.core.fact_transactions
group by 1
order by 2 desc
limit 10
)
select c.tx_receiver, "Date", tx_count
from top_contracts c left join contract_deploy_date d on d.tx_receiver = c.tx_receiver