Class BlockDataExtensions
Extension methods for querying block data from the mirror node.
Inherited Members
Namespace: Hiero.Mirror
Assembly: Hiero.dll
Syntax
public static class BlockDataExtensions
Methods
| Edit this page View SourceGetBlockAsync(MirrorRestClient, long)
Retrieves a single block by number from
/api/v1/blocks/{blockNumber}.
Declaration
public static Task<BlockData?> GetBlockAsync(this MirrorRestClient client, long blockNumber)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| long | blockNumber | Block Number |
Returns
| Type | Description |
|---|---|
| Task<BlockData> | Information for the block, or null if not found. |
GetBlockAsync(MirrorRestClient, ReadOnlyMemory<byte>)
Retrieves a single block by hash from
/api/v1/blocks/{blockHash}.
Declaration
public static Task<BlockData?> GetBlockAsync(this MirrorRestClient client, ReadOnlyMemory<byte> blockhash)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| ReadOnlyMemory<byte> | blockhash | The block hash bytes — accepts the 48-byte Hedera SHA-384 record-file hash returned by the mirror, or a 32-byte EVM block hash for callers that have one. |
Returns
| Type | Description |
|---|---|
| Task<BlockData> | Information for the block, or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
GetBlocksAsync(MirrorRestClient, params IMirrorQueryParameter[])
Enumerates blocks from the chain. Default ordering is newest-first; pass Ascending to reverse. Pair with BlockNumberFilter or TimestampFilter to bound a range.
Declaration
public static IAsyncEnumerable<BlockData> GetBlocksAsync(this MirrorRestClient client, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| IMirrorQueryParameter[] | filters | Additional query filters. The endpoint supports BlockNumberFilter, TimestampFilter, PageLimit, and OrderBy. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<BlockData> | An async enumerable of block records. |
GetLatestBlockAsync(MirrorRestClient)
Retrieves the most recent block observed by the mirror node via
/api/v1/blocks?limit=1&order=desc (there is no
dedicated "latest block" endpoint).
Declaration
public static Task<BlockData?> GetLatestBlockAsync(this MirrorRestClient client)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
Returns
| Type | Description |
|---|---|
| Task<BlockData> | Block information for the latest known block, or null if there was an error. |
GetLatestBlockBeforeConsensusAsync(MirrorRestClient, ConsensusTimeStamp)
Retrieves the latest known block before the given consensus timestamp.
Declaration
public static Task<BlockData?> GetLatestBlockBeforeConsensusAsync(this MirrorRestClient client, ConsensusTimeStamp consensus)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| ConsensusTimeStamp | consensus | The consensus timestamp |
Returns
| Type | Description |
|---|---|
| Task<BlockData> | Block info for the latest block before the given timestamp |