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

primitives/WithdrawalIndex

Type Aliases

WithdrawalIndexType

WithdrawalIndexType = bigint & object
Defined in: src/primitives/WithdrawalIndex/WithdrawalIndexType.ts:13 WithdrawalIndex type Represents the global withdrawal counter in the beacon chain (EIP-4895). This counter increments monotonically for each withdrawal processed.

Type Declaration

[brand]
readonly [brand]: "WithdrawalIndex"

See

Since

0.0.0

Variables

WithdrawalIndex

const WithdrawalIndex: object
Defined in: src/primitives/WithdrawalIndex/index.ts:10

Type Declaration

equals()
equals: (a, b) => boolean
Check if WithdrawalIndex values are equal
Parameters
a
WithdrawalIndexType First withdrawal index
b
WithdrawalIndexType Second withdrawal index
Returns
boolean true if equal
See
https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation
Since
0.0.0
Throws
Example
import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const a = WithdrawalIndex.from(1000000n);
const b = WithdrawalIndex.from(1000000n);
const result = WithdrawalIndex.equals(a, b); // true
from()
from: (value) => WithdrawalIndexType
Create WithdrawalIndex from number, bigint, or string
Parameters
value
Withdrawal index (number, bigint, or decimal/hex string) string | number | bigint
Returns
WithdrawalIndexType WithdrawalIndex value
See
https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation
Since
0.0.0
Throws
If value is negative or invalid
Example
import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const idx1 = WithdrawalIndex.from(1000000n);
const idx2 = WithdrawalIndex.from(1000000);
const idx3 = WithdrawalIndex.from("0xf4240");
toBigInt()
toBigInt: (index) => bigint
Convert WithdrawalIndex to bigint
Parameters
index
WithdrawalIndexType WithdrawalIndex value
Returns
bigint BigInt representation
See
https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation
Since
0.0.0
Throws
Example
import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const idx = WithdrawalIndex.from(1000000);
const big = WithdrawalIndex.toBigInt(idx); // 1000000n
toNumber()
toNumber: (index) => number
Convert WithdrawalIndex to number
Parameters
index
WithdrawalIndexType WithdrawalIndex value
Returns
number Number representation
See
https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation
Since
0.0.0
Throws
If index exceeds safe integer range
Example
import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const idx = WithdrawalIndex.from(1000000n);
const num = WithdrawalIndex.toNumber(idx); // 1000000

Functions

equals()

equals(a, b): boolean
Defined in: src/primitives/WithdrawalIndex/equals.js:18 Check if WithdrawalIndex values are equal

Parameters

a
WithdrawalIndexType First withdrawal index
b
WithdrawalIndexType Second withdrawal index

Returns

boolean true if equal

See

https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation

Since

0.0.0

Throws

Example

import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const a = WithdrawalIndex.from(1000000n);
const b = WithdrawalIndex.from(1000000n);
const result = WithdrawalIndex.equals(a, b); // true

from()

from(value): WithdrawalIndexType
Defined in: src/primitives/WithdrawalIndex/from.js:17 Create WithdrawalIndex from number, bigint, or string

Parameters

value
Withdrawal index (number, bigint, or decimal/hex string) string | number | bigint

Returns

WithdrawalIndexType WithdrawalIndex value

See

https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation

Since

0.0.0

Throws

If value is negative or invalid

Example

import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const idx1 = WithdrawalIndex.from(1000000n);
const idx2 = WithdrawalIndex.from(1000000);
const idx3 = WithdrawalIndex.from("0xf4240");

toBigInt()

toBigInt(index): bigint
Defined in: src/primitives/WithdrawalIndex/toBigInt.js:16 Convert WithdrawalIndex to bigint

Parameters

index
WithdrawalIndexType WithdrawalIndex value

Returns

bigint BigInt representation

See

https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation

Since

0.0.0

Throws

Example

import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const idx = WithdrawalIndex.from(1000000);
const big = WithdrawalIndex.toBigInt(idx); // 1000000n

toNumber()

toNumber(index): number
Defined in: src/primitives/WithdrawalIndex/toNumber.js:16 Convert WithdrawalIndex to number

Parameters

index
WithdrawalIndexType WithdrawalIndex value

Returns

number Number representation

See

https://voltaire.tevm.sh/primitives/withdrawal-index for WithdrawalIndex documentation

Since

0.0.0

Throws

If index exceeds safe integer range

Example

import * as WithdrawalIndex from './primitives/WithdrawalIndex/index.js';
const idx = WithdrawalIndex.from(1000000n);
const num = WithdrawalIndex.toNumber(idx); // 1000000