gleeth/gas
Gas estimation helpers for legacy and EIP-1559 transactions.
These functions combine multiple RPC calls to produce a complete gas estimate that can be passed directly to a transaction builder.
Types
Gas estimate for an EIP-1559 (Type 2) transaction.
pub type Eip1559GasEstimate {
Eip1559GasEstimate(
max_fee_per_gas: String,
max_priority_fee_per_gas: String,
gas_limit: String,
)
}
Constructors
-
Eip1559GasEstimate( max_fee_per_gas: String, max_priority_fee_per_gas: String, gas_limit: String, )
Gas estimate for a legacy (pre-EIP-1559) transaction.
pub type LegacyGasEstimate {
LegacyGasEstimate(gas_price: String, gas_limit: String)
}
Constructors
-
LegacyGasEstimate(gas_price: String, gas_limit: String)
Values
pub fn estimate_eip1559(
provider: provider.Provider,
from: String,
to: String,
value: String,
data: String,
) -> Result(Eip1559GasEstimate, types.GleethError)
Estimate gas for an EIP-1559 transaction by fetching priority fee, base fee from fee history, and gas limit. Computes max_fee = 2 * base_fee + priority_fee.
pub fn estimate_legacy(
provider: provider.Provider,
from: String,
to: String,
value: String,
data: String,
) -> Result(LegacyGasEstimate, types.GleethError)
Estimate gas for a legacy transaction by fetching gas price and gas limit.