Query editor
WITH details AS (SELECT0x6c84a8f1c29108F47a79964b5Fe888D4f4D0dE40 AS token, /* tBTC token address on Arbitrum */18 AS dec /* Decimal precision for tBTC */), transfer1 AS (SELECTt.contract_address,t."to" AS address, /* Focusing on the 'to' field for destination addresses */t.evt_tx_hash AS sourceTxHash,et.block_time AS initiatedAt_UTC,'Arbitrum' AS sourceChain, /* Assuming transfers are on the Arbitrum chain */'Arbitrum' AS destChain, /* Same assumption for the destination chain */t."from" AS sourceWallet, /* The Wormhole contract is now the source */TRY_CAST(t.value AS DOUBLE) / POWER(10, d.dec) AS amount,et.data AS transactionData /* Fetching the data column from transactions */FROM erc20_arbitrum.evt_Transfer AS t /* Adjusted for Arbitrum's ERC-20 transfer events */JOIN arbitrum.transactions AS etON t.evt_tx_hash = et.hash /* Adjusted for Arbitrum's transaction table */LEFT JOIN details AS dON t.contract_address = d.tokenWHEREt.contract_address = d.tokenAND t."from" = 0x0000000000000000000000000000000000000000 /* Filtering for Wormhole contract as the sender on Arbitrum */)SELECTROW_NUMBER() OVER (ORDER BY sub.balance_amount DESC) AS Rank_id,sub.initiatedAt_UTC AS initiatedAt_UTC,sub.destinationWallet AS destinationWallet, /* Now the recipient wallets */sub.sourceTxHash AS sourceTxHash,sub.sourceChain AS sourceChain,sub.destChain AS destChain,sub.sourceWallet AS sourceWallet, /* Wormhole contract as source */CAST(sub.tBTC_amt AS DECIMAL(18,6)) AS tBTC_amt,sub.transactionData /* Include the data column in your final selection */FROM (SELECTtt.address AS destinationWallet,tt.sourceTxHash AS sourceTxHash,tt.initiatedAt_UTC AS initiatedAt_UTC,tt.sourceChain AS sourceChain,tt.destChain AS destChain,tt.sourceWallet AS sourceWallet, /* Wormhole contract */SUM(tt.amount) AS balance_amount,tt.amount AS tBTC_amt,tt.transactionData /* Carry the data column through to the subquery */FROM transfer1 AS ttGROUP BYtt.address,tt.sourceTxHash,tt.initiatedAt_UTC,tt.sourceChain,tt.destChain,tt.sourceWallet,tt.amount,tt.transactionData /* Grouping by transactionData */) AS subORDER BYbalance_amount DESC