Skip to content

Get Account info

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

Get AccountInfo for an account

Returns AccountInfo for an account.

  • Following parameters required:
    • Address - Address of the account to get info from
/// Simple Account API request
import 'package:xpx_chain_sdk/xpx_sdk.dart';

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

final networkType = NetworkType.PUBLIC_TEST;

/// 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);

void main() async {
  /// Create an Address from a given public key.
  final accountOne = Address.fromPublicKey(
      '3B49BF0A08BB7528E54BB803BEEE0D935B2C800364917B6EFF331368A4232FD5',
      networkType);

  try {
    final result = await client.account.getAccountInfo(accountOne);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Account->GetAccountInfo: $e\n');
  }
}

Get AccountInfo for multiple accounts

Returns AccountInfo for multiple accounts.

  • Following parameters required:
    • List of Addresses - Addresses of the accounts to get info from
  /// Create an Address from a given public key.
  final account1 = Address.fromPublicKey('0D5248B9F8A9F8182DD2379F90F53906F054CC3A6C9FE621B291FD1212A7596A',
      networkType);

  /// Create an Address from a given public key.
  final account2 = Address.fromPublicKey('3B49BF0A08BB7528E54BB803BEEE0D935B2C800364917B6EFF331368A4232FD5',
      networkType);

  try {
    final result = await client.account.getAccountsInfo([account1, account2]);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Account->GetAccountsInfo: $e\n');
  }

Get confirmed transactions information

Gets a list of confirmed transaction for which an account is signer or recipient.

  • Following parameters required:
    • Address - Address of the account to get transactions associated.
  /// Create an Address from a given public key.
  final account = Address.fromPublicKey('0D5248B9F8A9F8182DD2379F90F53906F054CC3A6C9FE621B291FD1212A7596A',
      networkType);

  try {
    final result = await client.account.transactions(account);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Account->Transactions: $e\n');
  }

Get incoming transactions information

  • Get a list of transactions for which an account is the recipient. A transaction is said to be incoming regarding an account if the account is the recipient of a transaction.

  • Following parameters required:

    • Address - Address of the account to get incoming transactions associated.
  /// Create an Address from a given public key.
  final account = Address.fromPublicKey('0D5248B9F8A9F8182DD2379F90F53906F054CC3A6C9FE621B291FD1212A7596A',
      networkType);

  try {
    final result = await client.account.incomingTransactions(account);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Account->IncomingTransactions: $e\n');
  }

Get outgoing transactions information

  • Get a list of transactions for which an account is the sender. A transaction is said to be outgoing regarding an account if the account is the sender of a transaction.

  • Following parameters required:

    • Public Account - account to get outgoing transactions associated.
  /// Create a PublicAccount from a given public key.
  final account = PublicAccount.fromPublicKey('0D5248B9F8A9F8182DD2379F90F53906F054CC3A6C9FE621B291FD1212A7596A',
      networkType);

  try {
    final result = await client.account.outgoingTransactions(account);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Account->OutgoingTransactions: $e\n');
  }

Get unconfirmed transactions information

  • Gets the list of transactions for which an account is the sender or receiver and which have not yet been included in a block.

  • Following parameters required:

    • Address - Address of the account to get unconfirmed transactions associated.
  /// Create an Address from a given public key.
  final account = Address.fromPublicKey('0D5248B9F8A9F8182DD2379F90F53906F054CC3A6C9FE621B291FD1212A7596A',
      networkType);

  try {
    final result = await client.account.unconfirmedTransactions(account);
    print(result);
  } on Exception catch (e) {
    print('Exception when calling Account->UnconfirmedTransactions: $e\n');
  }