Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/Gas

primitives/Gas

Type Aliases

GasLimitType

GasLimitType = bigint & object
Defined in: src/primitives/Gas/GasLimitType.ts:7 Branded GasLimit type - prevents gas parameter confusion Represents maximum gas units for a transaction as a branded bigint

Type Declaration

[brand]
readonly [brand]: "GasLimit"

GasPriceType

GasPriceType = bigint & object
Defined in: src/primitives/Gas/GasPriceType.ts:7 Branded GasPrice type - prevents gas parameter confusion Represents gas price in wei per gas unit as a branded bigint

Type Declaration

[brand]
readonly [brand]: "GasPrice"

Variables

DEFAULT_LIMIT

const DEFAULT_LIMIT: Type
Defined in: src/primitives/Gas/gasLimitConstants.js:6

ERC20_TRANSFER

const ERC20_TRANSFER: Type
Defined in: src/primitives/Gas/gasLimitConstants.js:5

GasLimit

const GasLimit: object
Defined in: src/primitives/Gas/index.ts:54

Type Declaration

from()
from: (value) => GasLimitType = gasLimitFrom
Create GasLimit from number, bigint, or hex string
Parameters
value
Value to convert string | number | bigint
Returns
GasLimitType Gas limit
Example
const limit1 = GasLimit.from(21000);
const limit2 = GasLimit.from(21000n);
const limit3 = GasLimit.from("0x5208");
toBigInt()
toBigInt: (value) => bigint = gasLimitToBigInt
Parameters
value
string | number | bigint
Returns
bigint
toNumber()
toNumber: (value) => number = gasLimitToNumber
Parameters
value
string | number | bigint
Returns
number

GasPrice

const GasPrice: object
Defined in: src/primitives/Gas/index.ts:60

Type Declaration

from()
from: (value) => GasPriceType = gasPriceFrom
Create GasPrice from number, bigint, or hex string
Parameters
value
Value in wei string | number | bigint
Returns
GasPriceType Gas price
Example
const price1 = GasPrice.from(20_000_000_000); // 20 gwei
const price2 = GasPrice.from(20_000_000_000n);
const price3 = GasPrice.from("0x4a817c800");
fromGwei()
fromGwei: (gwei) => GasPriceType = gasPriceFromGwei
Create GasPrice from gwei
Parameters
gwei
Value in gwei number | bigint
Returns
GasPriceType Gas price in wei
Example
const price = GasPrice.fromGwei(20); // 20 gwei = 20000000000 wei
toBigInt()
toBigInt: (value) => bigint = gasPriceToBigInt
Parameters
value
string | number | bigint
Returns
bigint
toGwei()
toGwei: (value) => bigint = gasPriceToGwei
Parameters
value
string | number | bigint
Returns
bigint

SIMPLE_TRANSFER

const SIMPLE_TRANSFER: Type
Defined in: src/primitives/Gas/gasLimitConstants.js:4

Functions

_gasLimitToBigInt()

_gasLimitToBigInt(this): bigint
Defined in: src/primitives/Gas/gasLimitToBigInt.js:14 Convert GasLimit to bigint

Parameters

this
GasLimitType

Returns

bigint BigInt

Example

const n = GasLimit._toBigInt.call(limit);

_gasLimitToNumber()

_gasLimitToNumber(this): number
Defined in: src/primitives/Gas/gasLimitToNumber.js:15 Convert GasLimit to number

Parameters

this
GasLimitType

Returns

number Number

Throws

If value exceeds safe integer range

Example

const n = GasLimit._toNumber.call(limit);

_gasPriceToBigInt()

_gasPriceToBigInt(this): bigint
Defined in: src/primitives/Gas/gasPriceToBigInt.js:14 Convert GasPrice to bigint

Parameters

this
GasPriceType

Returns

bigint BigInt in wei

Example

const n = GasPrice._toBigInt.call(price);

_gasPriceToGwei()

_gasPriceToGwei(this): bigint
Defined in: src/primitives/Gas/gasPriceToGwei.js:16 Convert GasPrice to gwei

Parameters

this
GasPriceType

Returns

bigint Value in gwei

Example

const gwei = GasPrice._toGwei.call(price);

gasLimitFrom()

gasLimitFrom(value): GasLimitType
Defined in: src/primitives/Gas/gasLimitFrom.js:16 Create GasLimit from number, bigint, or hex string

Parameters

value
Value to convert string | number | bigint

Returns

GasLimitType Gas limit

Example

const limit1 = GasLimit.from(21000);
const limit2 = GasLimit.from(21000n);
const limit3 = GasLimit.from("0x5208");

gasLimitToBigInt()

gasLimitToBigInt(value): bigint
Defined in: src/primitives/Gas/index.ts:27

Parameters

value
string | number | bigint

Returns

bigint

gasLimitToNumber()

gasLimitToNumber(value): number
Defined in: src/primitives/Gas/index.ts:31

Parameters

value
string | number | bigint

Returns

number

gasPriceFrom()

gasPriceFrom(value): GasPriceType
Defined in: src/primitives/Gas/gasPriceFrom.js:16 Create GasPrice from number, bigint, or hex string

Parameters

value
Value in wei string | number | bigint

Returns

GasPriceType Gas price

Example

const price1 = GasPrice.from(20_000_000_000); // 20 gwei
const price2 = GasPrice.from(20_000_000_000n);
const price3 = GasPrice.from("0x4a817c800");

gasPriceFromGwei()

gasPriceFromGwei(gwei): GasPriceType
Defined in: src/primitives/Gas/gasPriceFromGwei.js:16 Create GasPrice from gwei

Parameters

gwei
Value in gwei number | bigint

Returns

GasPriceType Gas price in wei

Example

const price = GasPrice.fromGwei(20); // 20 gwei = 20000000000 wei

gasPriceToBigInt()

gasPriceToBigInt(value): bigint
Defined in: src/primitives/Gas/index.ts:42

Parameters

value
string | number | bigint

Returns

bigint

gasPriceToGwei()

gasPriceToGwei(value): bigint
Defined in: src/primitives/Gas/index.ts:46

Parameters

value
string | number | bigint

Returns

bigint