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
packages/block/src/header.ts:148
Properties
baseFeePerGas?
readonlyoptionalbaseFeePerGas:bigint
Defined in
packages/block/src/header.ts:58
blobGasUsed?
readonlyoptionalblobGasUsed:bigint
Defined in
packages/block/src/header.ts:60
cache
protectedcache:HeaderCache
Defined in
packages/block/src/header.ts:69
coinbase
readonlycoinbase:EthjsAddress
Defined in
packages/block/src/header.ts:45
common
readonlycommon:object
blockExplorers?
optionalblockExplorers:object
Collection of block explorers
Index Signature
[key: string]: ChainBlockExplorer
blockExplorers.default
blockExplorers.default:
ChainBlockExplorer
contracts?
optionalcontracts:object
Collection of contracts
contracts.ensRegistry?
optionalcontracts.ensRegistry:ChainContract
contracts.ensUniversalResolver?
optionalcontracts.ensUniversalResolver:ChainContract
contracts.multicall3?
optionalcontracts.multicall3:ChainContract
copy()
copy: () => { blockExplorers?: { [key: string]: ChainBlockExplorer; default: ChainBlockExplorer; } | undefined; contracts?: { [x: string]: ChainContract | { …; } | undefined; ensRegistry?: ChainContract | undefined; ensUniversalResolver?: ChainContract | undefined; multicall3?: ChainContract | undefined; } | undefined; … 11…
Returns
{ blockExplorers?: { [key: string]: ChainBlockExplorer; default: ChainBlockExplorer; } | undefined; contracts?: { [x: string]: ChainContract | { …; } | undefined; ensRegistry?: ChainContract | undefined; ensUniversalResolver?: ChainContract | undefined; multicall3?: ChainContract | undefined; } | undefined; … 11…
custom?
optionalcustom:Record<string,unknown>
Custom chain data.
ethjsCommon
ethjsCommon:
Common
fees?
optionalfees:ChainFees<undefined|ChainFormatters>
Modifies how fees are derived.
formatters?
optionalformatters:ChainFormatters
Modifies how data is formatted and typed (e.g. blocks and transactions)
id
id:
number
ID in number form
name
name:
string
Human-readable name
nativeCurrency
nativeCurrency:
ChainNativeCurrency
Currency used by chain
rpcUrls
rpcUrls:
object
Collection of RPC endpoints
Index Signature
[key: string]: ChainRpcUrls
rpcUrls.default
rpcUrls.default:
ChainRpcUrls
serializers?
optionalserializers:ChainSerializers<undefined|ChainFormatters,TransactionSerializable>
Modifies how data is serialized (e.g. transactions).
sourceId?
optionalsourceId:number
Source Chain ID (ie. the L1 chain)
testnet?
optionaltestnet:boolean
Flag for test networks
Defined in
packages/block/src/header.ts:65
difficulty
readonlydifficulty:bigint
Defined in
packages/block/src/header.ts:50
excessBlobGas?
readonlyoptionalexcessBlobGas:bigint
Defined in
packages/block/src/header.ts:61
extraData
readonlyextraData:Uint8Array
Defined in
packages/block/src/header.ts:55
gasLimit
readonlygasLimit:bigint
Defined in
packages/block/src/header.ts:52
gasUsed
readonlygasUsed:bigint
Defined in
packages/block/src/header.ts:53
keccakFunction()
protectedkeccakFunction: (msg) =>Uint8Array
Parameters
• msg: Uint8Array
Returns
Uint8Array
Defined in
packages/block/src/header.ts:67
logsBloom
readonlylogsBloom:Uint8Array
Defined in
packages/block/src/header.ts:49
mixHash
readonlymixHash:Uint8Array
Defined in
packages/block/src/header.ts:56
nonce
readonlynonce:Uint8Array
Defined in
packages/block/src/header.ts:57
number
readonlynumber:bigint
Defined in
packages/block/src/header.ts:51
parentBeaconBlockRoot?
readonlyoptionalparentBeaconBlockRoot:Uint8Array
Defined in
packages/block/src/header.ts:62
parentHash
readonlyparentHash:Uint8Array
Defined in
packages/block/src/header.ts:43
receiptTrie
readonlyreceiptTrie:Uint8Array
Defined in
packages/block/src/header.ts:48
requestsRoot?
readonlyoptionalrequestsRoot:Uint8Array
Defined in
packages/block/src/header.ts:63
stateRoot
readonlystateRoot:Uint8Array
Defined in
packages/block/src/header.ts:46
timestamp
readonlytimestamp:bigint
Defined in
packages/block/src/header.ts:54
transactionsTrie
readonlytransactionsTrie:Uint8Array
Defined in
packages/block/src/header.ts:47
uncleHash
readonlyuncleHash:Uint8Array
Defined in
packages/block/src/header.ts:44
withdrawalsRoot?
readonlyoptionalwithdrawalsRoot:Uint8Array
Defined in
packages/block/src/header.ts:59
Accessors
prevRandao
getprevRandao():Uint8Array
EIP-4399: After merge to PoS, mixHash supplanted as prevRandao
Returns
Uint8Array
Defined in
packages/block/src/header.ts:76
Methods
_consensusFormatValidation()
protected_consensusFormatValidation():void
Checks static parameters related to consensus algorithm
Returns
void
Throws
if any check fails
Defined in
packages/block/src/header.ts:397
_genericFormatValidation()
protected_genericFormatValidation():void
Validates correct buffer lengths, throws if invalid.
Returns
void
Defined in
packages/block/src/header.ts:310
_requireClique()
protected_requireClique(name):void
Parameters
• name: string
Returns
void
Defined in
packages/block/src/header.ts:680
_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
packages/block/src/header.ts:924
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
packages/block/src/header.ts:579
calcNextBaseFee()
calcNextBaseFee():
bigint
Calculates the base fee for a potential next block
Returns
bigint
Defined in
packages/block/src/header.ts:520
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
packages/block/src/header.ts:605
calcNextExcessBlobGas()
calcNextExcessBlobGas():
bigint
Calculates the excess blob gas for next (hopefully) post EIP 4844 block.
Returns
bigint
Defined in
packages/block/src/header.ts:590
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
packages/block/src/header.ts:823
cliqueExtraSeal()
cliqueExtraSeal():
Uint8Array
Returns extra seal data (only clique PoA, throws otherwise)
Returns
Uint8Array
Defined in
packages/block/src/header.ts:793
cliqueExtraVanity()
cliqueExtraVanity():
Uint8Array
Returns extra vanity data (only clique PoA, throws otherwise)
Returns
Uint8Array
Defined in
packages/block/src/header.ts:784
cliqueIsEpochTransition()
cliqueIsEpochTransition():
boolean
Checks if the block header is an epoch transition header (only clique PoA, throws otherwise)
Returns
boolean
Defined in
packages/block/src/header.ts:772
cliqueSigHash()
cliqueSigHash():
Uint8Array
PoA clique signature hash without the seal.
Returns
Uint8Array
Defined in
packages/block/src/header.ts:761
cliqueSigner()
cliqueSigner():
EthjsAddress
Returns the signer address
Returns
Defined in
packages/block/src/header.ts:860
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
packages/block/src/header.ts:848
errorStr()
errorStr():
string
Return a compact error string representation of the object
Returns
string
Defined in
packages/block/src/header.ts:946
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
packages/block/src/header.ts:692
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
packages/block/src/header.ts:554
hash()
hash():
Uint8Array
Returns the hash of the block header.
Returns
Uint8Array
Defined in
packages/block/src/header.ts:663
isGenesis()
isGenesis():
boolean
Checks if the block header is a genesis header.
Returns
boolean
Defined in
packages/block/src/header.ts:676
raw()
raw():
BlockHeaderBytes
Returns a Uint8Array Array of the raw Bytes in this header, in order.
Returns
Defined in
packages/block/src/header.ts:612
serialize()
serialize():
Uint8Array
Returns the rlp encoding of the block header.
Returns
Uint8Array
Defined in
packages/block/src/header.ts:877
toJSON()
toJSON():
JsonHeader
Returns the block header in JSON format.
Returns
Defined in
packages/block/src/header.ts:884
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
packages/block/src/header.ts:481
fromHeaderData()
staticfromHeaderData(headerData,opts):BlockHeader
Static constructor to create a block header from a header data dictionary
Parameters
• headerData: HeaderData
• opts: BlockOptions
Returns
Defined in
packages/block/src/header.ts:90
fromRLPSerializedHeader()
staticfromRLPSerializedHeader(serializedHeaderData,opts):BlockHeader
Static constructor to create a block header from a RLP-serialized header
Parameters
• serializedHeaderData: Uint8Array
• opts: BlockOptions
Returns
Defined in
packages/block/src/header.ts:100
fromValuesArray()
staticfromValuesArray(values,opts):BlockHeader
Static constructor to create a block header from an array of Bytes values
Parameters
• values: BlockHeaderBytes
• opts: BlockOptions