Query editor
-- 获取当前 ETH 价格,用于估算 USD 价值WITH current_eth_price AS (SELECT priceFROM prices.usdWHERE symbol = 'WETH' AND blockchain = 'ethereum'ORDER BY minute DESCLIMIT 1),spender_stats AS (SELECT"from" AS wallet_address, -- 交易发起地址COUNT(*) AS tx_count, -- 交易总次数MAX(block_time) AS last_active_time, -- 最后活跃时间-- 计算 Gas 总消耗 (ETH)-- 公式: (L2 Gas Used * Gas Price + L1 Fee) / 10^18SUM((gas_used * gas_price + COALESCE(l1_fee, 0)) / 1e18) AS total_gas_spent_ethFROM base.transactions-- 性能优化提示:如果查询超时,可以尝试限制时间范围,例如只查过去一年的:-- WHERE block_time > NOW() - INTERVAL '1' YEARGROUP BY 1)SELECTROW_NUMBER() OVER (ORDER BY s.total_gas_spent_eth DESC) as rank_id,s.wallet_address,s.tx_count,s.total_gas_spent_eth,-- 计算当前价值 (Total ETH * Current Price)(s.total_gas_spent_eth * p.price) AS current_gas_value_usd,s.last_active_time,-- 这是一个简单的链接生成,方便在区块浏览器查看s.wallet_addressFROM spender_stats sCROSS JOIN current_eth_price pORDER BY s.total_gas_spent_eth DESCLIMIT 100000