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

header.ts:148

Properties

baseFeePerGas?

readonly optional baseFeePerGas: bigint

Defined in

header.ts:58


blobGasUsed?

readonly optional blobGasUsed: bigint

Defined in

header.ts:60


cache

protected cache: HeaderCache

Defined in

header.ts:69


coinbase

readonly coinbase: EthjsAddress

Defined in

header.ts:45


common

readonly common: Common

Defined in

header.ts:65


difficulty

readonly difficulty: bigint

Defined in

header.ts:50


excessBlobGas?

readonly optional excessBlobGas: bigint

Defined in

header.ts:61


extraData

readonly extraData: Uint8Array

Defined in

header.ts:55


gasLimit

readonly gasLimit: bigint

Defined in

header.ts:52


gasUsed

readonly gasUsed: bigint

Defined in

header.ts:53


keccakFunction()

protected keccakFunction: (msg) => Uint8Array

Parameters

msg: Uint8Array

Returns

Uint8Array

Defined in

header.ts:67


logsBloom

readonly logsBloom: Uint8Array

Defined in

header.ts:49


mixHash

readonly mixHash: Uint8Array

Defined in

header.ts:56


nonce

readonly nonce: Uint8Array

Defined in

header.ts:57


number

readonly number: bigint

Defined in

header.ts:51


parentBeaconBlockRoot?

readonly optional parentBeaconBlockRoot: Uint8Array

Defined in

header.ts:62


parentHash

readonly parentHash: Uint8Array

Defined in

header.ts:43


receiptTrie

readonly receiptTrie: Uint8Array

Defined in

header.ts:48


requestsRoot?

readonly optional requestsRoot: Uint8Array

Defined in

header.ts:63


stateRoot

readonly stateRoot: Uint8Array

Defined in

header.ts:46


timestamp

readonly timestamp: bigint

Defined in

header.ts:54


transactionsTrie

readonly transactionsTrie: Uint8Array

Defined in

header.ts:47


uncleHash

readonly uncleHash: Uint8Array

Defined in

header.ts:44


withdrawalsRoot?

readonly optional withdrawalsRoot: Uint8Array

Defined in

header.ts:59

Accessors

prevRandao

get prevRandao(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:76

Methods

_consensusFormatValidation()

protected _consensusFormatValidation(): void

Checks static parameters related to consensus algorithm

Returns

void

Throws

if any check fails

Defined in

header.ts:397


_genericFormatValidation()

protected _genericFormatValidation(): void

Validates correct buffer lengths, throws if invalid.

Returns

void

Defined in

header.ts:310


_requireClique()

protected _requireClique(name): void

Parameters

name: string

Returns

void

Defined in

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

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

header.ts:579


calcNextBaseFee()

calcNextBaseFee(): bigint

Calculates the base fee for a potential next block

Returns

bigint

Defined in

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

header.ts:605


calcNextExcessBlobGas()

calcNextExcessBlobGas(): bigint

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

Returns

bigint

Defined in

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

header.ts:823


cliqueExtraSeal()

cliqueExtraSeal(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:793


cliqueExtraVanity()

cliqueExtraVanity(): Uint8Array

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

Returns

Uint8Array

Defined in

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

header.ts:772


cliqueSigHash()

cliqueSigHash(): Uint8Array

PoA clique signature hash without the seal.

Returns

Uint8Array

Defined in

header.ts:761


cliqueSigner()

cliqueSigner(): EthjsAddress

Returns the signer address

Returns

EthjsAddress

Defined in

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

header.ts:848


errorStr()

errorStr(): string

Return a compact error string representation of the object

Returns

string

Defined in

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

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

header.ts:554


hash()

hash(): Uint8Array

Returns the hash of the block header.

Returns

Uint8Array

Defined in

header.ts:663


isGenesis()

isGenesis(): boolean

Checks if the block header is a genesis header.

Returns

boolean

Defined in

header.ts:676


raw()

raw(): BlockHeaderBytes

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

Returns

BlockHeaderBytes

Defined in

header.ts:612


serialize()

serialize(): Uint8Array

Returns the rlp encoding of the block header.

Returns

Uint8Array

Defined in

header.ts:877


toJSON()

toJSON(): JsonHeader

Returns the block header in JSON format.

Returns

JsonHeader

Defined in

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

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

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

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

header.ts:114