@tevm/voltaire / primitives/EffectiveGasPrice
primitives/EffectiveGasPrice
Type Aliases
EffectiveGasPriceType
EffectiveGasPriceType =Defined in: src/primitives/EffectiveGasPrice/EffectiveGasPriceType.ts:10 Branded EffectiveGasPrice type - EIP-1559 effective gas price Represents the actual gas price paid in a transaction Calculated as: min(baseFee + priorityFee, maxFeePerGas)bigint&object
Type Declaration
[brand]
readonly[brand]:"EffectiveGasPrice"
See
https://eips.ethereum.org/EIPS/eip-1559Variables
EffectiveGasPrice
Defined in: src/primitives/EffectiveGasPrice/index.ts:54constEffectiveGasPrice:object
Type Declaration
calculate()
calculate: (Calculate effective gas price from EIP-1559 fee parameters Formula: min(baseFee + min(maxPriorityFee, maxFee - baseFee), maxFee)baseFee,maxFee,maxPriorityFee) =>EffectiveGasPriceType
Parameters
baseFee
bigint
Base fee per gas
maxFee
bigint
Maximum fee per gas
maxPriorityFee
bigint
Maximum priority fee per gas
Returns
EffectiveGasPriceType
Effective gas price
Example
compare()
compare: (effectivePrice1,effectivePrice2) =>number
Parameters
effectivePrice1
string | number | bigint
effectivePrice2
string | number | bigint
Returns
number
equals()
equals: (effectivePrice1,effectivePrice2) =>boolean
Parameters
effectivePrice1
string | number | bigint
effectivePrice2
string | number | bigint
Returns
boolean
from()
from: (Create EffectiveGasPrice from bigint, number, or hex stringvalue) =>EffectiveGasPriceType
Parameters
value
Effective price in Weistring | number | bigint
Returns
EffectiveGasPriceType
Branded effective gas price
Throws
If value is negative or invalid formatExample
fromGwei()
fromGwei: (Create EffectiveGasPrice from Gwei valuegwei) =>EffectiveGasPriceType
Parameters
gwei
Value in Gweinumber | bigint
Returns
EffectiveGasPriceType
Effective price in Wei
Example
fromWei()
fromWei: (Create EffectiveGasPrice from Wei value (alias for from)wei) =>EffectiveGasPriceType
Parameters
wei
Value in Weistring | number | bigint
Returns
EffectiveGasPriceType
Effective price
Example
toBigInt()
toBigInt: (effectivePrice) =>bigint
Parameters
effectivePrice
string | number | bigint
Returns
bigint
toGwei()
toGwei: (effectivePrice) =>bigint
Parameters
effectivePrice
string | number | bigint
Returns
bigint
toNumber()
toNumber: (effectivePrice) =>number
Parameters
effectivePrice
string | number | bigint
Returns
number
toWei()
toWei: (effectivePrice) =>bigint
Parameters
effectivePrice
string | number | bigint
Returns
bigint
Functions
_compare()
_compare(Defined in: src/primitives/EffectiveGasPrice/compare.js:15 Compare two EffectiveGasPrice valuesthis,other):number
Parameters
this
EffectiveGasPriceType
other
EffectiveGasPriceType
Value to compare
Returns
number
-1 if this < other, 0 if equal, 1 if this > other
Example
_equals()
_equals(Defined in: src/primitives/EffectiveGasPrice/equals.js:15 Check if two EffectiveGasPrice values are equalthis,other):boolean
Parameters
this
EffectiveGasPriceType
other
EffectiveGasPriceType
Value to compare
Returns
boolean
True if equal
Example
_toBigInt()
_toBigInt(Defined in: src/primitives/EffectiveGasPrice/toBigInt.js:13 Convert EffectiveGasPrice to bigint (identity function)this):bigint
Parameters
this
EffectiveGasPriceType
Returns
bigint
Value as bigint
Example
_toGwei()
_toGwei(Defined in: src/primitives/EffectiveGasPrice/toGwei.js:13 Convert EffectiveGasPrice to Gweithis):bigint
Parameters
this
EffectiveGasPriceType
Returns
bigint
Value in Gwei
Example
_toNumber()
_toNumber(Defined in: src/primitives/EffectiveGasPrice/toNumber.js:14 Convert EffectiveGasPrice to number WARNING: May lose precision for large valuesthis):number
Parameters
this
EffectiveGasPriceType
Returns
number
Value as number
Example
_toWei()
_toWei(Defined in: src/primitives/EffectiveGasPrice/toWei.js:13 Convert EffectiveGasPrice to Wei (identity function)this):bigint
Parameters
this
EffectiveGasPriceType
Returns
bigint
Value in Wei
Example
calculate()
calculate(Defined in: src/primitives/EffectiveGasPrice/calculate.js:19 Calculate effective gas price from EIP-1559 fee parameters Formula: min(baseFee + min(maxPriorityFee, maxFee - baseFee), maxFee)baseFee,maxFee,maxPriorityFee):EffectiveGasPriceType
Parameters
baseFee
bigint
Base fee per gas
maxFee
bigint
Maximum fee per gas
maxPriorityFee
bigint
Maximum priority fee per gas
Returns
EffectiveGasPriceType
Effective gas price
Example
compare()
compare(Defined in: src/primitives/EffectiveGasPrice/index.ts:43effectivePrice1,effectivePrice2):number
Parameters
effectivePrice1
string | number | bigint
effectivePrice2
string | number | bigint
Returns
number
equals()
equals(Defined in: src/primitives/EffectiveGasPrice/index.ts:36effectivePrice1,effectivePrice2):boolean
Parameters
effectivePrice1
string | number | bigint
effectivePrice2
string | number | bigint
Returns
boolean
from()
from(Defined in: src/primitives/EffectiveGasPrice/from.js:16 Create EffectiveGasPrice from bigint, number, or hex stringvalue):EffectiveGasPriceType
Parameters
value
Effective price in Weistring | number | bigint
Returns
EffectiveGasPriceType
Branded effective gas price
Throws
If value is negative or invalid formatExample
fromGwei()
fromGwei(Defined in: src/primitives/EffectiveGasPrice/fromGwei.js:12 Create EffectiveGasPrice from Gwei valuegwei):EffectiveGasPriceType
Parameters
gwei
Value in Gweinumber | bigint
Returns
EffectiveGasPriceType
Effective price in Wei
Example
fromWei()
fromWei(Defined in: src/primitives/EffectiveGasPrice/fromWei.js:12 Create EffectiveGasPrice from Wei value (alias for from)wei):EffectiveGasPriceType
Parameters
wei
Value in Weistring | number | bigint
Returns
EffectiveGasPriceType
Effective price
Example
toBigInt()
toBigInt(Defined in: src/primitives/EffectiveGasPrice/index.ts:32effectivePrice):bigint
Parameters
effectivePrice
string | number | bigint
Returns
bigint
toGwei()
toGwei(Defined in: src/primitives/EffectiveGasPrice/index.ts:20effectivePrice):bigint
Parameters
effectivePrice
string | number | bigint
Returns
bigint
toNumber()
toNumber(Defined in: src/primitives/EffectiveGasPrice/index.ts:28effectivePrice):number
Parameters
effectivePrice
string | number | bigint
Returns
number
toWei()
toWei(Defined in: src/primitives/EffectiveGasPrice/index.ts:24effectivePrice):bigint
Parameters
effectivePrice
string | number | bigint
Returns
bigint
