Query editor
selectcount(*) as txs,sum(case when success is null or success then 1 else 0 end) as txs_success,sum(case when success is not null and not success then 1 else 0 end) as txs_failed,sum(case when "to" is null then 1 else 0 end) as txs_deploys,sum(case when "to" is not null and coalesce(length(data), 0) > 0 then 1 else 0 end) as txs_to_contracts,sum(case when "to" is not null and value > 0 and coalesce(length(data), 0) = 0 then 1 else 0 end) as txs_eth_transfers,sum(case when substring(data from 1 for 4) in ('\xa9059cbb', '\x095ea7b3', '\x23b872dd') then 1 else 0 end) as txs_token_transfers,sum(gas_used) as gas_used,sum(case when success then gas_used else 0 end) as gas_success,sum(case when success then 0 else gas_used end) as gas_failed,sum(case when "to" is null then gas_used else 0 end) as gas_deploys,sum(gas_used * gas_price / 1e18) as eth_spent,sum(case when success then gas_used * gas_price / 1e18 else 0 end) as eth_success,sum(case when success then 0 else gas_used * gas_price / 1e18 end) as eth_failed,sum(case when "to" is null then gas_used * gas_price / 1e18 else 0 end) as eth_deploys,sum(gas_used * gas_price * price / 1e18) as usd_spent,sum(case when success then gas_used * gas_price * price / 1e18 else 0 end) as usd_success,sum(case when success then 0 else gas_used * gas_price * price / 1e18 end) as usd_failed,sum(case when "to" is null then gas_used * gas_price * price / 1e18 else 0 end) as usd_deploys,count(distinct case when coalesce(length(data), 0) > 0 then "to" else null end) as contracts_used,count(distinct case when "to" is not null and value > 0 and coalesce(length(data), 0) = 0 then "to" else null end) as eth_receivers,count(distinct case when substring(data from 1 for 4) in ('\xa9059cbb', '\x095ea7b3', '\x23b872dd') then "to" else null end) as tokens_used,count(distinct casewhen coalesce(length(data), 0) = 68 and substring(data from 1 for 4) in ('\xa9059cbb') then substring(data from 17 for 36)when coalesce(length(data), 0) = 100 and substring(data from 1 for 4) in ('\x23b872dd') then substring(data from 49 for 68)else null end) as tokens_receiversfrom ethereum.transactionsleft join prices.usd on symbol = 'ETH' and minute = date_trunc('minute', block_time)where "from" IN (SELECT dune_user_generated.get_address_from_ens_or_address(wallets) FROM UNNEST(split('{{wallet}}', ',')) as wallets)-- case-- when '{{wallet}}' like '0x________________________________________'-- then decode(substring('{{wallet}}' from 3 for 40), 'hex')-- else (-- select owner from (-- SELECT name, owner, evt_block_time, '1970-01-01'::timestamp + expires * interval '1 seconds', evt_tx_hash, 1*2^64 + extract(epoch from evt_block_time)::numeric as sort_priority FROM ethereumnameservice."ETHRegistrarController_1_evt_NameRegistered" UNION ALL-- SELECT name, owner, evt_block_time, '1970-01-01'::timestamp + expires * interval '1 seconds', evt_tx_hash, 1*2^64 + extract(epoch from evt_block_time)::numeric as sort_priority FROM ethereumnameservice."ETHRegistrarController_2_evt_NameRegistered" UNION ALL-- SELECT name, owner, evt_block_time, '1970-01-01'::timestamp + expires * interval '1 seconds', evt_tx_hash, 1*2^64 + extract(epoch from evt_block_time)::numeric as sort_priority FROM ethereumnameservice."ETHRegistrarController_3_evt_NameRegistered" UNION ALL-- select '0x' || encode(numeric2bytea(id::numeric, 32, false), 'hex') as name, owner, evt_block_time, '1970-01-01'::timestamp + expires * interval '1 seconds', evt_tx_hash, 1*2^64 + extract(epoch from evt_block_time)::numeric from ethereumnameservice."BaseRegistrarImplementation_evt_NameRegistered" union all-- select name, "from", call_block_time, expires, call_tx_hash, 2*2^64 + extract(epoch from call_block_time)::numeric as sort_priority from (-- select name, call_block_time, call_block_time + duration * interval '1 seconds' as expires, call_tx_hash from ethereumnameservice."ETHRegistrarController_1_call_renew" where call_success union all-- select name, call_block_time, call_block_time + duration * interval '1 seconds' as expires, call_tx_hash from ethereumnameservice."ETHRegistrarController_2_call_renew" where call_success union all-- select name, call_block_time, call_block_time + duration * interval '1 seconds' as expires, call_tx_hash from ethereumnameservice."ETHRegistrarController_3_call_renew" where call_success union all-- select '0x' || encode(numeric2bytea(id::numeric, 32, false), 'hex') as name, call_block_time, call_block_time + duration * interval '1 seconds', call_tx_hash from ethereumnameservice."BaseRegistrarImplementation_call_renew"-- ) t-- left join ethereum.transactions tx on t.call_tx_hash = tx.hash-- ) tt-- where name = '{{wallet}}' or name || '.eth' = '{{wallet}}'-- order by sort_priority-- limit 1-- ) end