shaunoffflipside node remix example copy
    Updated 2023-07-19
    -- forked from theericstone / flipside node remix example @ https://flipsidecrypto.xyz/theericstone/q/DaGuTEfTYF7I/flipside-node-remix-example

    -- with flipside and livequery you can combine data sources
    -- in one place 🤝

    -- in this simple example we first identify
    -- the largets "nft whales" 🖼️ 🐋

    -- and then use livequery to pull current ethereum balances
    -- directly from a node ⚡️
    -- first you will need to connect to a node provider, then this will work!

    -- 🐳 🔭 first, whale-watching:
    -- use flipside to summarize NFT purchasers from the last week
    WITH nft_whales AS (
    SELECT
    buyer_address,
    sum(price_usd) as usd_volume
    FROM ethereum.core.ez_nft_sales
    WHERE block_timestamp >= GETDATE() - interval'1 week'
    GROUP BY 1
    ORDER BY 2 DESC
    LIMIT 25
    ),

    -- ☊ next, pull each of their balances by passing an array to
    -- a native balances call to an Ethereum node
    whale_balances AS (
    SELECT
    *
    FROM table(
    ethereum_mainnet.latest_native_balance(
    (select array_agg(buyer_address) FROM nft_whales)
    )
    )
    )
    Run a query to Download Data