@tevm/voltaire / primitives/ForkId
primitives/ForkId
Type Aliases
ForkIdType
ForkIdType = object
Defined in: src/primitives/ForkId/ForkIdType.ts:9
EIP-2124 Fork Identifier
Used in DevP2P for fork detection and network validation
See
https://eips.ethereum.org/EIPS/eip-2124Properties
hash
Defined in: src/primitives/ForkId/ForkIdType.ts:13 CRC32 checksum of all fork hashes up to this point (4 bytes)readonlyhash:Uint8Array
next
Defined in: src/primitives/ForkId/ForkIdType.ts:18 Block number of next upcoming fork (0 if no known forks)readonlynext:BlockNumberType
Variables
ForkId
Defined in: src/primitives/ForkId/index.ts:28constForkId:object
Type Declaration
from()
from: (Create ForkId from hash and next block numbervalue) =>ForkIdType
Parameters
value
Fork ID componentshash
string | number | Uint8Array<ArrayBufferLike>
next
string | number | bigint
Returns
ForkIdType
ForkId
Example
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(Defined in: src/primitives/ForkId/matches.js:23 Check if two ForkIds are compatible (EIP-2124 fork validation) Compatible if:local,remote):boolean
- Hashes match and next blocks match (identical)
- Hashes match and remote next is 0 (remote knows of no future forks)
- Hashes match and local next is 0 (local knows of no future forks)
- Hashes differ but remote next is >= local next (remote is ahead but compatible)
Parameters
local
ForkIdType
Local ForkId
remote
ForkIdType
Remote peer’s ForkId
Returns
boolean
True if compatible
Example
_toBytes()
_toBytes(Defined in: src/primitives/ForkId/toBytes.js:15 Encode ForkId to bytes (for DevP2P handshake) Format: [hash (4 bytes) || next (8 bytes big-endian)]forkId):Uint8Array<ArrayBufferLike>
Parameters
forkId
ForkIdType
ForkId to encode
Returns
Uint8Array<ArrayBufferLike>
12-byte encoding
Example
from()
from(Defined in: src/primitives/ForkId/from.js:18 Create ForkId from hash and next block numbervalue):ForkIdType
Parameters
value
Fork ID componentshash
string | number | Uint8Array<ArrayBufferLike>
next
string | number | bigint
Returns
ForkIdType
ForkId
Example
matches()
matches(Defined in: src/primitives/ForkId/index.ts:17local,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(Defined in: src/primitives/ForkId/index.ts:13forkId):Uint8Array
Parameters
forkId
hash
string | number | Uint8Array<ArrayBufferLike>
next
string | number | bigint
Returns
Uint8Array
