freemartianSoccer League Popularity
    Updated 2022-08-22
    with source as (
    select
    regexp_substr_all(SUBSTR(data, 11, len(data)), '.{64}') AS segmented_data,
    concat('0x', substr(segmented_data[0], 17, 40)) as game,
    ethereum.public.udf_hex_to_int(substr(segmented_data[17], 1, 56) :: STRING) :: FLOAT as sport_tag
    from optimism.core.fact_event_logs
    where origin_function_signature = '0xac2c957c'
    and origin_to_address = '0x2b91c14ce9aa828ed124d12541452a017d8a2148'
    and topics[0] = '0x889e2060e46779287c2fcbf489c195ef20f5b44a74e3dcb58d491ae073c1370f'),

    game_sport as (
    select
    game,
    case
    when sport_tag = '9002' then 'NFL'
    when sport_tag = '9003' then'Baseball'
    when sport_tag = '9007' then 'MMA'
    when sport_tag = '9010' then 'MLS'
    when sport_tag = '9015' then 'Serie A'
    when sport_tag = '9012' then 'League 1'
    when sport_tag = '9013' then 'Bundesliga'
    when sport_tag = '9014' then 'La liga'
    when sport_tag = '9011' then 'EPL'
    end as sport
    from source),

    bet_transactions as (
    select
    distinct ft.tx_hash as tx,
    tt.contract_address as currency,
    regexp_substr_all(SUBSTR(input_data, 11, len(input_data)), '.{64}') AS segmented_data,
    concat('0x', substr(segmented_data[0], 25, 40)) as game,
    ethereum.public.udf_hex_to_int(segmented_data[3] :: STRING) :: FLOAT as paid_bet,
    ft.from_address as bettor,
    case
    when currency = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' then sum(paid_bet)/pow(10,18)
    Run a query to Download Data