Query editor
/*Example of using Byte Array functions + querying the logs tablehttps://dune.com/docs/query/DuneSQL-reference/Functions-and-operators/varbinary/bytearray_substring - Returns a suffix byte array or string starting at a given indexbytearray_to_int256 - Returns the INT256 of a big-endian byte array of length <= 32 representing the signed integer.If the byte array has length < 32 it is padded with zero bytes.bytearray_to_uint256 - Returns the UINT256 of a big-endian byte array of length <= 32 representing the unsigned integer.If the byte array has length < 32 it is padded with zero bytes.from_utf8 - Returns the string of bytearray*/-- logs table as sourceselect 'logs table' as source,block_time,tx_hash,topic1 as trackingCode,from_utf8(topic1) as trackingCode_readable, -- converting bytearray to readable stringbytearray_substring(data,1,32) as baseAsset,from_utf8(bytearray_substring(data,1,32)) as baseAsset_readable, -- converting bytearray to readable string(bytearray_substring(data,33,32)) as marketKey,from_utf8((bytearray_substring(data,33,32))) as marketKey_readable, -- converting bytearray to readable stringbytearray_to_int256(bytearray_substring(data,65,32)) as sizeDelta_int256, -- converting bytearray to int256 (allows negative values)bytearray_to_uint256(bytearray_substring(data,97,32)) as fee_uint256 -- converting bytearray to uint256 (positive values only)from optimism.logswhere contract_address = 0xa1ace9ce6862e865937939005b1a6c5ac938a11fand topic0 = 0xc9d5ada2ea384fe04826ecd1b258955ac73c3e2e20d755108eafde90bc5588d4and tx_hash IN (0x3e3c558e7f723e3bb7de1d8f5f920ca206e3e878984296a2b8e6af2969003a19,0xccfd2033adfb1fdd14fdfc047fe554ba7549e396abc6c559e9528a4259295b89) -- querying the same transaction hashUNION ALL-- querying the same result from the decoded tablesSELECT 'decoded table' as source,evt_block_time,evt_tx_hash,trackingCode,from_utf8(bytearray_rtrim(trackingCode)) as trackingCode_readable,baseAsset,from_utf8(baseAsset) as baseAsset_readable,marketKey,from_utf8(marketKey) as marketKey_readable,sizeDelta,feefrom synthetix_futuresmarket_optimism.ProxyPerpsV2_evt_PerpsTrackingwhere evt_tx_hash IN (0x3e3c558e7f723e3bb7de1d8f5f920ca206e3e878984296a2b8e6af2969003a19,0xccfd2033adfb1fdd14fdfc047fe554ba7549e396abc6c559e9528a4259295b89) -- querying the same transaction hashORDER BY 2 DESC