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

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

Parameters

headerData

HeaderData

opts

BlockOptions = {}

Returns

BlockHeader

Deprecated

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

Properties

baseFeePerGas?

readonly optional baseFeePerGas: bigint

Defined in: header/header.ts:60


blobGasUsed?

readonly optional blobGasUsed: bigint

Defined in: header/header.ts:62


coinbase

readonly coinbase: Address

Defined in: header/header.ts:47


common

readonly common: Common

Defined in: header/header.ts:67


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


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

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

Returns

Uint8Array<ArrayBufferLike>

Methods

calcDataFee()

calcDataFee(numBlobs): bigint

Defined in: header/header.ts:551

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

Calculates the base fee for a potential next block

Returns

bigint


calcNextBlobGasPrice()

calcNextBlobGasPrice(childCommon): bigint

Defined in: header/header.ts:578

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

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

Return a compact error string representation of the object

Returns

string


ethashCanonicalDifficulty()

ethashCanonicalDifficulty(parentBlockHeader): bigint

Defined in: header/header.ts:658

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

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

Returns the hash of the block header.

Returns

Uint8Array


isGenesis()

isGenesis(): boolean

Defined in: header/header.ts:649

Checks if the block header is a genesis header.

Returns

boolean


raw()

raw(): BlockHeaderBytes

Defined in: header/header.ts:585

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

Returns

BlockHeaderBytes


serialize()

serialize(): Uint8Array

Defined in: header/header.ts:729

Returns the rlp encoding of the block header.

Returns

Uint8Array


toJSON()

toJSON(): JSONHeader

Defined in: header/header.ts:736

Returns the block header in JSON format.

Returns

JSONHeader


validateGasLimit()

validateGasLimit(parentBlockHeader): void

Defined in: header/header.ts:454

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