fetchTransaction method

Future<FetchTransactionRes> fetchTransaction({
  1. List<int> transactionIdBytes = const [],
  2. String transactionIdString = "",
  3. CallOptions? options,
})

Returns a FetchTransactionRes object for the transaction at the given transactionId.

transactionIdBytes is an List of integers representing the transaction ID to retrieve

transactionIdString is an String representing the transaction ID to retrieve

options is an CallOptions for runtime options with RPC

Throws an Exception if transaction ID validation fails or an error occurs during the RPC request.

Implementation

Future<FetchTransactionRes> fetchTransaction({
  List<int> transactionIdBytes = const [],
  String transactionIdString = "",
  CallOptions? options,
}) async {
  if (transactionIdBytes.isEmpty && transactionIdString.isEmpty) {
    throw Exception(ErrorMessages.missingTransactionId);
  }

  final FetchTransactionReq request = FetchTransactionReq(
      transactionId: !transactionIdBytes.isEmpty
          ? getTransactionIdFromList(transactionIdBytes)
          : getTransactionIdFromString(transactionIdString));
  final FetchTransactionRes response = await nodeStub.fetchTransaction(
    request,
    options: options,
  );
  return response;
}