Updated 2024-03-04
    with all_sales_element as (
    select
    block_timestamp,
    tx_hash,
    ORIGIN_FUNCTION_SIGNATURE,
    origin_from_address,
    origin_to_address,
    event_index,
    contract_address as platform_address,
    REGEXP_SUBSTR_ALL(SUBSTR(data, 3, len(data)), '.{64}') as segmented_data,
    concat('0x', substr(segmented_data[1]::string,27,40)) as maker,
    concat('0x', substr(segmented_data[2]::string,27,40)) as taker,
    'ETH' as currency,
    -- concat('0x', substr(segmented_data[4]::string,27,40)) as erc_token,
    livequery.utils.udf_hex_to_int(SUBSTR(segmented_data[5], 3, 64)) :: float as price1,
    concat('0x', substr(segmented_data[7]::string,27,40)) as nft_address,
    livequery.utils.udf_hex_to_int(SUBSTR(segmented_data[8], 3, 64)) as tokenid
    from blast.core.fact_event_logs
    where contract_address = '0x4196b39157659bf0de9ebf6e505648b7889a39ce'
    and topics[0] = '0x9c248aa1a265aa616f707b979d57f4529bb63a4fc34dc7fc61fdddc18410f74e' --nftsale
    union all
    select
    block_timestamp,
    tx_hash,
    ORIGIN_FUNCTION_SIGNATURE,
    origin_from_address,
    origin_to_address,
    event_index,
    contract_address as platform_address,
    REGEXP_SUBSTR_ALL(SUBSTR(data, 3, len(data)), '.{64}') as segmented_data,
    concat('0x', substr(segmented_data[1]::string,27,40)) as maker,
    concat('0x', substr(segmented_data[2]::string,27,40)) as taker,
    concat('0x', substr(segmented_data[4]::string,27,40)) as currency,
    livequery.utils.udf_hex_to_int(SUBSTR(segmented_data[5], 3, 64)) :: float as price1,
    concat('0x', substr(segmented_data[7]::string,27,40)) as nft_address,
    livequery.utils.udf_hex_to_int(SUBSTR(segmented_data[8], 3, 64)) as tokenid
    QueryRunArchived: QueryRun has been archived