Class ContractResultDataExtensions
Extension methods for querying contract execution results from the mirror node.
Inherited Members
Namespace: Hiero.Mirror
Assembly: Hiero.dll
Syntax
public static class ContractResultDataExtensions
Methods
| Edit this page View SourceGetAllContractResultsAsync(MirrorRestClient, params IMirrorQueryParameter[])
Enumerates contract-call results across every contract on the
network from /api/v1/contracts/results. Same filter
palette as GetContractResultsAsync(MirrorRestClient, EntityId, CancellationToken, params IMirrorQueryParameter[]), without the
per-contract scoping, plus the
HbarTransferProjectionFilter toggle on the
HBAR-transfer subtree.
Declaration
public static IAsyncEnumerable<ContractResultData> GetAllContractResultsAsync(this MirrorRestClient client, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports BlockHashFilter, BlockNumberFilter, EvmSenderFilter, HbarTransferProjectionFilter, InternalProjectionFilter, TimestampFilter, TransactionIndexFilter, PageLimit, and OrderBy. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<ContractResultData> | An async enumerable of contract-call records. Empty when no results match the supplied criteria. |
GetAllContractResultsAsync(MirrorRestClient, CancellationToken, params IMirrorQueryParameter[])
Enumerates contract-call results across every contract on the
network from /api/v1/contracts/results. Same filter
palette as GetContractResultsAsync(MirrorRestClient, EntityId, CancellationToken, params IMirrorQueryParameter[]), without the
per-contract scoping, plus the
HbarTransferProjectionFilter toggle on the
HBAR-transfer subtree.
Declaration
public static IAsyncEnumerable<ContractResultData> GetAllContractResultsAsync(this MirrorRestClient client, CancellationToken cancellationToken, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| CancellationToken | cancellationToken | Token that cancels the enumeration, including a page request in
flight. |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports BlockHashFilter, BlockNumberFilter, EvmSenderFilter, HbarTransferProjectionFilter, InternalProjectionFilter, TimestampFilter, TransactionIndexFilter, PageLimit, and OrderBy. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<ContractResultData> | An async enumerable of contract-call records. Empty when no results match the supplied criteria. |
GetChainIdAsync(MirrorRestClient, CancellationToken)
Retrieves the EVM chain id (EIP-155) that this mirror's network uses.
Declaration
public static Task<BigInteger> GetChainIdAsync(this MirrorRestClient client, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| CancellationToken | cancellationToken | Optional token that cancels the request. |
Returns
| Type | Description |
|---|---|
| Task<BigInteger> | The Chain ID of the network. |
Remarks
The mirror node has no dedicated chain-id endpoint: chain_id is
only populated on contract results that wrapped an
EthereumTransaction — HAPI-native contract calls report it as
zero. This method therefore locates the most recent Ethereum-wrapped
transaction (/api/v1/transactions?transactiontype=ethereumtransaction)
and reads the chain id from its contract result, which is reliable across
the network's whole history rather than just a recent window. It remains
best-effort: a network that has never processed an EthereumTransaction
(e.g. a freshly-started local network) exposes the value nowhere, and the
method throws rather than returning a fabricated value — a wrong or zero
chain id would sign a transaction the network later rejects with
WrongChainId. Chain id is static network
configuration, so callers should cache the result rather than re-derive
it per call, or supply a known value directly.
Exceptions
| Type | Condition |
|---|---|
| MirrorException | Thrown when the mirror node holds no Ethereum-wrapped transaction from which to read the chain id (typically a network with no EVM/relay traffic yet, such as a freshly-started local network), or when the contract result of the most recent one is unavailable or carries no chain id. |
GetContractResultByBlockAndPositionAsync(MirrorRestClient, ReadOnlyMemory<byte>, long, CancellationToken)
Retrieves a single contract-call result by its position within a
block, via
/api/v1/contracts/results?block.hash={hash}&transaction.index={position}.
The server returns a list and this method unwraps the first
item — a matching result should be unique for a given (block,
position) pair.
Declaration
public static Task<ContractResultData?> GetContractResultByBlockAndPositionAsync(this MirrorRestClient client, ReadOnlyMemory<byte> blockHash, long position, CancellationToken cancellationToken = default)
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. |
| long | position | The transaction position within the block. |
| CancellationToken | cancellationToken | Optional token that cancels the request. |
Returns
| Type | Description |
|---|---|
| Task<ContractResultData> | The contract results data or null if not found. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |
GetContractResultByTimestampAsync(MirrorRestClient, EntityId, ConsensusTimeStamp, params IMirrorQueryParameter[])
Retrieves the single contract result produced by the given contract at the given consensus timestamp — useful when the timestamp is already known (e.g., from a transaction record or a block listing) and a txid/hash lookup is not available.
Declaration
public static Task<ContractResultData?> GetContractResultByTimestampAsync(this MirrorRestClient client, EntityId contract, ConsensusTimeStamp timestamp, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| EntityId | contract | The contract whose result is requested. |
| ConsensusTimeStamp | timestamp | The consensus timestamp identifying the execution. |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports HbarTransferProjectionFilter to opt out of the HBAR-transfer subtree on the returned record. |
Returns
| Type | Description |
|---|---|
| Task<ContractResultData> | The contract result, or null if not found. |
GetContractResultByTimestampAsync(MirrorRestClient, EntityId, ConsensusTimeStamp, CancellationToken, params IMirrorQueryParameter[])
Retrieves the single contract result produced by the given contract at the given consensus timestamp — useful when the timestamp is already known (e.g., from a transaction record or a block listing) and a txid/hash lookup is not available.
Declaration
public static Task<ContractResultData?> GetContractResultByTimestampAsync(this MirrorRestClient client, EntityId contract, ConsensusTimeStamp timestamp, CancellationToken cancellationToken, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| EntityId | contract | The contract whose result is requested. |
| ConsensusTimeStamp | timestamp | The consensus timestamp identifying the execution. |
| CancellationToken | cancellationToken | Token that cancels the request. |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports HbarTransferProjectionFilter to opt out of the HBAR-transfer subtree on the returned record. |
Returns
| Type | Description |
|---|---|
| Task<ContractResultData> | The contract result, or null if not found. |
GetContractResultByTransactionHashAsync(MirrorRestClient, EvmHash, params IMirrorProjection[])
Retrieve the contract results for a specific transaction by hash.
Declaration
public static Task<ContractResultData?> GetContractResultByTransactionHashAsync(this MirrorRestClient client, EvmHash evmTransactionHash, params IMirrorProjection[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| EvmHash | evmTransactionHash | The EVM TransactionId hash (not to be confused with the raw HAPI transaction hash) |
| IMirrorProjection[] | filters | Optional projection toggles recognized by this endpoint — currently HbarTransferProjectionFilter, which controls whether the HBAR-transfer subtree is included in the returned record. |
Returns
| Type | Description |
|---|---|
| Task<ContractResultData> | The contract results data, or null if not found. |
GetContractResultByTransactionHashAsync(MirrorRestClient, EvmHash, CancellationToken, params IMirrorProjection[])
Retrieve the contract results for a specific transaction by hash.
Declaration
public static Task<ContractResultData?> GetContractResultByTransactionHashAsync(this MirrorRestClient client, EvmHash evmTransactionHash, CancellationToken cancellationToken, params IMirrorProjection[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| EvmHash | evmTransactionHash | The EVM TransactionId hash (not to be confused with the raw HAPI transaction hash) |
| CancellationToken | cancellationToken | Token that cancels the request. |
| IMirrorProjection[] | filters | Optional projection toggles recognized by this endpoint — currently HbarTransferProjectionFilter, which controls whether the HBAR-transfer subtree is included in the returned record. |
Returns
| Type | Description |
|---|---|
| Task<ContractResultData> | The contract results data, or null if not found. |
GetContractResultByTransactionIdAsync(MirrorRestClient, TransactionId, params IMirrorProjection[])
Retrieve the contract results for a specific transaction by HAPI transaction ID
Declaration
public static Task<ContractResultData?> GetContractResultByTransactionIdAsync(this MirrorRestClient client, TransactionId transactionId, params IMirrorProjection[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| TransactionId | transactionId | The HAPI transaction id, not the EVM transaction hash |
| IMirrorProjection[] | filters | Optional projection toggles recognized by this endpoint — currently HbarTransferProjectionFilter, which controls whether the HBAR-transfer subtree is included in the returned record. |
Returns
| Type | Description |
|---|---|
| Task<ContractResultData> | The contract results data or null if not found |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the transaction id is scheduled: this mirror node route cannot select a scheduled transaction. |
GetContractResultByTransactionIdAsync(MirrorRestClient, TransactionId, CancellationToken, params IMirrorProjection[])
Retrieve the contract results for a specific transaction by HAPI transaction ID
Declaration
public static Task<ContractResultData?> GetContractResultByTransactionIdAsync(this MirrorRestClient client, TransactionId transactionId, CancellationToken cancellationToken, params IMirrorProjection[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| TransactionId | transactionId | The HAPI transaction id, not the EVM transaction hash |
| CancellationToken | cancellationToken | Token that cancels the request. |
| IMirrorProjection[] | filters | Optional projection toggles recognized by this endpoint — currently HbarTransferProjectionFilter, which controls whether the HBAR-transfer subtree is included in the returned record. |
Returns
| Type | Description |
|---|---|
| Task<ContractResultData> | The contract results data or null if not found |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If the transaction id is scheduled: this mirror node route cannot select a scheduled transaction. |
GetContractResultsAsync(MirrorRestClient, EntityId, params IMirrorQueryParameter[])
Enumerates calls made to a specific contract from
/api/v1/contracts/{id}/results, regardless of how the
call was routed (HAPI or JSON-RPC). Use
TimestampFilter or BlockNumberFilter
to bracket a range, EvmSenderFilter to narrow by
EVM caller, or InternalProjectionFilter to include
child-transaction calls. Newest-first by default; pass
Ascending to reverse.
Declaration
public static IAsyncEnumerable<ContractResultData> GetContractResultsAsync(this MirrorRestClient client, EntityId contract, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| EntityId | contract | The entityId of the contract |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports BlockHashFilter, BlockNumberFilter, EvmSenderFilter, InternalProjectionFilter, TimestampFilter, TransactionIndexFilter, PageLimit, and OrderBy. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<ContractResultData> | An async enumerable of contract-call records. Each record is a
lightweight summary; the full HAPI transaction details require
a separate |
GetContractResultsAsync(MirrorRestClient, EntityId, CancellationToken, params IMirrorQueryParameter[])
Enumerates calls made to a specific contract from
/api/v1/contracts/{id}/results, regardless of how the
call was routed (HAPI or JSON-RPC). Use
TimestampFilter or BlockNumberFilter
to bracket a range, EvmSenderFilter to narrow by
EVM caller, or InternalProjectionFilter to include
child-transaction calls. Newest-first by default; pass
Ascending to reverse.
Declaration
public static IAsyncEnumerable<ContractResultData> GetContractResultsAsync(this MirrorRestClient client, EntityId contract, CancellationToken cancellationToken, params IMirrorQueryParameter[] filters)
Parameters
| Type | Name | Description |
|---|---|---|
| MirrorRestClient | client | Mirror Rest Client to use for the request. |
| EntityId | contract | The entityId of the contract |
| CancellationToken | cancellationToken | Token that cancels the enumeration, including a page request in
flight. |
| IMirrorQueryParameter[] | filters | Additional query parameters. The endpoint supports BlockHashFilter, BlockNumberFilter, EvmSenderFilter, InternalProjectionFilter, TimestampFilter, TransactionIndexFilter, PageLimit, and OrderBy. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<ContractResultData> | An async enumerable of contract-call records. Each record is a
lightweight summary; the full HAPI transaction details require
a separate |
GetContractResultsByBlockHashAsync(MirrorRestClient, ReadOnlyMemory<byte>, CancellationToken)
Enumerates every contract-call result contained in a block,
via /api/v1/contracts/results?block.hash={hash}. Results
are returned in ascending transaction-index order.
Declaration
public static IAsyncEnumerable<ContractResultData> GetContractResultsByBlockHashAsync(this MirrorRestClient client, ReadOnlyMemory<byte> blockHash, CancellationToken cancellationToken = default)
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. |
| CancellationToken | cancellationToken | Optional token that cancels the enumeration, including a page request in
flight. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<ContractResultData> | An async enumerable of contract-call results in the block; may be empty if the block contained no contract calls. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | Thrown when |