forgashStacks - Microblocks LQ Example
Updated 2023-12-05
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 Stacks - Blocks LQ Example @ https://flipsidecrypto.xyz/edit/queries/5d2d348d-5942-4c59-a42f-f668ee14a0ce
with call as (
-- /extended/v1/microblock
-- returns latest microblocks and associated metadata
select
live.udf_api(
'GET',
'https://lingering-frequent-uranium.stacks-mainnet.quiknode.pro/0f69bc55d00c3ae9bc85679fd2ee81c835c40abe/extended/v1/microblock?limit=200',
{ },
{ }
) as res
),
transform as (
SELECT
VALUE:block_height :: INT as block_height,
VALUE:parent_burn_block_time_iso :: TIMESTAMP_NTZ as block_timestamp,
VALUE:microblock_sequence :: INT as microblock_sequence,
VALUE:canonical :: BOOLEAN as canonical,
VALUE:block_hash :: STRING as block_hash,
VALUE:parent_block_hash :: STRING as parent_block_hash,
ARRAY_SIZE(VALUE:txs :: ARRAY) as tx_count,
VALUE as block_header
from
call,
lateral flatten(input => res:data:results :: array)
)
select
concat_ws('-', block_height, microblock_sequence) as microblock_block_height,
block_height,
block_timestamp,
microblock_sequence,
canonical,
block_hash,
parent_block_hash,
tx_count,
avg(tx_count) over (
Run a query to Download Data