Query editor
-- Plasma tracker: native XPL balance (wei) of every address at the end of the base date, from chain data.-- balance = value received - value sent in successful traces - gas paid (gas_used x gas_price).-- A trace moves value from "from" to: refund_address for a selfdestruct (type 'suicide'), the new contract (address) for a-- contract creation, and "to" for a call. delegatecall / callcode / staticcall traces carry a value field but move nothing.-- Addresses funded in the genesis block come out negative here (that allocation is not in traces).-- first_day = first day the address moved native XPL or paid gas. base_date is repeated on every row.-- To re-base: change the three date literals below, then refresh the materialized view.WITH legs AS (SELECT x.addr, x.sgn * CAST(t.value AS DECIMAL(38,0)) AS d, t.block_date AS dayFROM plasma.traces tCROSS JOIN UNNEST(ARRAY[CASE WHEN t.type = 'suicide' THEN t.refund_address ELSE COALESCE(t."to", t.address) END, t."from"],ARRAY[1, -1]) AS x(addr, sgn)WHERE t.block_date <= DATE '2026-10-16'AND t.success AND t.tx_success AND t.value > UINT256 '0'AND (t.call_type IS NULL OR t.call_type NOT IN ('delegatecall', 'callcode', 'staticcall'))),nat AS (SELECT addr, SUM(d) AS wei, MIN(day) AS first_dayFROM legsWHERE addr IS NOT NULLGROUP BY 1),gas AS (SELECT x."from" AS addr,-SUM(CAST(x.gas_used AS DECIMAL(38,0)) * CAST(x.gas_price AS DECIMAL(38,0))) AS wei,MIN(x.block_date) AS first_dayFROM plasma.transactions xWHERE x.block_date <= DATE '2026-10-16' AND x.gas_price > UINT256 '0'GROUP BY 1)SELECT COALESCE(n.addr, g.addr) AS address,COALESCE(n.wei, DECIMAL '0') + COALESCE(g.wei, DECIMAL '0') AS wei,LEAST(COALESCE(n.first_day, g.first_day), COALESCE(g.first_day, n.first_day)) AS first_day,DATE '2026-10-16' AS base_dateFROM nat nFULL OUTER JOIN gas g ON n.addr = g.addr