Query editor
WITHparams AS (SELECT0xa8a30e0dafca4156f28d96cca5671a0eeca5e407 AS contract_address,4500000 AS total_tipping_allocation,10000 AS max_tipping_allocation_per_wallet),erc20_balances AS (WITHerc20_in AS (SELECTto AS wallet,SUM(CAST(tr.value AS DOUBLE)) as token_fundedFROMerc20_base.evt_Transfer tr,paramsWHEREtr.contract_address = params.contract_addressGROUP BYto),erc20_out AS (SELECT"from" AS wallet,SUM(CAST(tr.value AS DOUBLE)) as token_spentFROMerc20_base.evt_Transfer tr,paramsWHEREtr.contract_address = params.contract_addressGROUP BY"from")SELECTerc20_in.wallet,token_funded - COALESCE(token_spent, 0) AS balanceFROMerc20_inLEFT JOIN erc20_out ON erc20_in.wallet = erc20_out.wallet),total_balance AS (SELECTSUM(balance) AS totalFROMerc20_balances),profile AS (SELECTprofile.fid,profile.fname,profile.display_name,profile.avatar_url,fids_address.address AS wallet_addressFROMdune.neynar.dataset_farcaster_profile_with_addresses profileLEFT JOIN query_3464901 fids_address ON fids_address.fid = profile.fid),single_profile AS (SELECT distinctfid,