@tevm/voltaire / primitives/GasEstimate
primitives/GasEstimate
Type Aliases
GasEstimateType
GasEstimateType =Defined in: src/primitives/GasEstimate/GasEstimateType.ts:8 Branded GasEstimate type - estimated gas for transaction Returned by eth_estimateGas RPC method Should add buffer (20-30%) for actual transactionbigint&object
Type Declaration
[brand]
readonly[brand]:"GasEstimate"
Variables
GasEstimate
Defined in: src/primitives/GasEstimate/index.ts:67constGasEstimate:object
Type Declaration
compare()
compare: (value1,value2) =>number
Parameters
value1
string | number | bigint
value2
string | number | bigint
Returns
number
equals()
equals: (value1,value2) =>boolean
Parameters
value1
string | number | bigint
value2
string | number | bigint
Returns
boolean
from()
from: (Create GasEstimate from number, bigint, or stringvalue) =>GasEstimateType
Parameters
value
Gas estimate valuestring | number | bigint
Returns
GasEstimateType
Branded gas estimate
Throws
If value is negativeExample
toBigInt()
toBigInt: (value) =>bigint
Parameters
value
string | number | bigint
Returns
bigint
toGasLimit()
toGasLimit: (estimate) =>bigint
Parameters
estimate
string | number | bigint
Returns
bigint
toHex()
toHex: (value) =>string
Parameters
value
string | number | bigint
Returns
string
toNumber()
toNumber: (value) =>number
Parameters
value
string | number | bigint
Returns
number
withBuffer()
withBuffer: (estimate,percentageBuffer) =>GasEstimateType
Parameters
estimate
string | number | bigint
percentageBuffer
number
Returns
GasEstimateType
Functions
_compare()
_compare(Defined in: src/primitives/GasEstimate/compare.js:15 Compare two GasEstimate valuesthis,other):number
Parameters
this
GasEstimateType
other
GasEstimateType
Other gas estimate value
Returns
number
-1 if this < other, 0 if equal, 1 if this > other
Example
_equals()
_equals(Defined in: src/primitives/GasEstimate/equals.js:15 Check if two GasEstimate values are equalthis,other):boolean
Parameters
this
GasEstimateType
other
GasEstimateType
Other gas estimate value
Returns
boolean
True if equal
Example
_toBigInt()
_toBigInt(Defined in: src/primitives/GasEstimate/toBigInt.js:13 Convert GasEstimate to bigint (identity, for compatibility)this):bigint
Parameters
this
GasEstimateType
Returns
bigint
Gas estimate as bigint
Example
_toGasLimit()
_toGasLimit(Defined in: src/primitives/GasEstimate/toGasLimit.js:15 Convert GasEstimate to GasLimit type Typically used after adding buffer with withBuffer()this):bigint
Parameters
this
GasEstimateType
Returns
bigint
Gas limit value (unbranded bigint)
Example
_toHex()
_toHex(Defined in: src/primitives/GasEstimate/toHex.js:13 Convert GasEstimate to hex stringthis):string
Parameters
this
GasEstimateType
Returns
string
Gas estimate as hex string (0x prefixed)
Example
_toNumber()
_toNumber(Defined in: src/primitives/GasEstimate/toNumber.js:13 Convert GasEstimate to numberthis):number
Parameters
this
GasEstimateType
Returns
number
Gas estimate as number
Example
_withBuffer()
_withBuffer(Defined in: src/primitives/GasEstimate/withBuffer.js:18 Add percentage buffer to gas estimate Recommended: 20-30% to account for variabilitythis,percentageBuffer):GasEstimateType
Parameters
this
GasEstimateType
percentageBuffer
number
Padding percentage (e.g., 20 for 20%)
Returns
GasEstimateType
Estimate with buffer
Example
compare()
compare(Defined in: src/primitives/GasEstimate/index.ts:37value1,value2):number
Parameters
value1
string | number | bigint
value2
string | number | bigint
Returns
number
equals()
equals(Defined in: src/primitives/GasEstimate/index.ts:30value1,value2):boolean
Parameters
value1
string | number | bigint
value2
string | number | bigint
Returns
boolean
from()
from(Defined in: src/primitives/GasEstimate/from.js:16 Create GasEstimate from number, bigint, or stringvalue):GasEstimateType
Parameters
value
Gas estimate valuestring | number | bigint
Returns
GasEstimateType
Branded gas estimate
Throws
If value is negativeExample
toBigInt()
toBigInt(Defined in: src/primitives/GasEstimate/index.ts:22value):bigint
Parameters
value
string | number | bigint
Returns
bigint
toGasLimit()
toGasLimit(Defined in: src/primitives/GasEstimate/index.ts:51estimate):bigint
Parameters
estimate
string | number | bigint
Returns
bigint
toHex()
toHex(Defined in: src/primitives/GasEstimate/index.ts:26value):string
Parameters
value
string | number | bigint
Returns
string
toNumber()
toNumber(Defined in: src/primitives/GasEstimate/index.ts:18value):number
Parameters
value
string | number | bigint
Returns
number
withBuffer()
withBuffer(Defined in: src/primitives/GasEstimate/index.ts:44estimate,percentageBuffer):GasEstimateType
Parameters
estimate
string | number | bigint
percentageBuffer
number
Returns
GasEstimateType
