brian-terraRandomEarth Listings
    Updated 2021-12-18
    WITH
    allNFTs as (
    select msg_value:execute_msg:mint_nft:token_id::string AS tokenid,
    substr(msg_value:execute_msg:mint_nft:token_id::string,1,12) AS truncTokenID
    from terra.msgs
    where msg_value:contract::string = 'terra16wuzgsx3tz4hkqu73q5s7unxenefkkvefvewsh'
    and tx_status = 'SUCCEEDED'
    and msg_value:execute_msg:mint_nft is not null
    ),
    orders AS (
    select block_timestamp,
    tx_id,
    replace(substr(event_attributes:token_id::string,1,13),'.','') AS Etokenid,
    event_attributes:order:order:taker_asset:amount::float / 1e6 AS amount,
    'post_order' as tx_type
    from terra.msg_events
    where tx_status = 'SUCCEEDED'
    and event_type = 'wasm'
    and event_attributes:"0_contract_address"::string = 'terra103z9cnqm8psy0nyxqtugg6m7xnwvlkqdzm4s4k'
    and event_attributes:"1_contract_address"::string = 'terra1eek0ymmhyzja60830xhzm7k7jkrk99a60q2z2t'
    and event_attributes:order:order:expiration::datetime > getdate()::datetime
    UNION
    select block_timestamp,
    tx_id,
    replace(substr(event_attributes:order:order:maker_asset:info:nft:token_id::string,1,13),'.','') AS Etokenid,
    event_attributes:order:order:taker_asset:amount::float / 1e6 as amount,
    'post_order' as tx_type
    from terra.msg_events
    where tx_status = 'SUCCEEDED'
    and event_type = 'wasm'
    Run a query to Download Data