Skip to content

Latest commit

 

History

History
727 lines (399 loc) · 15.2 KB

BlockHeader.md

File metadata and controls

727 lines (399 loc) · 15.2 KB

@ethereumjs/block / BlockHeader

Class: BlockHeader

An object that represents the block header.

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new BlockHeader(headerData, options?)

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
options BlockOptions

Defined in

header.ts:147

Properties

baseFeePerGas

Optional Readonly baseFeePerGas: bigint

Defined in

header.ts:60


blobGasUsed

Optional Readonly blobGasUsed: bigint

Defined in

header.ts:62


coinbase

Readonly coinbase: Address

Defined in

header.ts:47


common

Readonly common: Common

Defined in

header.ts:66


difficulty

Readonly difficulty: bigint

Defined in

header.ts:52


excessBlobGas

Optional Readonly excessBlobGas: bigint

Defined in

header.ts:63


extraData

Readonly extraData: Uint8Array

Defined in

header.ts:57


gasLimit

Readonly gasLimit: bigint

Defined in

header.ts:54


gasUsed

Readonly gasUsed: bigint

Defined in

header.ts:55


logsBloom

Readonly logsBloom: Uint8Array

Defined in

header.ts:51


mixHash

Readonly mixHash: Uint8Array

Defined in

header.ts:58


nonce

Readonly nonce: Uint8Array

Defined in

header.ts:59


number

Readonly number: bigint

Defined in

header.ts:53


parentBeaconBlockRoot

Optional Readonly parentBeaconBlockRoot: Uint8Array

Defined in

header.ts:64


parentHash

Readonly parentHash: Uint8Array

Defined in

header.ts:45


receiptTrie

Readonly receiptTrie: Uint8Array

Defined in

header.ts:50


stateRoot

Readonly stateRoot: Uint8Array

Defined in

header.ts:48


timestamp

Readonly timestamp: bigint

Defined in

header.ts:56


transactionsTrie

Readonly transactionsTrie: Uint8Array

Defined in

header.ts:49


uncleHash

Readonly uncleHash: Uint8Array

Defined in

header.ts:46


withdrawalsRoot

Optional Readonly withdrawalsRoot: Uint8Array

Defined in

header.ts:61

Accessors

prevRandao

get prevRandao(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:75

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


calcNextBaseFee

calcNextBaseFee(): bigint

Calculates the base fee for a potential next block

Returns

bigint

Defined in

header.ts:537


calcNextExcessBlobGas

calcNextExcessBlobGas(): bigint

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

Returns

bigint

Defined in

header.ts:609


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


cliqueExtraSeal

cliqueExtraSeal(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:798


cliqueExtraVanity

cliqueExtraVanity(): Uint8Array

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

Returns

Uint8Array

Defined in

header.ts:789


cliqueIsEpochTransition

cliqueIsEpochTransition(): boolean

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

Returns

boolean

Defined in

header.ts:777


cliqueSigHash

cliqueSigHash(): Uint8Array

PoA clique signature hash without the seal.

Returns

Uint8Array

Defined in

header.ts:766


cliqueSigner

cliqueSigner(): Address

Returns the signer address

Returns

Address

Defined in

header.ts:867


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


errorStr

errorStr(): string

Return a compact error string representation of the object

Returns

string

Defined in

header.ts:950


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


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


hash

hash(): Uint8Array

Returns the hash of the block header.

Returns

Uint8Array

Defined in

header.ts:664


isGenesis

isGenesis(): boolean

Checks if the block header is a genesis header.

Returns

boolean

Defined in

header.ts:677


raw

raw(): BlockHeaderBytes

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

Returns

BlockHeaderBytes

Defined in

header.ts:624


serialize

serialize(): Uint8Array

Returns the rlp encoding of the block header.

Returns

Uint8Array

Defined in

header.ts:884


toJSON

toJSON(): JsonHeader

Returns the block header in JSON format.

Returns

JsonHeader

Defined in

header.ts:891


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


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


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


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