Hessishzink - usr dist
    Updated 2025-04-17
    with all_actions as (SELECT BLOCK_TIMESTAMP,
    '0x'||SUBSTRING(TOPICS[2], 27) as receiver,
    ethereum.public.udf_hex_to_int(topics[3]) as token_id ,TX_HASH
    from ink.core.fact_event_logs
    WHERE
    CONTRACT_ADDRESS = lower('0xFb2Cd41a8aeC89EFBb19575C6c48d872cE97A0A5') and
    TOPICS[0] = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
    and TX_SUCCEEDED = 'TRUE'
    ),

    owenrs as (select token_id, receiver
    from (
    select distinct token_id, receiver,
    row_number() over (partition by token_id order by BLOCK_TIMESTAMP desc) as rn
    from all_actions
    ) as ranked_actions
    where rn = 1),


    final as (select distinct receiver as user ,count(distinct token_id) as "ZNS balance"
    from owenrs
    group by 1 )


    select case
    when "ZNS balance" = 1 then 'A) 1 domain'
    when "ZNS balance" > 1 and "ZNS balance" < 5 then 'B) 2~4 domains'
    when "ZNS balance" >= 5 and "ZNS balance" < 10 then 'C) 5~9 domains'
    when "ZNS balance" >= 10 then 'D) +10 domains' end as "ZNS balance",
    count(DISTINCT user) as users
    from final
    group by all
    order by 1

    Last run: 11 days ago
    ZNS balance
    USERS
    1
    A) 1 domain40652
    2
    B) 2~4 domains1132
    3
    C) 5~9 domains17
    4
    D) +10 domains8
    4
    90B
    42s