CartanGroup⛽️ Aptos Gas Guzzlers (APT Fees)
    Updated 2023-12-01
    with

    payload_txs as (

    select
    block_timestamp
    , version
    , split(payload_function, '::')[0] as smart_contract
    , split(payload_function, '::')[1] as module
    , split(payload_function, '::')[2] as function
    , payload
    , payload_function
    , payload :type ::string as payload_type
    , gas_used
    , gas_unit_price
    , (gas_used * gas_unit_price) / pow(10,8) as fee_apt
    , ifnull(label, 'unlabeled') as label
    from aptos.core.fact_transactions
    left join aptos.core.dim_labels
    on split(fact_transactions.payload_function, '::')[0] = dim_labels.address
    where tx_type = 'user_transaction'
    and block_timestamp ::date > current_date() -30
    ),

    aggregated as (

    select

    case
    when payload_type in ('script_payload', 'multisig_payload') then payload_type
    when smart_contract in ('0x1', '0x3') then 'aptos_core_contracts'
    else smart_contract
    end as smart_contract
    , case
    Run a query to Download Data