purifUpdated conditions
    Updated 2024-09-27
    with badge_minters as (
    select
    distinct minter as minter,
    count(badge_id) as minted_badges
    from
    (
    select
    decoded_log ['to'] as minter,
    decoded_log ['id'] as badge_id,
    from
    berachain.testnet.fact_decoded_event_logs
    where
    CONTRACT_ADDRESS = lower('0x886D2176D899796cD1AfFA07Eff07B9b2B80f1be')
    and decoded_log ['from'] = lower('0x0000000000000000000000000000000000000000')
    )
    group by 1
    ),
    thj_delegations as (
    select
    user,
    sum(amount) as thj_delegated
    from
    (
    (
    select
    concat('0x', substr(TOPICS [1], 27, 64)) as user,
    (ethereum.public.udf_hex_to_int(data) :: int) / 1e18 as amount
    from
    berachain.testnet.fact_event_logs
    where
    contract_address = '0xbda130737bdd9618301681329bf2e46a016ff9ad'
    and topics [0] = '0x99966631dd6d6c02c5416ca2369709e025ff974a2f1b3f11c8b74acc67731f0e'
    and concat('0x', substr(TOPICS [2], 27, 64)) = lower('0x40495A781095932e2FC8dccA69F5e358711Fdd41')
    UNION ALL
    select
    QueryRunArchived: QueryRun has been archived