SandeshAirdrop to NFT+token holders
    Updated 2024-10-17
    with nft_holders as
    (
    select nft_to_address as holder from ethereum.nft.ez_nft_transfers
    where BLOCK_TIMESTAMP <='2024-08-19'
    and nft_address=lower('0xDE76aD8998310dd4C6cA9fdb03a5F20bbf01Ce96')
    and block_number>='19524912'
    qualify (row_number() over (partition by tokenid order by block_timestamp desc)=1)
    ),
    token_holders as
    (

    SELECT
    value:USER_ADDRESS as holder
    FROM (
    SELECT
    livequery.live.udf_api('https://flipsidecrypto.xyz/api/v1/queries/bfb132a7-7484-4ba0-8347-3359025afd05/data/latest') as response
    ), lateral FLATTEN (input => response:data)

    ),

    combined AS
    (
    select * from nft_holders
    union all
    select * from token_holders
    ),
    temp as
    (
    select to_address, sum(amount) as airdrop_amount
    -- ,utils.udf_hex_to_int(data) as int
    from arbitrum.core.ez_token_transfers
    where 1=1
    and contract_address='0x93fa0b88c0c78e45980fa74cdd87469311b7b3e4'
    and from_address='0x83002daec9689b1d07916fd034ed1d660c2d6c20'
    -- and tx_hash=lower('0x3823efae2362b1c397f075e23a809ea1006fac2272bc3b2d62b8fa15ff92b12e')
    and origin_function_signature='0x66afd8ef'
    QueryRunArchived: QueryRun has been archived