0xHaM-dUntitled Query
    Updated 2022-08-26
    with nft_sales_transactions as (
    select
    block_timestamp,
    tx_hash,
    event_inputs:from as seller,
    event_inputs:to as purchaser,
    event_inputs:tokenId as token_id,
    contract_address as nft_address
    from avalanche.core.fact_event_logs lg inner join avalanche.core.fact_transactions tr using(tx_hash)
    where
    event_inputs:tokenId is not null
    and event_inputs:from != '0x0000000000000000000000000000000000000000'
    and avax_value>0
    and event_inputs:to !='0x0000000000000000000000000000000000000000'
    and tr.block_timestamp >= '2022-06-16'
    and tx_status = 'SUCCESS'
    and event_name = 'Transfer'
    and tr.block_timestamp::date < CURRENT_DATE
    )
    select
    block_timestamp::date as date,
    'Avalanche' as status,
    count(DISTINCT seller) as seller_cnt,
    count(DISTINCT purchaser) as buyer_cnt,
    count(DISTINCT tx_hash) as sales_cnt,
    count(DISTINCT nft_address) as collection_cnt,
    count(DISTINCT token_id) as nft_cnt,
    sum(sales_cnt) over (order by date) as cum_sales_cnt
    from nft_sales_transactions
    group by 1,2

    UNION

    select
    block_timestamp::date as date,
    'Optimism' as status,
    Run a query to Download Data