Query editor
/*There are four types of transactions: -- https://ethereum.org/en/developers/docs/transactions/#typed-transaction-envelope0 = legacy1 = AccessList (EIP 2930)2 = EIP 15593 = Blob -- https://www.blocknative.com/blog/eip-4844-blobs-and-blob-gas-what-you-need-to-knowNote: blob transaction gas cost != gas cost used in blobs -- because blob data fee is only <1% of gas fee used by these transactions with blobsThe same logic also applies to AccessList, as the cost of AccessList constitutes part of the transaction gas cost that is type 1*/select date_trunc('week', block_time) as time, "type", sum(fees) as fees, sum(fees * pu.price) as fees_usd, count(distinct hash) as cntfrom (SELECT t.block_time, case when "type" = 'Legacy' then '0: Legacy'when "type" = 'AccessList' then '1: AccessList'when "type" = 'DynamicFee' then '2: EIP-1559'when "type" = '3' then '3: Blob'when "type" = 'EIP-7702' then '4: EIP-7702'end as "type", CASE WHEN t."type"='Legacy' or t."type"='AccessList' THEN CAST(t.gas_used/1e18 AS double) * t.gas_price -- for legacy transactions and AL transactions (AL txn gas_price already has AL cost considered)WHEN t."type"='DynamicFee' or t."type"='EIP-7702' THEN CAST(t.gas_used/1e18 AS double) * t.gas_price -- for EIP-1559 transactions | (b.base_fee_per_gas + t.priority_fee_per_gas) -- no need because effectiveGasPrice Dune used to fill gas_price field already does thisWHEN t."type"='3' THEN CAST(t.gas_used/1e18 AS double) * t.gas_price + cardinality(blob_versioned_hashes)*power(2, 17) * gp.blob_base_fee/1e18 -- for Blob transactions, need to add blob data fee | 2^17 is because each blob stores 128KB of data which is 131072 bytes which is 2^17 bytesEND AS fees, t.hashFROM ethereum.transactions tINNER JOIN ethereum.blocks b ON t.block_number = b.numberLEFT JOIN dune.resident_wizards.dataset_blob_base_fees_lookup gp USING (excess_blob_gas) --https://dune.com/queries/3521876LEFT JOIN beacon.blobs blob on blob.parent_root = b.parent_beacon_block_root and blob.block_date = b.date)LEFT JOIN prices.usd pu ON pu.blockchain IS NULLAND pu.symbol='ETH'AND pu.minute=date_trunc('minute', block_time)Where block_time between now() - interval '1' year AND date_trunc('week', NOW())group by 1,2