cloudr3nBasedApp Account by blXSGD
    Updated 2023-10-24
    with blXSGD as (
    SELECT
    block_timestamp,
    tx_hash,
    origin_to_address,
    origin_from_address,
    topics,
    concat(
    '0x',
    right(substr(topics [1], 1 + 2 + 64 * 0, 64), 40)
    ) as from_address,
    concat(
    '0x',
    right(substr(topics [2], 1 + 2 + 64 * 0, 64), 40)
    ) as to_address,
    ethereum.public.udf_hex_to_int(data) :: integer * pow(10, -6) as amount
    FROM
    polygon.core.fact_event_logs
    WHERE
    1 = 1 --tx_hash='0xf1f22a8fd68b7092a150648e608c3b620cc878edac99e72e915224ae1b2242e3'
    and contract_address = '0xfe3e6df612416f37031a61f622d5ecf027346c42'
    and topics [0] = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
    ),

    -- assuming only card users can mint blXSGD (230 users)
    users as (
    select
    distinct address as token_users
    from (
    select
    case when to_address='0x0000000000000000000000000000000000000000' then from_address
    else to_address
    end as address
    from
    blXSGD
    WHERE
    Run a query to Download Data