Query editor
WITH space_created AS (SELECTSUBSTR(topic1, 13) AS owner,SUBSTR(topic3, 13) AS towns_space,tx_hash /* Get the transaction hash for each space creation */FROM base.logsWHEREcontract_address = 0x9978c826d93883701522d2ca645d5436e5654252AND topic0 = 0xe50fc3942f8a2d7e5a7c8fb9488499eba5255b41e18bc3f1b4791402976d1d0bAND block_time >= CAST('2024-01-01' AS TIMESTAMP)), space_tx_data /* Get transaction data for the space creation transactions */ AS (SELECTs.towns_space,s.owner,t.data AS tx_data, /* Get the full transaction data */t.hash AS tx_hashFROM space_created AS sJOIN base.transactions AS tON s.tx_hash = t.hash), full_tx_data /* Now include the full transaction data */ AS (SELECTtowns_space,owner,tx_hash,TRY_CAST(tx_data AS VARCHAR) AS full_tx_dataFROM space_tx_data), member AS (SELECT*FROM base.logsWHEREtopic0 = 0x2f40b0474996b72a4251e00fb9170cdd960deea1dc749772cbbab61395b9b576AND block_time >= CAST('2024-01-01' AS TIMESTAMP)), towns_members_all AS (SELECTs.*,SUBSTR(member.topic1, 13) AS membersFROM memberRIGHT JOIN space_created AS sON s.towns_space = member.contract_address)SELECTt.towns_space,f.full_tx_data AS full_tx_dataFROM towns_members_all AS tLEFT JOIN full_tx_data AS fON t.towns_space = f.towns_spaceGROUP BYt.towns_space,f.full_tx_dataORDER BYCOUNT(DISTINCT t.members) DESCLIMIT 200000