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

primitives/ChainHead

Type Aliases

ChainHeadType

ChainHeadType = object
Defined in: src/primitives/ChainHead/ChainHeadType.ts:22 Current chain head information Represents the latest block at the tip of the blockchain. Typically obtained from eth_getBlockByNumber(“latest”).

Example

const chainHead: ChainHeadType = {
  number: 18000000n,
  hash: blockHash,
  timestamp: 1699000000n,
  difficulty: 0n, // Post-merge (PoS)
  totalDifficulty: 58750003716598352816469n, // Pre-merge cumulative
};

Properties

difficulty?
readonly optional difficulty: Type
Defined in: src/primitives/ChainHead/ChainHeadType.ts:41 Block difficulty (0 post-merge)
hash
readonly hash: BlockHashType
Defined in: src/primitives/ChainHead/ChainHeadType.ts:31 Block hash
number
readonly number: BlockNumberType
Defined in: src/primitives/ChainHead/ChainHeadType.ts:26 Block number
timestamp
readonly timestamp: Type
Defined in: src/primitives/ChainHead/ChainHeadType.ts:36 Block timestamp (Unix seconds)
totalDifficulty?
readonly optional totalDifficulty: Type
Defined in: src/primitives/ChainHead/ChainHeadType.ts:46 Total difficulty from genesis to this block

Variables

ChainHead

const ChainHead: object
Defined in: src/primitives/ChainHead/index.ts:9

Type Declaration

from()
from: (value) => ChainHeadType = _from
Create ChainHead from block data or RPC response
Parameters
value
Chain head data
difficulty?
string | number | bigint
hash
string | BlockHashType
number
string | number | bigint
timestamp
string | number | bigint
totalDifficulty?
string | number | bigint
Returns
ChainHeadType ChainHead
Example
const head = ChainHead.from({
  number: 18000000n,
  hash: blockHash,
  timestamp: 1699000000n,
});

Functions

from()

from(value): ChainHeadType
Defined in: src/primitives/ChainHead/from.js:16 Create ChainHead from block data or RPC response

Parameters

value
Chain head data
difficulty?
string | number | bigint
hash
string | BlockHashType
number
string | number | bigint
timestamp
string | number | bigint
totalDifficulty?
string | number | bigint

Returns

ChainHeadType ChainHead

Example

const head = ChainHead.from({
  number: 18000000n,
  hash: blockHash,
  timestamp: 1699000000n,
});