Block
An object that represents the block.
Constructors
new Block()
new Block(
opts
,header
?,transactions
?,uncleHeaders
?,withdrawals
?,requests
?,executionWitness
?):Block
This constructor takes the values, validates them, assigns them and freezes the object. Use the static factory methods to assist in creating a Block object from varying data types and options.
Parameters
• opts: BlockOptions
• header?: BlockHeader
• transactions?: TypedTransaction
[] = []
• uncleHeaders?: BlockHeader
[] = []
• withdrawals?: Withdrawal
[]
• requests?: ClRequest
[]
• executionWitness?: null
| VerkleExecutionWitness
Returns
Defined in
Properties
cache
protected
cache:object
={}
requestsRoot?
optional
requestsRoot:Uint8Array
txTrieRoot?
optional
txTrieRoot:Uint8Array
withdrawalsTrieRoot?
optional
withdrawalsTrieRoot:Uint8Array
Defined in
common
readonly
common:Common
Defined in
executionWitness?
readonly
optional
executionWitness:null
|VerkleExecutionWitness
EIP-6800: Verkle Proof Data (experimental) null implies that the non default executionWitness might exist but not available and will not lead to execution of the block via vm with verkle stateless manager
Defined in
header
readonly
header:BlockHeader
Defined in
keccakFunction()
protected
keccakFunction: (msg
) =>Uint8Array
Parameters
• msg: Uint8Array
Returns
Uint8Array
Defined in
requests?
readonly
optional
requests:ClRequest
[]
Defined in
transactions
readonly
transactions:TypedTransaction
[] =[]
Defined in
uncleHeaders
readonly
uncleHeaders:BlockHeader
[] =[]
Defined in
withdrawals?
readonly
optional
withdrawals:Withdrawal
[]
Defined in
Methods
errorStr()
errorStr():
string
Return a compact error string representation of the object
Returns
string
Defined in
ethashCanonicalDifficulty()
ethashCanonicalDifficulty(
parentBlock
):bigint
Returns the canonical difficulty for this block.
Parameters
• parentBlock: Block
the parent of this Block
Returns
bigint
Defined in
genTxTrie()
genTxTrie():
Promise
<Uint8Array
>
Generates transaction trie for validation.
Returns
Promise
<Uint8Array
>
Defined in
getTransactionsValidationErrors()
getTransactionsValidationErrors():
string
[]
Validates transaction signatures and minimum gas requirements.
Returns
string
[]
an array of error strings
Defined in
hash()
hash():
Uint8Array
Returns the hash of the block.
Returns
Uint8Array
Defined in
isGenesis()
isGenesis():
boolean
Determines if this block is the genesis block.
Returns
boolean
Defined in
raw()
raw():
BlockBytes
Returns a Array of the raw Bytes Arrays of this block, in order.
Returns
Defined in
requestsTrieIsValid()
requestsTrieIsValid():
Promise
<boolean
>
Returns
Promise
<boolean
>
Defined in
serialize()
serialize():
Uint8Array
Returns the rlp encoding of the block.
Returns
Uint8Array
Defined in
toExecutionPayload()
toExecutionPayload():
ExecutionPayload
Returns
Defined in
toJSON()
toJSON():
JsonBlock
Returns the block in JSON format.
Returns
Defined in
transactionsAreValid()
transactionsAreValid():
boolean
Validates transaction signatures and minimum gas requirements.
Returns
boolean
True if all transactions are valid, false otherwise
Defined in
transactionsTrieIsValid()
transactionsTrieIsValid():
Promise
<boolean
>
Validates the transaction trie by generating a trie and do a check on the root hash.
Returns
Promise
<boolean
>
True if the transaction trie is valid, false otherwise
Defined in
uncleHashIsValid()
uncleHashIsValid():
boolean
Validates the uncle’s hash.
Returns
boolean
true if the uncle’s hash is valid, false otherwise.
Defined in
validateBlobTransactions()
validateBlobTransactions(
parentHeader
):void
Validates that blob gas fee for each transaction is greater than or equal to the blobGasPrice for the block and that total blob gas in block is less than maximum blob gas per block
Parameters
• parentHeader: BlockHeader
header of parent block
Returns
void
Defined in
validateData()
validateData(
onlyHeader
,verifyTxs
):Promise
<void
>
Validates the block data, throwing if invalid. This can be checked on the Block itself without needing access to any parent block It checks:
- All transactions are valid
- The transactions trie is valid
- The uncle hash is valid
Parameters
• onlyHeader: boolean
= false
if only passed the header, skip validating txTrie and unclesHash (default: false)
• verifyTxs: boolean
= true
if set to false
, will not check for transaction validation errors (default: true)
Returns
Promise
<void
>
Defined in
validateGasLimit()
validateGasLimit(
parentBlock
):void
Validates if the block gasLimit remains in the boundaries set by the protocol. Throws if invalid
Parameters
• parentBlock: Block
the parent of this Block
Returns
void
Defined in
validateUncles()
validateUncles():
void
Consistency checks for uncles included in the block, if any.
Throws if invalid.
The rules for uncles checked are the following: Header has at most 2 uncles. Header does not count an uncle twice.
Returns
void
Defined in
withdrawalsTrieIsValid()
withdrawalsTrieIsValid():
Promise
<boolean
>
Validates the withdrawal root
Returns
Promise
<boolean
>
true if the withdrawals trie root is valid, false otherwise
Defined in
fromBeaconPayloadJson()
static
fromBeaconPayloadJson(payload
,opts
):Promise
<Block
>
Method to retrieve a block from a beacon payload json
Parameters
• payload: BeaconPayloadJson
json of a beacon beacon fetched from beacon apis
• opts: BlockOptions
Returns
Promise
<Block
>
the block constructed block
Defined in
fromBlockData()
static
fromBlockData(blockData
,opts
):Block
Static constructor to create a block from a block data dictionary
Parameters
• blockData: BlockData
• opts: BlockOptions
Returns
Defined in
fromExecutionPayload()
static
fromExecutionPayload(payload
,opts
):Promise
<Block
>
Method to retrieve a block from an execution payload
Parameters
• payload: ExecutionPayload
• opts: BlockOptions
Returns
Promise
<Block
>
the block constructed block
Defined in
fromRLPSerializedBlock()
static
fromRLPSerializedBlock(serialized
,opts
):Block
Static constructor to create a block from a RLP-serialized block
Parameters
• serialized: Uint8Array
• opts: BlockOptions
Returns
Defined in
fromValuesArray()
static
fromValuesArray(values
,opts
):Block
Static constructor to create a block from an array of Bytes values
Parameters
• values: BlockBytes
• opts: BlockOptions
Returns
Defined in
genRequestsTrieRoot()
static
genRequestsTrieRoot(requests
,emptyTrie
?):Promise
<Uint8Array
>
Returns the requests trie root for an array of CLRequests
Parameters
• requests: ClRequest
[]
an array of CLRequests
• emptyTrie?: Trie
optional empty trie used to generate the root
Returns
Promise
<Uint8Array
>
a 32 byte Uint8Array representing the requests trie root
Defined in
genTransactionsTrieRoot()
static
genTransactionsTrieRoot(txs
,emptyTrie
?):Promise
<Uint8Array
>
Returns the txs trie root for array of TypedTransaction
Parameters
• txs: TypedTransaction
[]
array of TypedTransaction to compute the root of
• emptyTrie?: Trie
Returns
Promise
<Uint8Array
>
Defined in
genWithdrawalsTrieRoot()
static
genWithdrawalsTrieRoot(wts
,emptyTrie
?):Promise
<Uint8Array
>
Returns the withdrawals trie root for array of Withdrawal.
Parameters
• wts: Withdrawal
[]
array of Withdrawal to compute the root of
• emptyTrie?: Trie
Returns
Promise
<Uint8Array
>