Skip to content

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

Block

Defined in

packages/block/src/block.ts:334

Properties

cache

protected cache: object = {}

requestsRoot?

optional requestsRoot: Uint8Array

txTrieRoot?

optional txTrieRoot: Uint8Array

withdrawalsTrieRoot?

optional withdrawalsTrieRoot: Uint8Array

Defined in

packages/block/src/block.ts:55


common

readonly common: object

blockExplorers?

optional blockExplorers: object

Collection of block explorers

Index Signature

[key: string]: ChainBlockExplorer

blockExplorers.default

blockExplorers.default: ChainBlockExplorer

contracts?

optional contracts: object

Collection of contracts

contracts.ensRegistry?

optional contracts.ensRegistry: ChainContract

contracts.ensUniversalResolver?

optional contracts.ensUniversalResolver: ChainContract

contracts.multicall3?

optional contracts.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?

optional custom: Record<string, unknown>

Custom chain data.

ethjsCommon

ethjsCommon: Common

fees?

optional fees: ChainFees<undefined | ChainFormatters>

Modifies how fees are derived.

formatters?

optional formatters: 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?

optional serializers: ChainSerializers<undefined | ChainFormatters, TransactionSerializable>

Modifies how data is serialized (e.g. transactions).

sourceId?

optional sourceId: number

Source Chain ID (ie. the L1 chain)

testnet?

optional testnet: boolean

Flag for test networks

Defined in

packages/block/src/block.ts:45


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

packages/block/src/block.ts:53


readonly header: BlockHeader

Defined in

packages/block/src/block.ts:40


keccakFunction()

protected keccakFunction: (msg) => Uint8Array

Parameters

msg: Uint8Array

Returns

Uint8Array

Defined in

packages/block/src/block.ts:46


requests?

readonly optional requests: ClRequest[]

Defined in

packages/block/src/block.ts:44


transactions

readonly transactions: TypedTransaction[] = []

Defined in

packages/block/src/block.ts:41


uncleHeaders

readonly uncleHeaders: BlockHeader[] = []

Defined in

packages/block/src/block.ts:42


withdrawals?

readonly optional withdrawals: Withdrawal[]

Defined in

packages/block/src/block.ts:43

Methods

errorStr()

errorStr(): string

Return a compact error string representation of the object

Returns

string

Defined in

packages/block/src/block.ts:801


ethashCanonicalDifficulty()

ethashCanonicalDifficulty(parentBlock): bigint

Returns the canonical difficulty for this block.

Parameters

parentBlock: Block

the parent of this Block

Returns

bigint

Defined in

packages/block/src/block.ts:735


genTxTrie()

genTxTrie(): Promise<Uint8Array>

Generates transaction trie for validation.

Returns

Promise<Uint8Array>

Defined in

packages/block/src/block.ts:455


getTransactionsValidationErrors()

getTransactionsValidationErrors(): string[]

Validates transaction signatures and minimum gas requirements.

Returns

string[]

an array of error strings

Defined in

packages/block/src/block.ts:501


hash()

hash(): Uint8Array

Returns the hash of the block.

Returns

Uint8Array

Defined in

packages/block/src/block.ts:434


isGenesis()

isGenesis(): boolean

Determines if this block is the genesis block.

Returns

boolean

Defined in

packages/block/src/block.ts:441


raw()

raw(): BlockBytes

Returns a Array of the raw Bytes Arrays of this block, in order.

Returns

BlockBytes

Defined in

packages/block/src/block.ts:412


requestsTrieIsValid()

requestsTrieIsValid(): Promise<boolean>

Returns

Promise<boolean>

Defined in

packages/block/src/block.ts:478


serialize()

serialize(): Uint8Array

Returns the rlp encoding of the block.

Returns

Uint8Array

Defined in

packages/block/src/block.ts:448


toExecutionPayload()

toExecutionPayload(): ExecutionPayload

Returns

ExecutionPayload

Defined in

packages/block/src/block.ts:767


toJSON()

toJSON(): JsonBlock

Returns the block in JSON format.

Returns

JsonBlock

Defined in

packages/block/src/block.ts:752


transactionsAreValid()

transactionsAreValid(): boolean

Validates transaction signatures and minimum gas requirements.

Returns

boolean

True if all transactions are valid, false otherwise

Defined in

packages/block/src/block.ts:551


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

packages/block/src/block.ts:464


uncleHashIsValid()

uncleHashIsValid(): boolean

Validates the uncle’s hash.

Returns

boolean

true if the uncle’s hash is valid, false otherwise.

Defined in

packages/block/src/block.ts:668


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

packages/block/src/block.ts:622


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

packages/block/src/block.ts:567


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

packages/block/src/block.ts:745


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

packages/block/src/block.ts:711


withdrawalsTrieIsValid()

withdrawalsTrieIsValid(): Promise<boolean>

Validates the withdrawal root

Returns

Promise<boolean>

true if the withdrawals trie root is valid, false otherwise

Defined in

packages/block/src/block.ts:681


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

BlockOptions

Returns

Promise<Block>

the block constructed block

Defined in

packages/block/src/block.ts:325


fromBlockData()

static fromBlockData(blockData, opts): Block

Static constructor to create a block from a block data dictionary

Parameters

blockData: BlockData

opts: BlockOptions

Returns

Block

Defined in

packages/block/src/block.ts:109


fromExecutionPayload()

static fromExecutionPayload(payload, opts): Promise<Block>

Method to retrieve a block from an execution payload

Parameters

payload: ExecutionPayload

opts: BlockOptions

BlockOptions

Returns

Promise<Block>

the block constructed block

Defined in

packages/block/src/block.ts:260


fromRLPSerializedBlock()

static fromRLPSerializedBlock(serialized, opts): Block

Static constructor to create a block from a RLP-serialized block

Parameters

serialized: Uint8Array

opts: BlockOptions

Returns

Block

Defined in

packages/block/src/block.ts:161


fromValuesArray()

static fromValuesArray(values, opts): Block

Static constructor to create a block from an array of Bytes values

Parameters

values: BlockBytes

opts: BlockOptions

Returns

Block

Defined in

packages/block/src/block.ts:177


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

packages/block/src/block.ts:93


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

packages/block/src/block.ts:79


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>

Defined in

packages/block/src/block.ts:66