LTirrellterra_dash:instantiated_contracts-simplified
    Updated 2022-07-07
    with instantiate_info as (
    select
    t.block_timestamp,
    t.tx_id,
    case
    when e.key = 'creator' then t.event_attributes :creator
    when e.key = '0_creator' then t.event_attributes :"0_creator"
    when e.key = '1_creator' then t.event_attributes :"1_creator"
    when e.key = '2_creator' then t.event_attributes :"2_creator"
    end as creator,
    case
    when e.key = 'creator' then t.event_attributes :admin
    when e.key = '0_creator' then t.event_attributes :"0_admin"
    when e.key = '1_creator' then t.event_attributes :"1_admin"
    when e.key = '2_creator' then t.event_attributes :"2_admin"
    end as admin,
    case
    when e.key = 'creator' then t.event_attributes :contract_address
    when e.key = '0_creator' then t.event_attributes :"0_contract_address"
    when e.key = '1_creator' then t.event_attributes :"1_contract_address"
    when e.key = '2_creator' then t.event_attributes :"2_contract_address"
    end as contract_address,
    case
    when e.key = 'creator' then t.event_attributes :code_id
    when e.key = '0_creator' then t.event_attributes :"0_code_id"
    when e.key = '1_creator' then t.event_attributes :"1_code_id"
    when e.key = '2_creator' then t.event_attributes :"2_code_id"
    end as code_id
    from
    terra.msg_events t,
    lateral flatten(input => t.event_attributes) e
    where
    t.event_type = 'instantiate_contract'
    and t.msg_type = 'wasm/MsgInstantiateContract'
    and creator is not NULL
    and tx_status = 'SUCCEEDED'
    Run a query to Download Data