cypherNear new active contracts
Updated 2023-03-30
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with new_contracts as (
SELECT
*
FROM
(
SELECT
date_trunc('day', call.block_timestamp) as date,
COUNT(DISTINCT tr.TX_RECEIVER) as new_contracts
FROM near.core.fact_actions_events_function_call call
INNER JOIN near.core.fact_transactions tr
ON call.TX_HASH = tr.TX_HASH
INNER JOIN near.core.fact_receipts as rc
ON tr.TX_HASH=rc.TX_HASH
WHERE ACTION_NAME = 'FunctionCall'
AND split(split(rc.status_value,':')[0],'{')[1] ilike '%Success%'
AND METHOD_NAME = 'new'
AND date >= current_date() - {{n_days}}
and date < current_date()
GROUP BY date
)),
contracts as (select
events.block_timestamp as date_,
receiver_id as receiver,
row_number() over (partition by receiver_id order by events.block_timestamp asc) as nums
from near.core.fact_actions_events events
join near.core.fact_receipts rec
on rec.tx_hash = events.tx_hash
where action_name ilike '%DEPLOYCONTRACT%'
AND events.block_timestamp < CURRENT_DATE
group by receiver, date_
qualify nums = 1),
active_contracts as (select
date_trunc('day', tr.block_timestamp) as date,
Run a query to Download Data