with contract as ( select tx_hash as tx , block_timestamp as time
from near.core.fact_actions_events
where action_name = 'DeployContract')
,
final as ( select min(time) as dates , tx_receiver
from near.core.fact_transactions a left outer join contract b on a.tx_hash = b.tx
where block_timestamp = time
group by 2
)
,
contracts as ( select *
from final
where dates >='2022-01-01'
)
select trunc(dates,'month') as month, count(DISTINCT(tx_receiver)) as daily_contract
from contracts
group by 1