Skip to content

BlockHeader

An object that represents the block header.

Constructors

new BlockHeader()

new BlockHeader(headerData, opts): BlockHeader

This constructor takes the values, validates them, assigns them and freezes the object.

Parameters

headerData: HeaderData

opts: BlockOptions

Returns

BlockHeader

Defined in

packages/block/src/header.ts:148

Properties

baseFeePerGas?

readonly optional baseFeePerGas: bigint

Defined in

packages/block/src/header.ts:58


blobGasUsed?

readonly optional blobGasUsed: bigint

Defined in

packages/block/src/header.ts:60


cache

protected cache: HeaderCache

Defined in

packages/block/src/header.ts:69


coinbase

readonly coinbase: EthjsAddress

Defined in

packages/block/src/header.ts:45


common

readonly common: object

blockExplorers?

optional blockExplorers: object

Collection of block explorers

Index Signature

[key: string]: ChainBlockExplorer

blockExplorers.default

blockExplorers.default: ChainBlockExplorer

contracts?

optional contracts: object

Collection of contracts

contracts.ensRegistry?

optional contracts.ensRegistry: ChainContract

contracts.ensUniversalResolver?

optional contracts.ensUniversalResolver: ChainContract

contracts.multicall3?

optional contracts.multicall3: ChainContract

copy()

copy: () => { blockExplorers?: { [key: string]: ChainBlockExplorer; default: ChainBlockExplorer; } | undefined; contracts?: { [x: string]: ChainContract | { …; } | undefined; ensRegistry?: ChainContract | undefined; ensUniversalResolver?: ChainContract | undefined; multicall3?: ChainContract | undefined; } | undefined; … 11…

Returns

{ blockExplorers?: { [key: string]: ChainBlockExplorer; default: ChainBlockExplorer; } | undefined; contracts?: { [x: string]: ChainContract | { …; } | undefined; ensRegistry?: ChainContract | undefined; ensUniversalResolver?: ChainContract | undefined; multicall3?: ChainContract | undefined; } | undefined; … 11…

custom?

optional custom: Record<string, unknown>

Custom chain data.

ethjsCommon

ethjsCommon: Common

fees?

optional fees: ChainFees<undefined | ChainFormatters>

Modifies how fees are derived.

formatters?

optional formatters: ChainFormatters

Modifies how data is formatted and typed (e.g. blocks and transactions)

id

id: number

ID in number form

name

name: string

Human-readable name

nativeCurrency

nativeCurrency: ChainNativeCurrency

Currency used by chain

rpcUrls

rpcUrls: object

Collection of RPC endpoints

Index Signature

[key: string]: ChainRpcUrls

rpcUrls.default

rpcUrls.default: ChainRpcUrls

serializers?

optional serializers: ChainSerializers<undefined | ChainFormatters, TransactionSerializable>

Modifies how data is serialized (e.g. transactions).

sourceId?

optional sourceId: number

Source Chain ID (ie. the L1 chain)

testnet?

optional testnet: boolean

Flag for test networks

Defined in

packages/block/src/header.ts:65


difficulty

readonly difficulty: bigint

Defined in

packages/block/src/header.ts:50


excessBlobGas?

readonly optional excessBlobGas: bigint

Defined in

packages/block/src/header.ts:61


extraData

readonly extraData: Uint8Array

Defined in

packages/block/src/header.ts:55


gasLimit

readonly gasLimit: bigint

Defined in

packages/block/src/header.ts:52


gasUsed

readonly gasUsed: bigint

Defined in

packages/block/src/header.ts:53


keccakFunction()

protected keccakFunction: (msg) => Uint8Array

Parameters

msg: Uint8Array

Returns

Uint8Array

Defined in

packages/block/src/header.ts:67


logsBloom

readonly logsBloom: Uint8Array

Defined in

packages/block/src/header.ts:49


mixHash

readonly mixHash: Uint8Array

Defined in

packages/block/src/header.ts:56


nonce

readonly nonce: Uint8Array

Defined in

packages/block/src/header.ts:57


number

readonly number: bigint

Defined in

packages/block/src/header.ts:51


parentBeaconBlockRoot?

readonly optional parentBeaconBlockRoot: Uint8Array

Defined in

packages/block/src/header.ts:62


parentHash

readonly parentHash: Uint8Array

Defined in

packages/block/src/header.ts:43


receiptTrie

readonly receiptTrie: Uint8Array

Defined in

packages/block/src/header.ts:48


requestsRoot?

readonly optional requestsRoot: Uint8Array

Defined in

packages/block/src/header.ts:63


stateRoot

readonly stateRoot: Uint8Array

Defined in

packages/block/src/header.ts:46


timestamp

readonly timestamp: bigint

Defined in

packages/block/src/header.ts:54


transactionsTrie

readonly transactionsTrie: Uint8Array

Defined in

packages/block/src/header.ts:47


uncleHash

readonly uncleHash: Uint8Array

Defined in

packages/block/src/header.ts:44


withdrawalsRoot?

readonly optional withdrawalsRoot: Uint8Array

Defined in

packages/block/src/header.ts:59

Accessors

prevRandao

get prevRandao(): Uint8Array

EIP-4399: After merge to PoS, mixHash supplanted as prevRandao

Returns

Uint8Array

Defined in

packages/block/src/header.ts:76

Methods

_consensusFormatValidation()

protected _consensusFormatValidation(): void

Checks static parameters related to consensus algorithm

Returns

void

Throws

if any check fails

Defined in

packages/block/src/header.ts:397


_genericFormatValidation()

protected _genericFormatValidation(): void

Validates correct buffer lengths, throws if invalid.

Returns

void

Defined in

packages/block/src/header.ts:310


_requireClique()

protected _requireClique(name): void

Parameters

name: string

Returns

void

Defined in

packages/block/src/header.ts:680


_validateDAOExtraData()

protected _validateDAOExtraData(): void

Validates extra data is DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)

Returns

void

Defined in

packages/block/src/header.ts:924


calcDataFee()

calcDataFee(numBlobs): bigint

Returns the total fee for blob gas spent for including blobs in block.

Parameters

numBlobs: number

number of blobs in the transaction/block

Returns

bigint

the total blob gas fee for numBlobs blobs

Defined in

packages/block/src/header.ts:579


calcNextBaseFee()

calcNextBaseFee(): bigint

Calculates the base fee for a potential next block

Returns

bigint

Defined in

packages/block/src/header.ts:520


calcNextBlobGasPrice()

calcNextBlobGasPrice(): bigint

Calculate the blob gas price of the block built on top of this one

Returns

bigint

The blob gas price

Defined in

packages/block/src/header.ts:605


calcNextExcessBlobGas()

calcNextExcessBlobGas(): bigint

Calculates the excess blob gas for next (hopefully) post EIP 4844 block.

Returns

bigint

Defined in

packages/block/src/header.ts:590


cliqueEpochTransitionSigners()

cliqueEpochTransitionSigners(): EthjsAddress[]

Returns a list of signers (only clique PoA, throws otherwise)

This function throws if not called on an epoch transition block and should therefore be used in conjunction with BlockHeader.cliqueIsEpochTransition

Returns

EthjsAddress[]

Defined in

packages/block/src/header.ts:823


cliqueExtraSeal()

cliqueExtraSeal(): Uint8Array

Returns extra seal data (only clique PoA, throws otherwise)

Returns

Uint8Array

Defined in

packages/block/src/header.ts:793


cliqueExtraVanity()

cliqueExtraVanity(): Uint8Array

Returns extra vanity data (only clique PoA, throws otherwise)

Returns

Uint8Array

Defined in

packages/block/src/header.ts:784


cliqueIsEpochTransition()

cliqueIsEpochTransition(): boolean

Checks if the block header is an epoch transition header (only clique PoA, throws otherwise)

Returns

boolean

Defined in

packages/block/src/header.ts:772


cliqueSigHash()

cliqueSigHash(): Uint8Array

PoA clique signature hash without the seal.

Returns

Uint8Array

Defined in

packages/block/src/header.ts:761


cliqueSigner()

cliqueSigner(): EthjsAddress

Returns the signer address

Returns

EthjsAddress

Defined in

packages/block/src/header.ts:860


cliqueVerifySignature()

cliqueVerifySignature(signerList): boolean

Verifies the signature of the block (last 65 bytes of extraData field) (only clique PoA, throws otherwise)

Method throws if signature is invalid

Parameters

signerList: EthjsAddress[]

Returns

boolean

Defined in

packages/block/src/header.ts:848


errorStr()

errorStr(): string

Return a compact error string representation of the object

Returns

string

Defined in

packages/block/src/header.ts:946


ethashCanonicalDifficulty()

ethashCanonicalDifficulty(parentBlockHeader): bigint

Returns the canonical difficulty for this block.

Parameters

parentBlockHeader: BlockHeader

the header from the parent Block of this header

Returns

bigint

Defined in

packages/block/src/header.ts:692


getBlobGasPrice()

getBlobGasPrice(): bigint

Returns the price per unit of blob gas for a blob transaction in the current/pending block

Returns

bigint

the price in gwei per unit of blob gas spent

Defined in

packages/block/src/header.ts:554


hash()

hash(): Uint8Array

Returns the hash of the block header.

Returns

Uint8Array

Defined in

packages/block/src/header.ts:663


isGenesis()

isGenesis(): boolean

Checks if the block header is a genesis header.

Returns

boolean

Defined in

packages/block/src/header.ts:676


raw()

raw(): BlockHeaderBytes

Returns a Uint8Array Array of the raw Bytes in this header, in order.

Returns

BlockHeaderBytes

Defined in

packages/block/src/header.ts:612


serialize()

serialize(): Uint8Array

Returns the rlp encoding of the block header.

Returns

Uint8Array

Defined in

packages/block/src/header.ts:877


toJSON()

toJSON(): JsonHeader

Returns the block header in JSON format.

Returns

JsonHeader

Defined in

packages/block/src/header.ts:884


validateGasLimit()

validateGasLimit(parentBlockHeader): void

Validates if the block gasLimit remains in the boundaries set by the protocol. Throws if out of bounds.

Parameters

parentBlockHeader: BlockHeader

the header from the parent Block of this header

Returns

void

Defined in

packages/block/src/header.ts:481


fromHeaderData()

static fromHeaderData(headerData, opts): BlockHeader

Static constructor to create a block header from a header data dictionary

Parameters

headerData: HeaderData

opts: BlockOptions

Returns

BlockHeader

Defined in

packages/block/src/header.ts:90


fromRLPSerializedHeader()

static fromRLPSerializedHeader(serializedHeaderData, opts): BlockHeader

Static constructor to create a block header from a RLP-serialized header

Parameters

serializedHeaderData: Uint8Array

opts: BlockOptions

Returns

BlockHeader

Defined in

packages/block/src/header.ts:100


fromValuesArray()

static fromValuesArray(values, opts): BlockHeader

Static constructor to create a block header from an array of Bytes values

Parameters

values: BlockHeaderBytes

opts: BlockOptions

Returns

BlockHeader

Defined in

packages/block/src/header.ts:114