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

primitives/MaxFeePerGas

Type Aliases

MaxFeePerGasType

MaxFeePerGasType = bigint & object
Defined in: src/primitives/MaxFeePerGas/MaxFeePerGasType.ts:10 Branded MaxFeePerGas type - EIP-1559 maximum fee per gas Represents the maximum total gas price user is willing to pay Must be >= baseFeePerGas + maxPriorityFeePerGas for inclusion

Type Declaration

[brand]
readonly [brand]: "MaxFeePerGas"

See

https://eips.ethereum.org/EIPS/eip-1559

Variables

MaxFeePerGas

const MaxFeePerGas: object
Defined in: src/primitives/MaxFeePerGas/index.ts:53

Type Declaration

compare()
compare: (maxFee1, maxFee2) => number
Parameters
maxFee1
string | number | bigint
maxFee2
string | number | bigint
Returns
number
equals()
equals: (maxFee1, maxFee2) => boolean
Parameters
maxFee1
string | number | bigint
maxFee2
string | number | bigint
Returns
boolean
from()
from: (value) => MaxFeePerGasType
Create MaxFeePerGas from bigint, number, or hex string
Parameters
value
Max fee in Wei string | number | bigint
Returns
MaxFeePerGasType Branded max fee
Throws
If value is negative or invalid format
Example
const maxFee = MaxFeePerGas.from(100000000000n); // 100 Gwei
const maxFee2 = MaxFeePerGas.from("0x174876e800");
fromGwei()
fromGwei: (gwei) => MaxFeePerGasType
Create MaxFeePerGas from Gwei value
Parameters
gwei
Value in Gwei number | bigint
Returns
MaxFeePerGasType Max fee in Wei
Example
const maxFee = MaxFeePerGas.fromGwei(100n); // 100 Gwei = 100000000000 Wei
fromWei()
fromWei: (wei) => MaxFeePerGasType
Create MaxFeePerGas from Wei value (alias for from)
Parameters
wei
Value in Wei string | number | bigint
Returns
MaxFeePerGasType Max fee
Example
const maxFee = MaxFeePerGas.fromWei(100000000000n);
toBigInt()
toBigInt: (maxFee) => bigint
Parameters
maxFee
string | number | bigint
Returns
bigint
toGwei()
toGwei: (maxFee) => bigint
Parameters
maxFee
string | number | bigint
Returns
bigint
toNumber()
toNumber: (maxFee) => number
Parameters
maxFee
string | number | bigint
Returns
number
toWei()
toWei: (maxFee) => bigint
Parameters
maxFee
string | number | bigint
Returns
bigint

Functions

_compare()

_compare(this, other): number
Defined in: src/primitives/MaxFeePerGas/compare.js:15 Compare two MaxFeePerGas values

Parameters

this
MaxFeePerGasType
other
MaxFeePerGasType Value to compare

Returns

number -1 if this < other, 0 if equal, 1 if this > other

Example

const fee1 = MaxFeePerGas.from(100000000000n);
const fee2 = MaxFeePerGas.from(120000000000n);
MaxFeePerGas.compare(fee1, fee2); // -1

_equals()

_equals(this, other): boolean
Defined in: src/primitives/MaxFeePerGas/equals.js:15 Check if two MaxFeePerGas values are equal

Parameters

this
MaxFeePerGasType
other
MaxFeePerGasType Value to compare

Returns

boolean True if equal

Example

const fee1 = MaxFeePerGas.from(100000000000n);
const fee2 = MaxFeePerGas.from(100000000000n);
MaxFeePerGas.equals(fee1, fee2); // true

_toBigInt()

_toBigInt(this): bigint
Defined in: src/primitives/MaxFeePerGas/toBigInt.js:13 Convert MaxFeePerGas to bigint (identity function)

Parameters

this
MaxFeePerGasType

Returns

bigint Value as bigint

Example

const maxFee = MaxFeePerGas.from(100000000000n);
MaxFeePerGas.toBigInt(maxFee); // 100000000000n

_toGwei()

_toGwei(this): bigint
Defined in: src/primitives/MaxFeePerGas/toGwei.js:13 Convert MaxFeePerGas to Gwei

Parameters

this
MaxFeePerGasType

Returns

bigint Value in Gwei

Example

const maxFee = MaxFeePerGas.from(100000000000n);
MaxFeePerGas.toGwei(maxFee); // 100n Gwei

_toNumber()

_toNumber(this): number
Defined in: src/primitives/MaxFeePerGas/toNumber.js:14 Convert MaxFeePerGas to number WARNING: May lose precision for large values

Parameters

this
MaxFeePerGasType

Returns

number Value as number

Example

const maxFee = MaxFeePerGas.from(100000000000n);
MaxFeePerGas.toNumber(maxFee); // 100000000000

_toWei()

_toWei(this): bigint
Defined in: src/primitives/MaxFeePerGas/toWei.js:13 Convert MaxFeePerGas to Wei (identity function)

Parameters

this
MaxFeePerGasType

Returns

bigint Value in Wei

Example

const maxFee = MaxFeePerGas.from(100000000000n);
MaxFeePerGas.toWei(maxFee); // 100000000000n Wei

compare()

compare(maxFee1, maxFee2): number
Defined in: src/primitives/MaxFeePerGas/index.ts:42

Parameters

maxFee1
string | number | bigint
maxFee2
string | number | bigint

Returns

number

equals()

equals(maxFee1, maxFee2): boolean
Defined in: src/primitives/MaxFeePerGas/index.ts:35

Parameters

maxFee1
string | number | bigint
maxFee2
string | number | bigint

Returns

boolean

from()

from(value): MaxFeePerGasType
Defined in: src/primitives/MaxFeePerGas/from.js:16 Create MaxFeePerGas from bigint, number, or hex string

Parameters

value
Max fee in Wei string | number | bigint

Returns

MaxFeePerGasType Branded max fee

Throws

If value is negative or invalid format

Example

const maxFee = MaxFeePerGas.from(100000000000n); // 100 Gwei
const maxFee2 = MaxFeePerGas.from("0x174876e800");

fromGwei()

fromGwei(gwei): MaxFeePerGasType
Defined in: src/primitives/MaxFeePerGas/fromGwei.js:12 Create MaxFeePerGas from Gwei value

Parameters

gwei
Value in Gwei number | bigint

Returns

MaxFeePerGasType Max fee in Wei

Example

const maxFee = MaxFeePerGas.fromGwei(100n); // 100 Gwei = 100000000000 Wei

fromWei()

fromWei(wei): MaxFeePerGasType
Defined in: src/primitives/MaxFeePerGas/fromWei.js:12 Create MaxFeePerGas from Wei value (alias for from)

Parameters

wei
Value in Wei string | number | bigint

Returns

MaxFeePerGasType Max fee

Example

const maxFee = MaxFeePerGas.fromWei(100000000000n);

toBigInt()

toBigInt(maxFee): bigint
Defined in: src/primitives/MaxFeePerGas/index.ts:31

Parameters

maxFee
string | number | bigint

Returns

bigint

toGwei()

toGwei(maxFee): bigint
Defined in: src/primitives/MaxFeePerGas/index.ts:19

Parameters

maxFee
string | number | bigint

Returns

bigint

toNumber()

toNumber(maxFee): number
Defined in: src/primitives/MaxFeePerGas/index.ts:27

Parameters

maxFee
string | number | bigint

Returns

number

toWei()

toWei(maxFee): bigint
Defined in: src/primitives/MaxFeePerGas/index.ts:23

Parameters

maxFee
string | number | bigint

Returns

bigint