Query editor
withaddresses as (SELECTtx."from" as wallet, sum(case when tr.block_time >= now() - interval '{{4. Days}}' day then 1 else 0 end) as new_calls, sum(case when tr.block_time < now() - interval '{{4. Days}}' day then 1 else 0 end) as old_calls, count(*) as total_calls, min(tr.block_time) as first_called, arbitrary(tr.tx_hash) as example_hashFROM evms.traces trJOIN (SELECT *, row_number() over (partition by blockchain, address order by created_at desc) as last_submittedFROM evms.contracts) cON c.blockchain = '{{1. Blockchain}}'and c.address = tr.toand last_submitted = 1LEFT JOIN evms.transactions tx ON tr.tx_hash = tx.hash AND tr.blockchain = tx.blockchainLEFT JOIN {{1. Blockchain}}.signatures sig ON bytearray_substring(tr.input,1,4) = sig.id AND sig.name = c.name AND sig.namespace = c.namespaceWHERE tx.successAND tr.blockchain = '{{1. Blockchain}}'and(contains(split(replace('{{3. Contract Addresses}}',' ',''), ','), cast(tr.to as varchar))ORcontains(split('{{2. Namespaces}}', ','), concat(c.namespace, '.', c.name, '_call_', split_part(sig.signature,'(',1))) --concat together with chain and match)group by 1--keep only users that have just hit the threshold in the last X daysHAVING count(*) >= {{5. Minimum Calls}}AND sum(case when tr.block_time < now() - interval '{{4. Days}}' day then 1 else 0 end) < {{5. Minimum Calls}})SELECTget_href(concat(get_chain_explorer('{{1. Blockchain}}'),'/address/',cast(a.wallet as varchar)), COALESCE(ens.name, cast(a.wallet as varchar))) as wallet, a.total_calls, get_href(concat(get_chain_explorer('{{1. Blockchain}}'),'/tx/',cast(example_hash as varchar)), '🔗 tx') as example_hash, '||' as col_, date_diff('day', tt.first_tx_date, now()) as wallet_days_old, tt.txs, tt.blockchains_used, tt.nft_trades, tt.nft_volume_usd, tt.dex_trades, tt.dex_volume_usd, tt.times_cex_funded, array_agg(label.name) as other_labelsFROM addresses aLEFT JOIN dune.dune.result_wallet_all_chain_activity_summary tt ON tt.wallet = a.walletLEFT JOIN labels.addresses label ON label.address = a.wallet AND label.category != 'ENS'LEFT JOIN labels.ens ens ON ens.address = a.walletgroup by 1,2,3,4,5,6,7,8,9,10,11,12order by total_calls desc