Updated 2023-08-23
    -- with base as (
    -- SELECT
    -- tx_receiver as contract,
    -- a.block_timestamp,
    -- first_value(a.block_timestamp) OVER (PARTITION BY contract ORDER BY a.block_timestamp) as origin,
    -- tx
    -- from near.core.fact_actions_events a
    -- LEFT JOIN near.core.fact_transactions t ON t.tx_hash = a.tx_hash
    -- where action_name = 'DeployContract'
    -- ),
    -- refine as(
    -- SELECT
    -- *,
    -- CASE WHEN block_timestamp = origin THEN 'new' ELSE 'upgrade existing' END as cat
    -- from base
    -- )
    -- SELECT *
    -- FROM refine
    -- LIMIT 10


    SELECT
    t.tx as t_tx,
    t.tx_hash as txn_hash,
    t.tx_receiver as t_tx_receiver,
    a.*
    -- tx_receiver as contract,
    -- a.block_timestamp,
    -- first_value(a.block_timestamp) OVER (PARTITION BY contract ORDER BY a.block_timestamp) as origin,
    -- tx,
    from near.core.fact_actions_events a
    LEFT JOIN near.core.fact_transactions t ON t.tx_hash = a.tx_hash
    WHERE 1=1
    -- where t.block_timestamp::date = '2023-07-21'
    -- AND a.block_timestamp::date = '2023-07-21'
    AND action_name = 'DeployContract'
    Run a query to Download Data