Query editor
with prices as (SELECTdate_trunc('day',minute) as day,contract_address,symbol,decimals,priceFROM prices.usd_latestWHERE blockchain = 'ethereum'),/* This will give you the sum of transfers in to the wallet */balance as (SELECTe.contract_address,coalesce(cast(t.symbol as VARCHAR),cast(e.contract_address as VARCHAR))as symbol, /* name is referenced in balances */sum(cast(value as double)/power(10,t.decimals)) as value /* name is referenced in balances */FROM erc20_ethereum.evt_Transfer e /* named the table e */INNER JOIN tokens.erc20 t /* named the table t */on e.contract_address = t.contract_address and blockchain = 'ethereum'WHERE to = from_hex('0xf60B82309D90c0c90826266aaa22b00322C2f632')GROUP BY 1,2union all /* this will stack the table generated from the query above to the table generated by the following query *//* This will give you the sum of transfers out of the wallet */SELECTe.contract_address,coalesce(cast(t.symbol as VARCHAR),cast(e.contract_address as VARCHAR))as symbol, /* name is referenced in balances */-sum(cast(value as double)/power(10,t.decimals)) as value /* name is referenced in balances */FROM erc20_ethereum.evt_Transfer e /* named the table e */INNER JOIN tokens.erc20 t /* named the table t */on e.contract_address = t.contract_address and blockchain = 'ethereum'WHERE "from" = from_hex('{{Wallet}}')GROUP BY 1,2),/* This will give you the net balance of tokens in the wallet */balances as (SELECTcontract_address,symbol,sum(value) as token_balanceFROM balanceGROUP BY 1,2),/* This will give you a table with tokens who have a balance >0 */final_balances as (SELECT *FROM balancesWHERE token_balance > 0)/* This will give you the final table */SELECTCONCAT('<a href=https://etherscan.io/address/',cast(b.contract_address as VARCHAR), '/overview" target="_blank" >','0',substring(cast(b.contract_address as VARCHAR)from 2 for 5),'...',substring(cast(b.contract_address as VARCHAR) from 39 for 4),