Query editor
-- NAT ON BITCOIN, WEEKLY, READ STRAIGHT FROM WITNESS DATA: the TAP-protocol inscriptions that carry NAT.-- dmt-mint = a claim on one block's NAT (FCFS era, block 817,709 to 885,587: first valid mint per block wins, all pay fees;-- mints all but stop after the redirect, a few stray weeks only)-- token-transfer = an inscribed transfer of NAT ("attempted": TAP's indexer decides validity, the chain only records the attempt)-- token-send = the tap of a transfer (the inscription is sent, moving the tokens)-- Method: taproot script-path spends with a 3-element witness (sig, script, control block); the inscription body is the JSON-- in element 2. Parsed with json_extract_scalar; tick = nat only. Fees from bitcoin.transactions; BTC price weekly from prices.usd_daily.-- "Mint fee share %" = fees paid by NAT mint transactions / all fees miners earned that week: the sniping revenue.-- All-time columns repeat on every row so a counter can read them from row 1; newest week first.with tap as (select i.block_height, i.tx_id,regexp_extract(from_utf8(i.witness_data[2], '?'), '\{\s*"p"\s*:\s*"tap"[^{}]*\}') as jsfrom bitcoin.inputs iwhere i.block_date >= date '2023-11-19' and i.block_height >= 817709and i.type = 'witness_v1_taproot' and cardinality(i.witness_data) = 3and from_utf8(i.witness_data[2], '?') like '%"tap"%'),parsed as (select distinct block_height, tx_id,lower(json_extract_scalar(js, '$.op')) as op,try_cast(json_extract_scalar(js, '$.amt') as double) as amt,json_extract_scalar(js, '$.blk') as blkfrom tapwhere js is not null and lower(json_extract_scalar(js, '$.tick')) = 'nat'),fees as (select p.*, t.fee, t.block_timefrom parsed p join bitcoin.transactions t on t.block_height = p.block_height and t.id = p.tx_id),wk as (select date_trunc('week', block_time) as week,count(case when op = 'dmt-mint' then 1 end) as mint_txs,count(distinct case when op = 'dmt-mint' then blk end) as blocks_targeted,sum(case when op = 'dmt-mint' then fee else 0 end) as mint_fees_btc,count(case when op = 'token-transfer' then 1 end) as transfer_txs,sum(case when op = 'token-transfer' then amt else 0 end) as transfer_amt,count(case when op = 'token-send' then 1 end) as send_txsfrom fees group by 1),blk as (select date_trunc('week', time) as week, count(*) as blocks, sum(total_fees) as all_fees_btcfrom bitcoin.blocks where height >= 817709 group by 1),px as (select date_trunc('week', day) as week, avg(price) as btc_usdfrom prices.usd_daily where symbol = 'BTC' and (blockchain is null or blockchain = 'bitcoin') and day >= date '2023-11-13'group by 1)select b.week, b.blocks, p.btc_usd,nullif(coalesce(w.mint_txs, 0), 0) as "NAT mint txs", -- null, not 0: log-axis charts draw 0 as a full barcoalesce(w.blocks_targeted, 0) as "Blocks targeted",round(coalesce(w.mint_txs, 0) * 1.0 / nullif(w.blocks_targeted, 0), 1) as "Mints per block",nullif(round(coalesce(w.mint_fees_btc, 0), 4), 0) as "Mint fees, BTC",nullif(round(coalesce(w.mint_fees_btc, 0) * p.btc_usd, 0), 0) as "Mint fees, $",round(100.0 * coalesce(w.mint_fees_btc, 0) / b.all_fees_btc, 2) as "Mint fee share %",round(b.all_fees_btc, 2) as "All fees, BTC",coalesce(w.transfer_txs, 0) as "Transfer inscriptions",coalesce(w.send_txs, 0) as "Sends",round(coalesce(w.transfer_amt, 0) / 1e12, 3) as "Transferred, T NAT",sum(coalesce(w.mint_txs, 0)) over () as "Mint txs, all-time",