> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# primitives/EffectiveGasPrice

> Auto-generated API documentation

[**@tevm/voltaire**](../index.mdx)

***

[@tevm/voltaire](../index.mdx) / primitives/EffectiveGasPrice

# primitives/EffectiveGasPrice

## Type Aliases

### EffectiveGasPriceType

> **EffectiveGasPriceType** = `bigint` & `object`

Defined in: [src/primitives/EffectiveGasPrice/EffectiveGasPriceType.ts:10](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/EffectiveGasPriceType.ts#L10)

Branded EffectiveGasPrice type - EIP-1559 effective gas price
Represents the actual gas price paid in a transaction
Calculated as: min(baseFee + priorityFee, maxFeePerGas)

#### Type Declaration

##### \[brand]

> `readonly` **\[brand]**: `"EffectiveGasPrice"`

#### See

[https://eips.ethereum.org/EIPS/eip-1559](https://eips.ethereum.org/EIPS/eip-1559)

## Variables

### EffectiveGasPrice

> `const` **EffectiveGasPrice**: `object`

Defined in: [src/primitives/EffectiveGasPrice/index.ts:54](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/index.ts#L54)

#### Type Declaration

##### calculate()

> **calculate**: (`baseFee`, `maxFee`, `maxPriorityFee`) => [`EffectiveGasPriceType`](#effectivegaspricetype)

Calculate effective gas price from EIP-1559 fee parameters
Formula: min(baseFee + min(maxPriorityFee, maxFee - baseFee), maxFee)

###### Parameters

###### baseFee

`bigint`

Base fee per gas

###### maxFee

`bigint`

Maximum fee per gas

###### maxPriorityFee

`bigint`

Maximum priority fee per gas

###### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Effective gas price

###### Example

```typescript theme={null}
const baseFee = 25000000000n; // 25 Gwei
const maxFee = 100000000000n; // 100 Gwei
const maxPriorityFee = 2000000000n; // 2 Gwei
const effective = EffectiveGasPrice.calculate(baseFee, maxFee, maxPriorityFee);
// Returns 27000000000n (25 + 2 Gwei)
```

##### 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**: (`value`) => [`EffectiveGasPriceType`](#effectivegaspricetype)

Create EffectiveGasPrice from bigint, number, or hex string

###### Parameters

###### value

Effective price in Wei

`string` | `number` | `bigint`

###### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Branded effective gas price

###### Throws

If value is negative or invalid format

###### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.from(27000000000n); // 27 Gwei
const effectivePrice2 = EffectiveGasPrice.from("0x64da46800");
```

##### fromGwei()

> **fromGwei**: (`gwei`) => [`EffectiveGasPriceType`](#effectivegaspricetype)

Create EffectiveGasPrice from Gwei value

###### Parameters

###### gwei

Value in Gwei

`number` | `bigint`

###### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Effective price in Wei

###### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.fromGwei(27n); // 27 Gwei = 27000000000 Wei
```

##### fromWei()

> **fromWei**: (`wei`) => [`EffectiveGasPriceType`](#effectivegaspricetype)

Create EffectiveGasPrice from Wei value (alias for from)

###### Parameters

###### wei

Value in Wei

`string` | `number` | `bigint`

###### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Effective price

###### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.fromWei(27000000000n);
```

##### 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**(`this`, `other`): `number`

Defined in: [src/primitives/EffectiveGasPrice/compare.js:15](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/compare.js#L15)

Compare two EffectiveGasPrice values

#### Parameters

##### this

[`EffectiveGasPriceType`](#effectivegaspricetype)

##### other

[`EffectiveGasPriceType`](#effectivegaspricetype)

Value to compare

#### Returns

`number`

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

#### Example

```typescript theme={null}
const price1 = EffectiveGasPrice.from(27000000000n);
const price2 = EffectiveGasPrice.from(30000000000n);
EffectiveGasPrice.compare(price1, price2); // -1
```

***

### \_equals()

> **\_equals**(`this`, `other`): `boolean`

Defined in: [src/primitives/EffectiveGasPrice/equals.js:15](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/equals.js#L15)

Check if two EffectiveGasPrice values are equal

#### Parameters

##### this

[`EffectiveGasPriceType`](#effectivegaspricetype)

##### other

[`EffectiveGasPriceType`](#effectivegaspricetype)

Value to compare

#### Returns

`boolean`

True if equal

#### Example

```typescript theme={null}
const price1 = EffectiveGasPrice.from(27000000000n);
const price2 = EffectiveGasPrice.from(27000000000n);
EffectiveGasPrice.equals(price1, price2); // true
```

***

### \_toBigInt()

> **\_toBigInt**(`this`): `bigint`

Defined in: [src/primitives/EffectiveGasPrice/toBigInt.js:13](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/toBigInt.js#L13)

Convert EffectiveGasPrice to bigint (identity function)

#### Parameters

##### this

[`EffectiveGasPriceType`](#effectivegaspricetype)

#### Returns

`bigint`

Value as bigint

#### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.from(27000000000n);
EffectiveGasPrice.toBigInt(effectivePrice); // 27000000000n
```

***

### \_toGwei()

> **\_toGwei**(`this`): `bigint`

Defined in: [src/primitives/EffectiveGasPrice/toGwei.js:13](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/toGwei.js#L13)

Convert EffectiveGasPrice to Gwei

#### Parameters

##### this

[`EffectiveGasPriceType`](#effectivegaspricetype)

#### Returns

`bigint`

Value in Gwei

#### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.from(27000000000n);
EffectiveGasPrice.toGwei(effectivePrice); // 27n Gwei
```

***

### \_toNumber()

> **\_toNumber**(`this`): `number`

Defined in: [src/primitives/EffectiveGasPrice/toNumber.js:14](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/toNumber.js#L14)

Convert EffectiveGasPrice to number
WARNING: May lose precision for large values

#### Parameters

##### this

[`EffectiveGasPriceType`](#effectivegaspricetype)

#### Returns

`number`

Value as number

#### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.from(27000000000n);
EffectiveGasPrice.toNumber(effectivePrice); // 27000000000
```

***

### \_toWei()

> **\_toWei**(`this`): `bigint`

Defined in: [src/primitives/EffectiveGasPrice/toWei.js:13](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/toWei.js#L13)

Convert EffectiveGasPrice to Wei (identity function)

#### Parameters

##### this

[`EffectiveGasPriceType`](#effectivegaspricetype)

#### Returns

`bigint`

Value in Wei

#### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.from(27000000000n);
EffectiveGasPrice.toWei(effectivePrice); // 27000000000n Wei
```

***

### calculate()

> **calculate**(`baseFee`, `maxFee`, `maxPriorityFee`): [`EffectiveGasPriceType`](#effectivegaspricetype)

Defined in: [src/primitives/EffectiveGasPrice/calculate.js:19](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/calculate.js#L19)

Calculate effective gas price from EIP-1559 fee parameters
Formula: min(baseFee + min(maxPriorityFee, maxFee - baseFee), maxFee)

#### Parameters

##### baseFee

`bigint`

Base fee per gas

##### maxFee

`bigint`

Maximum fee per gas

##### maxPriorityFee

`bigint`

Maximum priority fee per gas

#### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Effective gas price

#### Example

```typescript theme={null}
const baseFee = 25000000000n; // 25 Gwei
const maxFee = 100000000000n; // 100 Gwei
const maxPriorityFee = 2000000000n; // 2 Gwei
const effective = EffectiveGasPrice.calculate(baseFee, maxFee, maxPriorityFee);
// Returns 27000000000n (25 + 2 Gwei)
```

***

### compare()

> **compare**(`effectivePrice1`, `effectivePrice2`): `number`

Defined in: [src/primitives/EffectiveGasPrice/index.ts:43](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/index.ts#L43)

#### Parameters

##### effectivePrice1

`string` | `number` | `bigint`

##### effectivePrice2

`string` | `number` | `bigint`

#### Returns

`number`

***

### equals()

> **equals**(`effectivePrice1`, `effectivePrice2`): `boolean`

Defined in: [src/primitives/EffectiveGasPrice/index.ts:36](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/index.ts#L36)

#### Parameters

##### effectivePrice1

`string` | `number` | `bigint`

##### effectivePrice2

`string` | `number` | `bigint`

#### Returns

`boolean`

***

### from()

> **from**(`value`): [`EffectiveGasPriceType`](#effectivegaspricetype)

Defined in: [src/primitives/EffectiveGasPrice/from.js:16](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/from.js#L16)

Create EffectiveGasPrice from bigint, number, or hex string

#### Parameters

##### value

Effective price in Wei

`string` | `number` | `bigint`

#### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Branded effective gas price

#### Throws

If value is negative or invalid format

#### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.from(27000000000n); // 27 Gwei
const effectivePrice2 = EffectiveGasPrice.from("0x64da46800");
```

***

### fromGwei()

> **fromGwei**(`gwei`): [`EffectiveGasPriceType`](#effectivegaspricetype)

Defined in: [src/primitives/EffectiveGasPrice/fromGwei.js:12](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/fromGwei.js#L12)

Create EffectiveGasPrice from Gwei value

#### Parameters

##### gwei

Value in Gwei

`number` | `bigint`

#### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Effective price in Wei

#### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.fromGwei(27n); // 27 Gwei = 27000000000 Wei
```

***

### fromWei()

> **fromWei**(`wei`): [`EffectiveGasPriceType`](#effectivegaspricetype)

Defined in: [src/primitives/EffectiveGasPrice/fromWei.js:12](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/fromWei.js#L12)

Create EffectiveGasPrice from Wei value (alias for from)

#### Parameters

##### wei

Value in Wei

`string` | `number` | `bigint`

#### Returns

[`EffectiveGasPriceType`](#effectivegaspricetype)

Effective price

#### Example

```typescript theme={null}
const effectivePrice = EffectiveGasPrice.fromWei(27000000000n);
```

***

### toBigInt()

> **toBigInt**(`effectivePrice`): `bigint`

Defined in: [src/primitives/EffectiveGasPrice/index.ts:32](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/index.ts#L32)

#### Parameters

##### effectivePrice

`string` | `number` | `bigint`

#### Returns

`bigint`

***

### toGwei()

> **toGwei**(`effectivePrice`): `bigint`

Defined in: [src/primitives/EffectiveGasPrice/index.ts:20](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/index.ts#L20)

#### Parameters

##### effectivePrice

`string` | `number` | `bigint`

#### Returns

`bigint`

***

### toNumber()

> **toNumber**(`effectivePrice`): `number`

Defined in: [src/primitives/EffectiveGasPrice/index.ts:28](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/index.ts#L28)

#### Parameters

##### effectivePrice

`string` | `number` | `bigint`

#### Returns

`number`

***

### toWei()

> **toWei**(`effectivePrice`): `bigint`

Defined in: [src/primitives/EffectiveGasPrice/index.ts:24](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/EffectiveGasPrice/index.ts#L24)

#### Parameters

##### effectivePrice

`string` | `number` | `bigint`

#### Returns

`bigint`
