mlhUntitled Query
Updated 2022-10-25Copy 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
›
⌄
WITH deposits AS (
SELECT concat('0x', substr(data, 27,40)) AS address
, tokenflow_eth.hextoint(substr(data,67,64))*1e-18 AS amount
, block_timestamp
FROM optimism.core.fact_event_logs
WHERE origin_to_address = '0x4200000000000000000000000000000000000007'
AND origin_from_address = '0x0000000000000000000000000000000000000000'
AND topics[0] = '0xb0444523268717a02698be47d0803aa7468c00acbed2f8bd93a0459cde61dd89'
AND topics[2] = '0x000000000000000000000000deaddeaddeaddeaddeaddeaddeaddeaddead0000' --ETH
AND block_timestamp::DATE >= '2022-01-01'
),
first_tx_date AS (
SELECT from_address
, MIN(t.block_timestamp) AS f_block_timestamp
FROM optimism.core.fact_transactions t
JOIN deposits
ON (from_address = address
AND deposits.block_timestamp <= t.block_timestamp)
GROUP BY 1
),
first_tx AS (
SELECT event_name
FROM optimism.core.fact_event_logs t
JOIN first_tx_date f
ON (f.from_address = t.origin_from_address
AND f_block_timestamp = block_timestamp)
)
SELECT event_name
, COUNT(*) AS tx
FROM first_tx
GROUP BY 1
HAVING event_name IS NOT NULL
ORDER BY tx DESC
limit 10
Run a query to Download Data