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

> Auto-generated API documentation

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

***

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

# primitives/ForkId

## Type Aliases

### ForkIdType

> **ForkIdType** = `object`

Defined in: [src/primitives/ForkId/ForkIdType.ts:9](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/ForkId/ForkIdType.ts#L9)

EIP-2124 Fork Identifier
Used in DevP2P for fork detection and network validation

#### See

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

#### Properties

##### hash

> `readonly` **hash**: `Uint8Array`

Defined in: [src/primitives/ForkId/ForkIdType.ts:13](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/ForkId/ForkIdType.ts#L13)

CRC32 checksum of all fork hashes up to this point (4 bytes)

##### next

> `readonly` **next**: [`BlockNumberType`](BlockNumber.mdx#blocknumbertype)

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

Block number of next upcoming fork (0 if no known forks)

## Variables

### ForkId

> `const` **ForkId**: `object`

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

#### Type Declaration

##### from()

> **from**: (`value`) => [`ForkIdType`](#forkidtype)

Create ForkId from hash and next block number

###### Parameters

###### value

Fork ID components

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

###### Returns

[`ForkIdType`](#forkidtype)

ForkId

###### Example

```typescript theme={null}
const forkId = ForkId.from({
  hash: new Uint8Array([0xfc, 0x64, 0xec, 0x04]),
  next: 1920000n,
});
```

##### matches()

> **matches**: (`local`, `remote`) => `boolean`

###### Parameters

###### local

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

###### remote

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

###### Returns

`boolean`

##### toBytes()

> **toBytes**: (`forkId`) => `Uint8Array`

###### Parameters

###### forkId

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

###### Returns

`Uint8Array`

## Functions

### \_matches()

> **\_matches**(`local`, `remote`): `boolean`

Defined in: [src/primitives/ForkId/matches.js:23](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/ForkId/matches.js#L23)

Check if two ForkIds are compatible (EIP-2124 fork validation)

Compatible if:

1. Hashes match and next blocks match (identical)
2. Hashes match and remote next is 0 (remote knows of no future forks)
3. Hashes match and local next is 0 (local knows of no future forks)
4. Hashes differ but remote next is >= local next (remote is ahead but compatible)

#### Parameters

##### local

[`ForkIdType`](#forkidtype)

Local ForkId

##### remote

[`ForkIdType`](#forkidtype)

Remote peer's ForkId

#### Returns

`boolean`

True if compatible

#### Example

```typescript theme={null}
const compatible = ForkId.matches(localForkId, peerForkId);
if (!compatible) {
  console.log("Fork incompatible - disconnect peer");
}
```

***

### \_toBytes()

> **\_toBytes**(`forkId`): `Uint8Array`\<`ArrayBufferLike`>

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

Encode ForkId to bytes (for DevP2P handshake)

Format: \[hash (4 bytes) || next (8 bytes big-endian)]

#### Parameters

##### forkId

[`ForkIdType`](#forkidtype)

ForkId to encode

#### Returns

`Uint8Array`\<`ArrayBufferLike`>

12-byte encoding

#### Example

```typescript theme={null}
const bytes = ForkId.toBytes(forkId);
console.log(bytes.length); // 12
```

***

### from()

> **from**(`value`): [`ForkIdType`](#forkidtype)

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

Create ForkId from hash and next block number

#### Parameters

##### value

Fork ID components

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

#### Returns

[`ForkIdType`](#forkidtype)

ForkId

#### Example

```typescript theme={null}
const forkId = ForkId.from({
  hash: new Uint8Array([0xfc, 0x64, 0xec, 0x04]),
  next: 1920000n,
});
```

***

### matches()

> **matches**(`local`, `remote`): `boolean`

Defined in: [src/primitives/ForkId/index.ts:17](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/ForkId/index.ts#L17)

#### Parameters

##### local

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

##### remote

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

#### Returns

`boolean`

***

### toBytes()

> **toBytes**(`forkId`): `Uint8Array`

Defined in: [src/primitives/ForkId/index.ts:13](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/ForkId/index.ts#L13)

#### Parameters

##### forkId

###### hash

`string` | `number` | `Uint8Array`\<`ArrayBufferLike`>

###### next

`string` | `number` | `bigint`

#### Returns

`Uint8Array`
