shaunoffflipside node remix example copy
Updated 2023-07-19Copy Reference Fork
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
-- 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