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
Defined in
Properties
baseFeePerGas?
readonly
optional
baseFeePerGas:bigint
Defined in
blobGasUsed?
readonly
optional
blobGasUsed:bigint
Defined in
cache
protected
cache:HeaderCache
Defined in
coinbase
readonly
coinbase:EthjsAddress
Defined in
common
readonly
common:Common
Defined in
difficulty
readonly
difficulty:bigint
Defined in
excessBlobGas?
readonly
optional
excessBlobGas:bigint
Defined in
extraData
readonly
extraData:Uint8Array
Defined in
gasLimit
readonly
gasLimit:bigint
Defined in
gasUsed
readonly
gasUsed:bigint
Defined in
keccakFunction()
protected
keccakFunction: (msg
) =>Uint8Array
Parameters
• msg: Uint8Array
Returns
Uint8Array
Defined in
logsBloom
readonly
logsBloom:Uint8Array
Defined in
mixHash
readonly
mixHash:Uint8Array
Defined in
nonce
readonly
nonce:Uint8Array
Defined in
number
readonly
number:bigint
Defined in
parentBeaconBlockRoot?
readonly
optional
parentBeaconBlockRoot:Uint8Array
Defined in
parentHash
readonly
parentHash:Uint8Array
Defined in
receiptTrie
readonly
receiptTrie:Uint8Array
Defined in
requestsRoot?
readonly
optional
requestsRoot:Uint8Array
Defined in
stateRoot
readonly
stateRoot:Uint8Array
Defined in
timestamp
readonly
timestamp:bigint
Defined in
transactionsTrie
readonly
transactionsTrie:Uint8Array
Defined in
uncleHash
readonly
uncleHash:Uint8Array
Defined in
withdrawalsRoot?
readonly
optional
withdrawalsRoot:Uint8Array
Defined in
Accessors
prevRandao
get
prevRandao():Uint8Array
EIP-4399: After merge to PoS, mixHash
supplanted as prevRandao
Returns
Uint8Array
Defined in
Methods
_consensusFormatValidation()
protected
_consensusFormatValidation():void
Checks static parameters related to consensus algorithm
Returns
void
Throws
if any check fails
Defined in
_genericFormatValidation()
protected
_genericFormatValidation():void
Validates correct buffer lengths, throws if invalid.
Returns
void
Defined in
_requireClique()
protected
_requireClique(name
):void
Parameters
• name: string
Returns
void
Defined in
_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
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
calcNextBaseFee()
calcNextBaseFee():
bigint
Calculates the base fee for a potential next block
Returns
bigint
Defined in
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
calcNextExcessBlobGas()
calcNextExcessBlobGas():
bigint
Calculates the excess blob gas for next (hopefully) post EIP 4844 block.
Returns
bigint
Defined in
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
Defined in
cliqueExtraSeal()
cliqueExtraSeal():
Uint8Array
Returns extra seal data (only clique PoA, throws otherwise)
Returns
Uint8Array
Defined in
cliqueExtraVanity()
cliqueExtraVanity():
Uint8Array
Returns extra vanity data (only clique PoA, throws otherwise)
Returns
Uint8Array
Defined in
cliqueIsEpochTransition()
cliqueIsEpochTransition():
boolean
Checks if the block header is an epoch transition header (only clique PoA, throws otherwise)
Returns
boolean
Defined in
cliqueSigHash()
cliqueSigHash():
Uint8Array
PoA clique signature hash without the seal.
Returns
Uint8Array
Defined in
cliqueSigner()
cliqueSigner():
EthjsAddress
Returns the signer address
Returns
Defined in
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
errorStr()
errorStr():
string
Return a compact error string representation of the object
Returns
string
Defined in
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
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
hash()
hash():
Uint8Array
Returns the hash of the block header.
Returns
Uint8Array
Defined in
isGenesis()
isGenesis():
boolean
Checks if the block header is a genesis header.
Returns
boolean
Defined in
raw()
raw():
BlockHeaderBytes
Returns a Uint8Array Array of the raw Bytes in this header, in order.
Returns
Defined in
serialize()
serialize():
Uint8Array
Returns the rlp encoding of the block header.
Returns
Uint8Array
Defined in
toJSON()
toJSON():
JsonHeader
Returns the block header in JSON format.
Returns
Defined in
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
fromHeaderData()
static
fromHeaderData(headerData
,opts
):BlockHeader
Static constructor to create a block header from a header data dictionary
Parameters
• headerData: HeaderData
• opts: BlockOptions
Returns
Defined in
fromRLPSerializedHeader()
static
fromRLPSerializedHeader(serializedHeaderData
,opts
):BlockHeader
Static constructor to create a block header from a RLP-serialized header
Parameters
• serializedHeaderData: Uint8Array
• opts: BlockOptions
Returns
Defined in
fromValuesArray()
static
fromValuesArray(values
,opts
):BlockHeader
Static constructor to create a block header from an array of Bytes values
Parameters
• values: BlockHeaderBytes
• opts: BlockOptions