Query editor
with stable_coin as (select 0xdAC17F958D2ee523a2206206994597C13D831ec7 as address, 'USDT' as name, 6 as decimalsUNION SELECT 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 as address, 'USDC' as name, 6 as decimalsUNION SELECT 0x6b175474e89094c44da98b954eedeac495271d0f as address, 'DAI' as name, 18 as decimalsUNION SELECT 0x4Fabb145d64652a948d72533023f6E7A623C7C53 as address, 'BUSD' as name, 18 as decimalsUNION SELECT 0x0000000000085d4780B73119b644AE5ecd22b376 as address, 'TUSD' as name, 18 as decimals),-- 疑似受害者,may_victim as (SELECT c.*from(SELECT a.*,b.name,b.decimalsfrom(SELECT block_time,block_number,contract_address,topic1,topic2,tx_hash,bytearray_to_uint256(data) as datafrom ethereum.logswhere topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efand block_time>cast('2022-07-15 00:00' as TIMESTAMP)and contract_address in (select address from stable_coin)and length(data)=32and data!=0x0000000000000000000000000000000000000000000000000000000000000000) ajoin(select * from stable_coin) bon a.contract_address=b.addresswhere data > cast(power(10,decimals)*2 as uint256)) cjoin (select hashfrom ethereum.transactionswhere to in (select address from stable_coin)and substr(data, 1, 4) = 0xa9059cbb) don c.tx_hash=d.hash),attack_info as(SELECT distinct a.block_time,name, substr(a.topic1,13,20) as victim, substr(b.topic2,13,20) as attacker, a.tx_hash as origin_txhash, b.tx_hash as attack_txhash, a.data as origin_data, decimalsfrom may_victim ajoin(SELECT block_time,block_number,contract_address,topic1,topic2,tx_hash,bytearray_to_uint256(data) as datafrom ethereum.logswhere topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efand block_time>cast('2022-07-15 00:00' as TIMESTAMP)and contract_address not in (select address from stable_coin)and length(data)=32and data!=0x0000000000000000000000000000000000000000000000000000000000000000) bon a.topic1=b.topic1 and b.block_number>=a.block_number and b.block_number-a.block_number<100 and a.data=b.dataand substr(a.topic2,13,1)=substr(b.topic2,13,1) and substr(a.topic2,32,1)=substr(b.topic2,32,1) and a.topic2!=b.topic2ORDER by block_time desc)-- select distinct attacker,nonce-- from (select attacker-- from attack_info-- where attacker not in (select address from ethereum.creation_traces)) a-- join (select "from",max(nonce) as nonce-- from ethereum.transactions-- where block_time>cast('2022-07-15 00:00' as TIMESTAMP)-- group by "from") b-- on a.attacker=b."from"-- where nonce>=10-- union