tendroGet Goons & Gangster
    Updated 2024-07-26
    WITH parsed_data AS (
    SELECT
    from_address,
    -- Extract and convert `_typeA` from the input_data (first 32 bytes after the function signature)
    utils.udf_hex_to_int(SUBSTR(input_data, 11, 64)) AS type_a,
    -- Extract and convert `_amount` from the input_data (next 32 bytes after `_typeA`)
    utils.udf_hex_to_int(SUBSTR(input_data, 75, 64)) AS amount
    FROM
    blast.core.fact_transactions
    WHERE
    origin_function_signature = LOWER('0x5b262a77')
    AND to_address = LOWER('0x1f06467e9046acff001270a9bf38c7c289ff0e4e') -- Replace with the actual contract address
    )
    SELECT
    from_address,
    -- Use CASE to map type_a to descriptive names
    CASE
    WHEN type_a = 0 THEN 'Gangster'
    WHEN type_a = 1 THEN 'Goon'
    ELSE 'Other' -- Default case for any other type_a values
    END AS type_name,
    -- Calculate the total amount for each type_a
    SUM(amount) AS total_amount,
    -- Count the number of transactions for each type_a
    COUNT(*) AS transaction_count
    FROM
    parsed_data
    GROUP BY
    from_address,
    type_name
    ORDER BY
    from_address,
    type_name;

    QueryRunArchived: QueryRun has been archived