> ## 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/GasEstimate

> Auto-generated API documentation

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

***

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

# primitives/GasEstimate

## Type Aliases

### GasEstimateType

> **GasEstimateType** = `bigint` & `object`

Defined in: [src/primitives/GasEstimate/GasEstimateType.ts:8](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/GasEstimateType.ts#L8)

Branded GasEstimate type - estimated gas for transaction
Returned by eth\_estimateGas RPC method
Should add buffer (20-30%) for actual transaction

#### Type Declaration

##### \[brand]

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

## Variables

### GasEstimate

> `const` **GasEstimate**: `object`

Defined in: [src/primitives/GasEstimate/index.ts:67](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L67)

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

Create GasEstimate from number, bigint, or string

###### Parameters

###### value

Gas estimate value

`string` | `number` | `bigint`

###### Returns

[`GasEstimateType`](#gasestimatetype)

Branded gas estimate

###### Throws

If value is negative

###### Example

```typescript theme={null}
const estimate = GasEstimate.from(51234n);
const fromRpc = GasEstimate.from(rpcEstimate);
```

##### 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`](#gasestimatetype)

###### Parameters

###### estimate

`string` | `number` | `bigint`

###### percentageBuffer

`number`

###### Returns

[`GasEstimateType`](#gasestimatetype)

## Functions

### \_compare()

> **\_compare**(`this`, `other`): `number`

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

Compare two GasEstimate values

#### Parameters

##### this

[`GasEstimateType`](#gasestimatetype)

##### other

[`GasEstimateType`](#gasestimatetype)

Other gas estimate value

#### Returns

`number`

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

#### Example

```typescript theme={null}
const a = GasEstimate.from(21000n);
const b = GasEstimate.from(51234n);
GasEstimate._compare.call(a, b); // -1
```

***

### \_equals()

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

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

Check if two GasEstimate values are equal

#### Parameters

##### this

[`GasEstimateType`](#gasestimatetype)

##### other

[`GasEstimateType`](#gasestimatetype)

Other gas estimate value

#### Returns

`boolean`

True if equal

#### Example

```typescript theme={null}
const a = GasEstimate.from(51234n);
const b = GasEstimate.from(51234n);
GasEstimate._equals.call(a, b); // true
```

***

### \_toBigInt()

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

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

Convert GasEstimate to bigint (identity, for compatibility)

#### Parameters

##### this

[`GasEstimateType`](#gasestimatetype)

#### Returns

`bigint`

Gas estimate as bigint

#### Example

```typescript theme={null}
const estimate = GasEstimate.from(51234n);
GasEstimate.toBigInt(estimate); // 51234n
```

***

### \_toGasLimit()

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

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

Convert GasEstimate to GasLimit type
Typically used after adding buffer with withBuffer()

#### Parameters

##### this

[`GasEstimateType`](#gasestimatetype)

#### Returns

`bigint`

Gas limit value (unbranded bigint)

#### Example

```typescript theme={null}
const estimate = GasEstimate.from(100000n);
const withBuffer = GasEstimate._withBuffer.call(estimate, 20);
const gasLimit = GasEstimate._toGasLimit.call(withBuffer); // 120000n
```

***

### \_toHex()

> **\_toHex**(`this`): `string`

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

Convert GasEstimate to hex string

#### Parameters

##### this

[`GasEstimateType`](#gasestimatetype)

#### Returns

`string`

Gas estimate as hex string (0x prefixed)

#### Example

```typescript theme={null}
const estimate = GasEstimate.from(51234n);
GasEstimate.toHex(estimate); // "0xc822"
```

***

### \_toNumber()

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

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

Convert GasEstimate to number

#### Parameters

##### this

[`GasEstimateType`](#gasestimatetype)

#### Returns

`number`

Gas estimate as number

#### Example

```typescript theme={null}
const estimate = GasEstimate.from(51234n);
GasEstimate.toNumber(estimate); // 51234
```

***

### \_withBuffer()

> **\_withBuffer**(`this`, `percentageBuffer`): [`GasEstimateType`](#gasestimatetype)

Defined in: [src/primitives/GasEstimate/withBuffer.js:18](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/withBuffer.js#L18)

Add percentage buffer to gas estimate
Recommended: 20-30% to account for variability

#### Parameters

##### this

[`GasEstimateType`](#gasestimatetype)

##### percentageBuffer

`number`

Padding percentage (e.g., 20 for 20%)

#### Returns

[`GasEstimateType`](#gasestimatetype)

Estimate with buffer

#### Example

```typescript theme={null}
const estimate = GasEstimate.from(100000n);
GasEstimate._withBuffer.call(estimate, 20); // 120000n (100000 + 20%)
GasEstimate._withBuffer.call(estimate, 30); // 130000n (100000 + 30%)
```

***

### compare()

> **compare**(`value1`, `value2`): `number`

Defined in: [src/primitives/GasEstimate/index.ts:37](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L37)

#### Parameters

##### value1

`string` | `number` | `bigint`

##### value2

`string` | `number` | `bigint`

#### Returns

`number`

***

### equals()

> **equals**(`value1`, `value2`): `boolean`

Defined in: [src/primitives/GasEstimate/index.ts:30](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L30)

#### Parameters

##### value1

`string` | `number` | `bigint`

##### value2

`string` | `number` | `bigint`

#### Returns

`boolean`

***

### from()

> **from**(`value`): [`GasEstimateType`](#gasestimatetype)

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

Create GasEstimate from number, bigint, or string

#### Parameters

##### value

Gas estimate value

`string` | `number` | `bigint`

#### Returns

[`GasEstimateType`](#gasestimatetype)

Branded gas estimate

#### Throws

If value is negative

#### Example

```typescript theme={null}
const estimate = GasEstimate.from(51234n);
const fromRpc = GasEstimate.from(rpcEstimate);
```

***

### toBigInt()

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

Defined in: [src/primitives/GasEstimate/index.ts:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L22)

#### Parameters

##### value

`string` | `number` | `bigint`

#### Returns

`bigint`

***

### toGasLimit()

> **toGasLimit**(`estimate`): `bigint`

Defined in: [src/primitives/GasEstimate/index.ts:51](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L51)

#### Parameters

##### estimate

`string` | `number` | `bigint`

#### Returns

`bigint`

***

### toHex()

> **toHex**(`value`): `string`

Defined in: [src/primitives/GasEstimate/index.ts:26](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L26)

#### Parameters

##### value

`string` | `number` | `bigint`

#### Returns

`string`

***

### toNumber()

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

Defined in: [src/primitives/GasEstimate/index.ts:18](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L18)

#### Parameters

##### value

`string` | `number` | `bigint`

#### Returns

`number`

***

### withBuffer()

> **withBuffer**(`estimate`, `percentageBuffer`): [`GasEstimateType`](#gasestimatetype)

Defined in: [src/primitives/GasEstimate/index.ts:44](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/GasEstimate/index.ts#L44)

#### Parameters

##### estimate

`string` | `number` | `bigint`

##### percentageBuffer

`number`

#### Returns

[`GasEstimateType`](#gasestimatetype)
