adriaparcerisasdebut of near contracts
    Updated 2023-01-17
    WITH
    debuts as (
    SELECT
    distinct receiver_id,
    min(trunc(x.block_timestamp,'week')) as first_date
    from near.core.fact_actions_events x
    join near.core.fact_receipts y on x.tx_hash=y.tx_hash
    where action_name = 'DeployContract'
    group by 1
    ),
    interactions as (
    SELECT
    case when d.receiver_id like '%factory.bridge%' then 'factory.bridge.near' else d.receiver_id end as receiver_id,
    first_date,
    --case when date between first_date and first_date+INTERVAL '1 MONTH' then 'New contract' else 'Old contract' end as type,
    count(distinct call.tx_hash) as interactions
    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
    inner join debuts d on rc.receiver_id=d.receiver_id
    WHERE ACTION_NAME = 'FunctionCall' and split(split(rc.status_value,':')[0],'{')[1] not ilike '%Failure%'
    AND METHOD_NAME <> 'new'
    group by 1,2 order by 2 asc, 3 desc
    ),
    alls as (
    SELECT
    sum(interactions) as total_interactions
    from interactions
    )
    select *,interactions/total_interactions as share from interactions,alls where interactions > 20000 and LEN(receiver_id) <40
    Run a query to Download Data