cristinatintoEragon Immortal NFTs
    Updated 2025-01-02
    with tx as (
    select distinct tx_hash from aptos.core.fact_transactions where block_timestamp>'2024-05-01'
    and payload_function ='0x2ddd7fa041625cd617ac81f445a16326fcee11f44027913d83e4e20b42aee7fb::immortal_nft::mint_with'
    and success=TRUE --and tx_hash='0x6234d04b0c51b31d1c5a8d539645f83d6a3199fb5cb6ece093d3f4b27b59bdb9'
    ),
    volume as (
    select tx_hash, event_data:amount/pow(10,8) as amount
    from aptos.core.fact_events where block_timestamp>'2024-05-01'
    and tx_hash in (select * from tx)
    and event_module='coin' and event_resource='DepositEvent' and account_address='0x2ddd7fa041625cd617ac81f445a16326fcee11f44027913d83e4e20b42aee7fb'
    ),
    type as (
    select tx_hash, block_timestamp, event_data:owner as user, event_data:type as type
    from aptos.core.fact_events where block_timestamp>'2024-05-01'
    and tx_hash in (select * from tx)
    and event_module='immortal_nft' and event_resource='EragonImmortalMint' --and account_address='0x2ddd7fa041625cd617ac81f445a16326fcee11f44027913d83e4e20b42aee7fb'
    ),
    final_info as (
    SELECT type.tx_hash, block_timestamp, user, type, amount
    from type join volume on type.tx_hash=volume.tx_hash
    ),
    news as (
    select distinct user as new, min(date_trunc('day',block_timestamp)) as first_tx
    from final_info group by 1
    )
    select date_trunc('day',block_timestamp) as day,
    count(distinct tx_hash) as immortal_nfts,
    sum(immortal_nfts) over (order by day) as total_immortal_nfts,
    count(distinct user) as nft_owners,
    count(distinct new) as new_owners,
    sum(new_owners) over (order by day) as total_nft_owners,
    sum(amount) as amount_spent_apt,
    sum(amount_spent_apt) over (order by day) as total_amount_spent_apt
    from final_info fi join news n on date_trunc('day',block_timestamp)=first_tx
    group by 1 order by 1 desc
    QueryRunArchived: QueryRun has been archived