> ## 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.

# ValidatorIndex

> Validator index in beacon state registry

## Overview

ValidatorIndex represents a validator's unique index in the beacon chain state registry. Each validator receives an immutable index when they activate, which persists for their entire lifecycle.

**Type:** `number & { readonly [brand]: "ValidatorIndex" }`

## Key Concepts

* **Immutable**: Index assigned at activation, never changes
* **Sequential**: Indices assigned sequentially starting from 0
* **Permanent**: Index retained even after validator exits
* **Registry**: Maps to validator entry in beacon state

## Methods

### `ValidatorIndex.from(value)`

Create ValidatorIndex from number, bigint, or string.

```typescript theme={null}
import { ValidatorIndex } from '@tevm/primitives';

const idx1 = ValidatorIndex.from(123456);
const idx2 = ValidatorIndex.from(123456n);
const idx3 = ValidatorIndex.from("0x1e240");
```

### `ValidatorIndex.toNumber(index)`

Convert ValidatorIndex to number.

```typescript theme={null}
const idx = ValidatorIndex.from(123456);
const num = ValidatorIndex.toNumber(idx); // 123456
```

### `ValidatorIndex.equals(a, b)`

Check if two validator indices are equal.

```typescript theme={null}
const a = ValidatorIndex.from(123456);
const b = ValidatorIndex.from(123456);
ValidatorIndex.equals(a, b); // true
```

## Usage Examples

### Work with validator data

```typescript theme={null}
import { ValidatorIndex } from '@tevm/primitives';

interface ValidatorInfo {
  index: ValidatorIndex;
  pubkey: Uint8Array;
  withdrawalAddress: string;
  balance: bigint;
}

const validator: ValidatorInfo = {
  index: ValidatorIndex.from(123456),
  pubkey: new Uint8Array(48),
  withdrawalAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f251e3",
  balance: 32000000000n, // 32 ETH in Gwei
};
```

### Track validator committees

```typescript theme={null}
import { ValidatorIndex, Epoch } from '@tevm/primitives';

interface Committee {
  epoch: Epoch;
  slot: number;
  validators: ValidatorIndex[];
}

const committee: Committee = {
  epoch: Epoch.from(100n),
  slot: 3200,
  validators: [
    ValidatorIndex.from(100),
    ValidatorIndex.from(200),
    ValidatorIndex.from(300),
  ],
};
```

## Related Types

* [Withdrawal](/primitives/withdrawal) - References validator by index
* [Slot](/primitives/slot) - Validators assigned to specific slots
* [Epoch](/primitives/epoch) - Committee assignments per epoch

## References

* [Ethereum Consensus Specs](https://github.com/ethereum/consensus-specs)
* [Validator Lifecycle](https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/)
