ethereumjs-monorepo

@ethereumjs/block


@ethereumjs/block / BlockHeader

Class: BlockHeader

Defined in: header/header.ts:44

An object that represents the block header.

Constructors

Constructor

new BlockHeader(headerData, opts?): BlockHeader

Defined in: header/header.ts:100

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

Parameters

headerData

HeaderData

opts?

BlockOptions = {}

Returns

BlockHeader

Deprecated

Use the module-level factory functions such as createBlockHeader, createBlockHeaderFromRLP, and createBlockHeaderFromBytesArray to create a BlockHeader from varying data types.

Properties

baseFeePerGas?

readonly optional baseFeePerGas?: bigint

Defined in: header/header.ts:60


blobGasUsed?

readonly optional blobGasUsed?: bigint

Defined in: header/header.ts:62


blockAccessListHash?

readonly optional blockAccessListHash?: Uint8Array<ArrayBufferLike>

Defined in: header/header.ts:67

EIP-7928 block access list hash. Experimental (Amsterdam); may change on patch releases.


coinbase

readonly coinbase: Address

Defined in: header/header.ts:47


common

readonly common: Common

Defined in: header/header.ts:71


difficulty

readonly difficulty: bigint

Defined in: header/header.ts:52


excessBlobGas?

readonly optional excessBlobGas?: bigint

Defined in: header/header.ts:63


extraData

readonly extraData: Uint8Array

Defined in: header/header.ts:57


gasLimit

readonly gasLimit: bigint

Defined in: header/header.ts:54


gasUsed

readonly gasUsed: bigint

Defined in: header/header.ts:55


logsBloom

readonly logsBloom: Uint8Array

Defined in: header/header.ts:51


mixHash

readonly mixHash: Uint8Array

Defined in: header/header.ts:58


nonce

readonly nonce: Uint8Array

Defined in: header/header.ts:59


number

readonly number: bigint

Defined in: header/header.ts:53


parentBeaconBlockRoot?

readonly optional parentBeaconBlockRoot?: Uint8Array<ArrayBufferLike>

Defined in: header/header.ts:64


parentHash

readonly parentHash: Uint8Array

Defined in: header/header.ts:45


receiptTrie

readonly receiptTrie: Uint8Array

Defined in: header/header.ts:50


requestsHash?

readonly optional requestsHash?: Uint8Array<ArrayBufferLike>

Defined in: header/header.ts:65


slotNumber?

readonly optional slotNumber?: bigint

Defined in: header/header.ts:69

EIP-7843 slot number. Experimental (Amsterdam); may change on patch releases.


stateRoot

readonly stateRoot: Uint8Array

Defined in: header/header.ts:48


timestamp

readonly timestamp: bigint

Defined in: header/header.ts:56


transactionsTrie

readonly transactionsTrie: Uint8Array

Defined in: header/header.ts:49


uncleHash

readonly uncleHash: Uint8Array

Defined in: header/header.ts:46


withdrawalsRoot?

readonly optional withdrawalsRoot?: Uint8Array<ArrayBufferLike>

Defined in: header/header.ts:61

Accessors

prevRandao

Get Signature

get prevRandao(): Uint8Array<ArrayBufferLike>

Defined in: header/header.ts:82

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

Returns

Uint8Array<ArrayBufferLike>

Methods

calcDataFee()

calcDataFee(numBlobs): bigint

Defined in: header/header.ts:595

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


calcNextBaseFee()

calcNextBaseFee(): bigint

Defined in: header/header.ts:544

Calculates the base fee for a potential next block

Returns

bigint


calcNextBlobGasPrice()

calcNextBlobGasPrice(childCommon): bigint

Defined in: header/header.ts:639

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

Parameters

childCommon

Common

Returns

bigint

The blob gas price


calcNextExcessBlobGas()

calcNextExcessBlobGas(childCommon): bigint

Defined in: header/header.ts:606

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

Parameters

childCommon

Common

Returns

bigint


errorStr()

errorStr(): string

Defined in: header/header.ts:866

Return a compact error string representation of the object

Returns

string


ethashCanonicalDifficulty()

ethashCanonicalDifficulty(parentBlockHeader): bigint

Defined in: header/header.ts:716

Returns the canonical difficulty for this block.

Parameters

parentBlockHeader

BlockHeader

the header from the parent Block of this header

Returns

bigint


getBlobGasPrice()

getBlobGasPrice(): bigint

Defined in: header/header.ts:582

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


hash()

hash(): Uint8Array

Defined in: header/header.ts:696

Returns the hash of the block header.

Returns

Uint8Array


isGenesis()

isGenesis(): boolean

Defined in: header/header.ts:707

Checks if the block header is a genesis header.

Returns

boolean


raw()

raw(): BlockHeaderBytes

Defined in: header/header.ts:646

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

Returns

BlockHeaderBytes


serialize()

serialize(): Uint8Array

Defined in: header/header.ts:787

Returns the rlp encoding of the block header.

Returns

Uint8Array


toJSON()

toJSON(): JSONHeader

Defined in: header/header.ts:794

Returns the block header in JSON format.

Returns

JSONHeader


validateGasLimit()

validateGasLimit(parentBlockHeader): void

Defined in: header/header.ts:498

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