Query editor
with nn as (select date_trunc('day', now()) - interval '1' day as day), bb as (select date_trunc('day', now()) - interval '1' day- casewhen '{{Interval}}' = '24H' then interval '1' daywhen '{{Interval}}' = '7D' then interval '7' daywhen '{{Interval}}' = '30D' then interval '30' daywhen '{{Interval}}' = '180D' then interval '180' daywhen '{{Interval}}' = '1Y' then interval '365' dayend as day), scans as (select *from (values('Ethereum', 'https://etherscan.io/address/'),('Arbitrum', 'https://arbiscan.io/address/'),('Optimism', 'https://optimistic.etherscan.io/address/'),('Polygon', 'https://polygonscan.com/address/'),('BNB', 'https://bscscan.com/address/'),('Fantom', 'https://ftmscan.com/address/'),('Avalanche_C', 'https://snowtrace.io/address/')) s (blockchain, url)), txs as(selectdate_trunc('day', block_time) as day,'Ethereum' as blockchain,t."to",count(distinct t."from") as num_addr,count(*) as cnt,sum(cast(gas_price as double) * gas_used) / pow(10, 18) as gasfrom ethereum.transactions twhere ('{{Blockchain}}'= 'All' or '{{Blockchain}}'= 'Ethereum')and (date_trunc('day', block_time) <= (select day from nn)and date_trunc('day', block_time) >= (select day from bb))and (t."to" not in (select contract_address from erc20_ethereum.evt_Approval)and t."to" not in (select contract_address from erc721_ethereum.evt_Approval)and t."to" not in (select contract_address from erc1155_ethereum.evt_ApprovalForAll))-- and t."to" in (select contract_address from ethereum.logs))group by 1, 2, 3union allselectdate_trunc('day', block_time) as day,'Arbitrum' as blockchain,t."to",count(distinct t."from") as num_addr,count(*) as cnt,sum(cast(gas_price as double) * gas_used) / pow(10, 18) as gasfrom arbitrum.transactions twhere ('{{Blockchain}}'= 'All' or '{{Blockchain}}'= 'Arbitrum')and (date_trunc('day', block_time) <= (select day from nn)and date_trunc('day', block_time) >= (select day from bb))and (t."to" not in (select contract_address from erc20_arbitrum.evt_Approval)and t."to" not in (select contract_address from erc721_arbitrum.evt_Approval)and t."to" not in (select contract_address from erc1155_arbitrum.evt_ApprovalForAll))-- and t."to" in (select contract_address from arbitrum.logs))group by 1, 2, 3union all