maybeyonasnep141_tokens
    Updated 2022-12-12
    with
    flat_logs as (
    select
    block_timestamp,
    tx_hash,
    receiver_id,
    value as log
    from near.core.fact_receipts r,
    lateral flatten(input => r.logs)
    ),
    ft_tokens as (
    select
    tx_receiver as token_address,
    case
    when l.symbol is null then tx_receiver else l.symbol
    end as token_symbol,
    count( distinct
    case when array_size(split(tx_signer,'.')) > 1 then tx_signer else null end
    ) as users,
    count(
    case when array_size(split(tx_signer,'.')) > 1 then f.tx_hash else null end
    ) as txs
    from near.core.fact_actions_events_function_call f
    join near.core.fact_transactions t on f.tx_hash=t.tx_hash
    left outer join near.core.dim_token_labels l on t.tx_receiver = l.token_contract
    where method_name = 'ft_transfer' or method_name = 'ft_transfer_call'
    group by 1,2
    ),
    nep_tokens as (
    select distinct
    receiver_id as token_contract,
    'nep141' as type
    from flat_logs
    where true
    and try_parse_json(replace(log,'EVENT_JSON:','')):standard::string = 'nep141'
    )
    Run a query to Download Data