with smartcontracts as (
SELECT
min(t.BLOCK_TIMESTAMP) as time,DISTINCT TX_RECEIVER
FROM( near.core.fact_actions_events INNER JOIN near.core.fact_transactions t on t.TX_HASH = near.core.fact_actions_events.TX_HASH and t.BLOCK_TIMESTAMP=near.core.fact_actions_events.BLOCK_TIMESTAMP)
WHERE action_name = 'DeployContract'
GROUP BY TX_RECEIVER)
select
Date_trunc('day',time) as date,
COUNT(DISTINCT(TX_RECEIVER)) as number_of_smart_contracts_deployed
FROM smartcontracts
GROUP by date