prbhvgupta2023-12-12 03:33 PM
    with traces_initial as (
    select
    date(block_timestamp) as date,
    tx_hash as transaction_hash ,
    from_address as "from",
    to_address as "to",
    eth_value as value,
    'call' as trace_type,
    (case when trace_status = 'SUCCESS' then true else false end) as success,
    type as call_type
    from OPTIMISM.CORE.FACT_TRACES tr
    where 1=1
    -- and date(block_timestamp) in ('2023-10-01','2023-10-02')
    --and trace_type = 'call'
    and date >= '2023-11-23'
    and trace_status = 'SUCCESS'
    and (type not in ('DELEGATECALL', 'STATICCALL', 'CALLCODE'))
    order by trace_index asc

    ),

    transfer_in as (
    select
    date,
    transaction_hash,
    "to" as address,
    sum(value) as eth_in
    from traces_initial
    -- AND cast(value as double) > 0
    group by 1,2,3
    ),
    transfer_out as (
    select
    date,
    transaction_hash,
    "from" as address,
    Run a query to Download Data