Afonso_Diaz2023-10-24 09:56 PM
    Updated 2023-10-24
    with

    t1 as (
    select distinct tx_id
    from sei.core.fact_msg_attributes
    where attribute_key = '_contract_address'
    and msg_type = 'wasm-execute-exchange'
    and attribute_value = 'sei1pdwlx9h8nc3fp6073mweug654wfkxjaelgkum0a9wtsktwuydw5sduczvz'
    and tx_succeeded = 1
    ),

    t2 as (
    select
    tx_id,
    a.block_timestamp,
    a.attribute_value / 1e6 as amount_sei,
    b.attribute_value as seller_address,
    d.tx_from as buyer_address,
    split_part(c.attribute_value, ', ', 1) as tokenid,
    split_part(c.attribute_value, ', ', 2) as nft_address
    from sei.core.fact_msg_attributes a
    join sei.core.fact_msg_attributes b
    using(tx_id, block_timestamp)
    join sei.core.fact_msg_attributes c
    using(tx_id, block_timestamp)
    join sei.core.fact_transactions d
    using(tx_id, block_timestamp)
    where a.attribute_key = 'exchange-token-amount'
    and a.msg_type = 'wasm-accept-request'
    and b.attribute_key = 'seller'
    and b.msg_type = 'wasm-accept-request'
    and b.msg_index = 12
    and c.attribute_key = 'nft'
    and tx_id in (select distinct tx_id from t1)
    ),

    Run a query to Download Data