ethereumjs-monorepo

@ethereumjs/block / BlockHeader

Class: BlockHeader

An object that represents the block header.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new BlockHeader(headerData, opts?)

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

Deprecated

Use the public static factory methods to assist in creating a Header object from varying data types. For a default empty header, use fromHeaderData.

Parameters

Name Type
headerData HeaderData
opts BlockOptions

Defined in

header.ts:150

Properties

baseFeePerGas

Optional Readonly baseFeePerGas: bigint

Defined in

header.ts:61


blobGasUsed

Optional Readonly blobGasUsed: bigint

Defined in

header.ts:63


coinbase

Readonly coinbase: Address

Defined in

header.ts:48


common

Readonly common: Common

Defined in

header.ts:67


difficulty

Readonly difficulty: bigint

Defined in

header.ts:53


excessBlobGas

Optional Readonly excessBlobGas: bigint

Defined in

header.ts:64


extraData

Readonly extraData: Uint8Array

Defined in

header.ts:58


gasLimit

Readonly gasLimit: bigint

Defined in

header.ts:55


gasUsed

Readonly gasUsed: bigint

Defined in

header.ts:56


logsBloom

Readonly logsBloom: Uint8Array

Defined in

header.ts:52


mixHash

Readonly mixHash: Uint8Array

Defined in

header.ts:59


nonce

Readonly nonce: Uint8Array

Defined in

header.ts:60


number

Readonly number: bigint

Defined in

header.ts:54


parentBeaconBlockRoot

Optional Readonly parentBeaconBlockRoot: Uint8Array

Defined in

header.ts:65


parentHash

Readonly parentHash: Uint8Array

Defined in

header.ts:46


receiptTrie

Readonly receiptTrie: Uint8Array

Defined in

header.ts:51


stateRoot

Readonly stateRoot: Uint8Array

Defined in

header.ts:49


timestamp

Readonly timestamp: bigint

Defined in

header.ts:57


transactionsTrie

Readonly transactionsTrie: Uint8Array

Defined in

header.ts:50


uncleHash

Readonly uncleHash: Uint8Array

Defined in

header.ts:47


withdrawalsRoot

Optional Readonly withdrawalsRoot: Uint8Array

Defined in

header.ts:62

Accessors

prevRandao

get prevRandao(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:78

Methods

calcDataFee

calcDataFee(numBlobs): bigint

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

Parameters

Name Type Description
numBlobs number number of blobs in the transaction/block

Returns

bigint

the total blob gas fee for numBlobs blobs

Defined in

header.ts:621


calcNextBaseFee

calcNextBaseFee(): bigint

Calculates the base fee for a potential next block

Returns

bigint

Defined in

header.ts:552


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:648


calcNextExcessBlobGas

calcNextExcessBlobGas(): bigint

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

Returns

bigint

Defined in

header.ts:632


cliqueEpochTransitionSigners

cliqueEpochTransitionSigners(): Address[]

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 cliqueIsEpochTransition

Returns

Address[]

Defined in

header.ts:870


cliqueExtraSeal

cliqueExtraSeal(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:837


cliqueExtraVanity

cliqueExtraVanity(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:828


cliqueIsEpochTransition

cliqueIsEpochTransition(): boolean

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

Returns

boolean

Defined in

header.ts:816


cliqueSigHash

cliqueSigHash(): Uint8Array

PoA clique signature hash without the seal.

Returns

Uint8Array

Defined in

header.ts:805


cliqueSigner

cliqueSigner(): Address

Returns the signer address

Returns

Address

Defined in

header.ts:907


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

Name Type
signerList Address[]

Returns

boolean

Defined in

header.ts:895


errorStr

errorStr(): string

Return a compact error string representation of the object

Returns

string

Defined in

header.ts:994


ethashCanonicalDifficulty

ethashCanonicalDifficulty(parentBlockHeader): bigint

Returns the canonical difficulty for this block.

Parameters

Name Type Description
parentBlockHeader BlockHeader the header from the parent Block of this header

Returns

bigint

Defined in

header.ts:734


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:596


hash

hash(): Uint8Array

Returns the hash of the block header.

Returns

Uint8Array

Defined in

header.ts:703


isGenesis

isGenesis(): boolean

Checks if the block header is a genesis header.

Returns

boolean

Defined in

header.ts:716


raw

raw(): BlockHeaderBytes

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

Returns

BlockHeaderBytes

Defined in

header.ts:655


serialize

serialize(): Uint8Array

Returns the rlp encoding of the block header.

Returns

Uint8Array

Defined in

header.ts:924


toJSON

toJSON(): JsonHeader

Returns the block header in JSON format.

Returns

JsonHeader

Defined in

header.ts:931


validateGasLimit

validateGasLimit(parentBlockHeader): void

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

Parameters

Name Type Description
parentBlockHeader BlockHeader the header from the parent Block of this header

Returns

void

Defined in

header.ts:505


fromHeaderData

Static fromHeaderData(headerData?, opts?): BlockHeader

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

Parameters

Name Type
headerData HeaderData
opts BlockOptions

Returns

BlockHeader

Defined in

header.ts:94


fromRLPSerializedHeader

Static fromRLPSerializedHeader(serializedHeaderData, opts?): BlockHeader

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

Parameters

Name Type
serializedHeaderData Uint8Array
opts BlockOptions

Returns

BlockHeader

Defined in

header.ts:104


fromValuesArray

Static fromValuesArray(values, opts?): BlockHeader

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

Parameters

Name Type
values BlockHeaderBytes
opts BlockOptions

Returns

BlockHeader

Defined in

header.ts:118