pub struct GasBreakdown {
pub execution_gas_cost: U256,
pub blob_gas_cost: U256,
pub l1_data_fee: U256,
pub blob_count: BlobCount,
pub blob_gas_price: BlobGasPrice,
}Expand description
Detailed breakdown of gas costs for a transaction
Separates execution gas, blob gas, and L1 data fees for comprehensive analytics and cost attribution.
§Example
use alloy_primitives::U256;
use semioscan::{GasBreakdown, BlobGasPrice};
let breakdown = GasBreakdown::builder()
.execution_gas_cost(U256::from(1_000_000_000_000_000u64))
.blob_gas_cost(U256::from(500_000_000_000_000u64))
.build();
assert_eq!(
breakdown.total_cost(),
U256::from(1_500_000_000_000_000u64)
);Fields§
§execution_gas_cost: U256Cost for regular execution gas (gas_used * effective_gas_price)
blob_gas_cost: U256Cost for blob gas (blob_gas_used * blob_gas_price) - EIP-4844 only
l1_data_fee: U256L1 data fee for OP-stack chains (Optimism, Base, etc.)
blob_count: BlobCountNumber of blobs in the transaction (0 for non-EIP-4844)
blob_gas_price: BlobGasPriceBlob gas price used for this transaction
Implementations§
Source§impl GasBreakdown
impl GasBreakdown
Sourcepub fn builder() -> GasBreakdownBuilder
pub fn builder() -> GasBreakdownBuilder
Create a builder for constructing a gas breakdown
Sourcepub fn total_cost(&self) -> U256
pub fn total_cost(&self) -> U256
Calculate total cost (execution + blob + L1 data fee)
Sourcepub fn has_blob_gas(&self) -> bool
pub fn has_blob_gas(&self) -> bool
Check if this transaction used blob gas (is EIP-4844)
Sourcepub fn has_l1_data_fee(&self) -> bool
pub fn has_l1_data_fee(&self) -> bool
Check if this transaction has L1 data fees (is on an L2)
Trait Implementations§
Source§impl Add for GasBreakdown
impl Add for GasBreakdown
Source§impl Clone for GasBreakdown
impl Clone for GasBreakdown
Source§fn clone(&self) -> GasBreakdown
fn clone(&self) -> GasBreakdown
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GasBreakdown
impl Debug for GasBreakdown
Source§impl Default for GasBreakdown
impl Default for GasBreakdown
Source§fn default() -> GasBreakdown
fn default() -> GasBreakdown
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for GasBreakdown
impl<'de> Deserialize<'de> for GasBreakdown
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for GasBreakdown
impl Display for GasBreakdown
Source§impl PartialEq for GasBreakdown
impl PartialEq for GasBreakdown
Source§impl Serialize for GasBreakdown
impl Serialize for GasBreakdown
impl Copy for GasBreakdown
impl Eq for GasBreakdown
impl StructuralPartialEq for GasBreakdown
Auto Trait Implementations§
impl Freeze for GasBreakdown
impl RefUnwindSafe for GasBreakdown
impl Send for GasBreakdown
impl Sync for GasBreakdown
impl Unpin for GasBreakdown
impl UnwindSafe for GasBreakdown
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.