Block
A Block represents the data associated with a full block on Ethereum.
Extended by
Implements
BlockParams
Iterable
<string
>
Constructors
new Block()
new Block(block, provider): Block
Create a new Block object.
This should generally not be necessary as the unless implementing a low-level library.
Parameters
Parameter | Type | Description |
---|---|---|
block | BlockParams | The block parameters. |
provider | Provider | The provider. |
Returns
Source
Properties
Property | Modifier | Type | Description |
---|---|---|---|
provider | readonly | Provider | The provider connected to the block used to fetch additional details if necessary. |
Accessors
date
get date(): null | Date
The Date this block was included at.
Returns
null
| Date
The date this block was included at, or null if the timestamp is not available.
Source
extTransactions
get extTransactions(): readonly string[]
Returns the list of extended transaction hashes, in the order they were executed within the block.
Returns
readonly string
[]
The list of extended transaction hashes.
Source
length
get length(): number
The number of transactions in this block.
Returns
number
The number of transactions.
Source
prefetchedExtTransactions
get prefetchedExtTransactions(): ExternalTransactionResponse[]
Returns the complete extended transactions, in the order they were executed within the block.
This is only available for blocks which prefetched transactions, by passing true
to prefetchTxs
into
getBlock.
Throws
If the transactions were not prefetched.
Returns
ExternalTransactionResponse
[]
The list of prefetched extended transactions.
Source
prefetchedTransactions
get prefetchedTransactions(): TransactionResponse[]
Returns the complete transactions, in the order they were executed within the block.
This is only available for blocks which prefetched transactions, by passing true
to prefetchTxs
into
getBlock.
Throws
If the transactions were not prefetched.
Returns
The list of prefetched transactions.
Source
transactions
get transactions(): readonly string[]
Returns the list of transaction hashes, in the order they were executed within the block.
Returns
readonly string
[]
The list of transaction hashes.
Source
Methods
getExtTransaction()
getExtTransaction(indexOrHash): Promise<ExternalTransactionResponse>
Get the extended transaction at index
within this block.
Parameters
Parameter | Type | Description |
---|---|---|
indexOrHash | string | number | The index or hash of the extended transaction. |
Returns
Promise
<ExternalTransactionResponse
>
A promise resolving to the extended transaction.
Throws
If the extended transaction is not found.
Source
getPrefetchedTransaction()
getPrefetchedTransaction(indexOrHash): TransactionResponse
If a Block was fetched with a request to include the transactions this will allow synchronous access to those transactions.
If the transactions were not prefetched, this will throw.
Parameters
Parameter | Type | Description |
---|---|---|
indexOrHash | string | number | The index or hash of the transaction. |
Returns
The transaction.
Throws
If the transaction is not found.
Source
getTransaction()
getTransaction(indexOrHash): Promise<TransactionResponse | ExternalTransactionResponse>
Get the transaction at index
within this block.
Parameters
Parameter | Type | Description |
---|---|---|
indexOrHash | string | number | The index or hash of the transaction. |
Returns
Promise
<TransactionResponse
| ExternalTransactionResponse
>
A promise resolving to the transaction.
Throws
If the transaction is not found.
Source
isMined()
isMined(): this is MinedBlock
Returns true if this block been mined. This provides a type guard for all properties on a MinedBlock.
Returns
this is MinedBlock
True if the block has been mined.
Source
toJSON()
toJSON(): any
Returns a JSON-friendly value.
Returns
any
The JSON-friendly value.
Source
Was this page helpful?