Query editor
with blocks as (select tx.block_height as block_height, count(*) as commit_count, count(distinct tx.input[1].script_pub_key.address) as miner_count, count(distinctsubstr(tx.output[1].script_pub_key.hex,4+67,4+2) -- msg_parent_block||msg_parent_index) as parent_uniq, sum(tx.fee + reduce(tx.output, 0, (s,ox) -> IF(ox.script_pub_key.address <> tx.input[1].script_pub_key.address, s + ox.value, s), s->s)) as net_spend, sum(tx.fee) as net_feesFROM bitcoin.transactions txWHERE tx.block_height >= 666050 -- Stacks 2.0 genesisAND tx.input_count = 1AND tx.output_count between 2 and 4AND starts_with(tx.output[1].script_pub_key.hex, 0x6a4c5058325b) -- OP_RETURN + OP_PUSHDATA1(0x50) + magic 'X2' + stx_op '['GROUP BY 1ORDER BY 1)select block_height - (block_height - 666050) % 300 as block_height, max(commit_count) as commits_max, max(miner_count) as miners_max, min(miner_count) as miners_min, approx_percentile(miner_count, 0.50) as miners_median, approx_percentile(miner_count, 0.01) as miners_p01, round(avg(miner_count), 2) as miners_avg, round(avg(net_spend), 8) as block_spend_avg, round(avg(net_fees), 8) as block_fees_avg, round(sum(net_spend) / sum(miner_count), 8) as miner_spend_avg, round(sum(net_fees) / sum(miner_count), 8) as miner_fees_avg, 1.000 * sum(parent_uniq - 1) / sum(miner_count - 1) as dissensusfrom blocksgroup by 1order by 1