@tevm/voltaire / primitives/GasUsed
primitives/GasUsed
Type Aliases
GasUsedType
GasUsedType =Defined in: src/primitives/GasUsed/GasUsedType.ts:8 Branded GasUsed type - actual gas consumed by transaction Found in transaction receipts (receipt.gasUsed) Range: 21000 (minimum transfer) to block gas limit (30M typical)bigint&object
Type Declaration
[brand]
readonly[brand]:"GasUsed"
Variables
GasUsed
Defined in: src/primitives/GasUsed/index.ts:54constGasUsed:object
Type Declaration
calculateCost()
calculateCost: (gasUsed,gasPrice) =>bigint
Parameters
gasUsed
string | number | bigint
gasPrice
bigint
Returns
bigint
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 GasUsed from number, bigint, or stringvalue) =>GasUsedType
Parameters
value
Gas used valuestring | number | bigint
Returns
GasUsedType
Branded gas used
Throws
If value is negativeExample
toBigInt()
toBigInt: (value) =>bigint
Parameters
value
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
Functions
_calculateCost()
_calculateCost(Defined in: src/primitives/GasUsed/calculateCost.js:15 Calculate transaction cost in Wei (gasUsed * gasPrice)this,gasPrice):bigint
Parameters
this
GasUsedType
gasPrice
bigint
Gas price in Wei
Returns
bigint
Transaction cost in Wei
Example
_compare()
_compare(Defined in: src/primitives/GasUsed/compare.js:15 Compare two GasUsed valuesthis,other):number
Parameters
this
GasUsedType
other
GasUsedType
Other gas used value
Returns
number
-1 if this < other, 0 if equal, 1 if this > other
Example
_equals()
_equals(Defined in: src/primitives/GasUsed/equals.js:15 Check if two GasUsed values are equalthis,other):boolean
Parameters
this
GasUsedType
other
GasUsedType
Other gas used value
Returns
boolean
True if equal
Example
_toBigInt()
_toBigInt(Defined in: src/primitives/GasUsed/toBigInt.js:13 Convert GasUsed to bigint (identity, for compatibility)this):bigint
Parameters
this
GasUsedType
Returns
bigint
Gas used as bigint
Example
_toHex()
_toHex(Defined in: src/primitives/GasUsed/toHex.js:13 Convert GasUsed to hex stringthis):string
Parameters
this
GasUsedType
Returns
string
Gas used as hex string (0x prefixed)
Example
_toNumber()
_toNumber(Defined in: src/primitives/GasUsed/toNumber.js:13 Convert GasUsed to numberthis):number
Parameters
this
GasUsedType
Returns
number
Gas used as number
Example
calculateCost()
calculateCost(Defined in: src/primitives/GasUsed/index.ts:43gasUsed,gasPrice):bigint
Parameters
gasUsed
string | number | bigint
gasPrice
bigint
Returns
bigint
compare()
compare(Defined in: src/primitives/GasUsed/index.ts:36value1,value2):number
Parameters
value1
string | number | bigint
value2
string | number | bigint
Returns
number
equals()
equals(Defined in: src/primitives/GasUsed/index.ts:29value1,value2):boolean
Parameters
value1
string | number | bigint
value2
string | number | bigint
Returns
boolean
from()
from(Defined in: src/primitives/GasUsed/from.js:16 Create GasUsed from number, bigint, or stringvalue):GasUsedType
Parameters
value
Gas used valuestring | number | bigint
Returns
GasUsedType
Branded gas used
Throws
If value is negativeExample
toBigInt()
toBigInt(Defined in: src/primitives/GasUsed/index.ts:21value):bigint
Parameters
value
string | number | bigint
Returns
bigint
toHex()
toHex(Defined in: src/primitives/GasUsed/index.ts:25value):string
Parameters
value
string | number | bigint
Returns
string
toNumber()
toNumber(Defined in: src/primitives/GasUsed/index.ts:17value):number
Parameters
value
string | number | bigint
Returns
number
