Query editor
WITH action_events AS (SELECTblock_time,block_number,-- First 32 bytes is the log typebytearray_to_uint256(bytearray_substring(data, 1, 32)) as log_type,CASE bytearray_to_uint256(bytearray_substring(data, 1, 32))WHEN 101 THEN 'ACTION_PROPOSE'WHEN 201 THEN 'ACTION_SET'WHEN 301 THEN 'ACTION_CANCEL'WHEN 401 THEN 'ACTION_DISPOSE'END as event_type,-- ActionId: skip header (32) + offset (32) + length (32) = 96 bytes'0x' || SUBSTRING(CAST(bytearray_substring(data, 97, 4) AS varchar), 3) as action_id,-- Address: skip header (32) + offset (32) + length (32) + actionId+padding (32) = 128 bytes'0x' || SUBSTRING(CAST(bytearray_substring(data, 129, 32) AS varchar), 27, 40) as action_addressFROM ethereum.logsWHEREtopic0 = 0xc580531c0d70bc831ea0e492033aa55ca4001fbe1b6d400060a026374db2afddAND contract_address = 0x99A055251170411c4505519aaeC57020B6129BB8AND bytearray_to_uint256(bytearray_substring(data, 1, 32)) IN (101, 201, 301, 401) -- Only action events),active_actions AS (SELECT DISTINCTae.action_id,ae.action_address,ae.block_number as added_at_block,ae.block_time as added_timestampFROM action_events aeWHERE ae.event_type = 'ACTION_SET'AND NOT EXISTS (-- Check if the action was disposed after being setSELECT 1FROM action_events ae2WHERE ae2.action_address = ae.action_addressAND ae2.event_type = 'ACTION_DISPOSE'AND ae2.block_number > ae.block_number))SELECTadded_timestamp,added_at_block,action_id,action_addressFROM active_actionsORDER BY added_at_block DESC;