LittlerDatakaia nft holders
    Updated 2024-10-17

    with kaia_nfts_holders as (

    select
    max(block_timestamp) as timestamp
    ,utils.udf_hex_to_int(topics[3])::string as token_id
    ,concat('0x', SUBSTR(topics[2], 27, 40)) as user_address
    from kaia.core.fact_event_logs
    where 1=1
    --and tx_hash = '0x9d596c5dbcc947d2438a22d9857683c9c3152a50f7c0a95e883fc637c9364fdd'
    and contract_address = '0x50f718ca7dc27393dbcc2b41c5867c588e2b48fb' --nft_contract
    and topics[0] = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' --transfer topic
    group by token_id, user_address
    qualify row_number() over (partition by token_id order by timestamp desc) = 1
    )

    select
    user_address
    ,count(token_id) as nfts
    from kaia_nfts_holders
    group by 1
    order by 2 desc

    /*
    with Warlord_nfts as (
    select
    max(block_timestamp) timestamp
    ,tokenid
    ,nft_to_address
    from ethereum.nft.ez_nft_transfers
    where nft_address = '0xe841e6e68becfc54b621a23a41f8c1a829a4cf44'
    group by 2, 3
    qualify row_number() over (partition by tokenid order by timestamp desc) = 1
    )
    QueryRunArchived: QueryRun has been archived