Skip to content

Get Transactions info

Wei Hau Lim edited this page May 12, 2022 · 7 revisions

Get transaction information by transaction id or hash

  • Following parameters required:
    • Transaction Group Type - the type of the transaction group
      • Example: TransactionGroupType.confirmed
    • Transaction ID or hash - identifier of transaction to get info about
      • Example transaction id: "5EF58A3EB0A01400011A01F7"
      • Example transaction hash: "B090128A7D4D2C317B964C6951C0CD7C48899A40C5F936221159A288E4C77B93"
import 'package:xpx_chain_sdk/xpx_sdk.dart';

const baseUrl = 'http://bctestnet3.brimstone.xpxsirius.io:3000';

/// Creating a client instance
/// xpx_chain_sdk uses the Dart's native HttpClient.
/// Depending on the platform, you may want to use either
/// the one which comes from dart:io or the BrowserClient
/// example:
/// 1- import 'package:http/browser_client.dart';
/// 2- var client = newClient(config,  BrowserClient());
final client = SiriusClient.fromUrl(baseUrl, null);

/// Simple Transactions API request
void main() async {

  const hash =
    'B090128A7D4D2C317B964C6951C0CD7C48899A40C5F936221159A288E4C77B93';

  try {
    /// Get a transaction information given a transactionId or hash.
    final result = await client.transaction
        .getTransaction(TransactionGroupType.confirmed, hash);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Transaction->GetTransaction: $e\n');
  }
}

Get transaction informations for a given list of transaction ids or hashes

  • Following parameters required:
    • Transaction IDs or hashes - identifiers of transactions to get info about
    • Transaction Group Type - the type of the transaction group
  const hash1 = 'B090128A7D4D2C317B964C6951C0CD7C48899A40C5F936221159A288E4C77B93';
  const hash2 = 'FF91ABCF52C042A77F0B35BD6E629A0E8932839FC1D23A894B4F8642211A0F21';
  try {
    /// Get a List of Transaction information for a given List of transactionIds.
    final result = await client.transaction.getTransactions([hash1,hash2], TransactionGroupType.confirmed);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Transaction->GetTransactions: $e\n');
  }