createLedgerAccount method

Future<String> createLedgerAccount({
  1. required String parentId,
  2. required String operator,
  3. int? balanceLimit,
  4. String? contextId,
})

Implementation

Future<String> createLedgerAccount({
  required String parentId,
  required String operator,
  int? balanceLimit,
  String? contextId,
}) async {
  final account = CreateLedgerAccount()
    ..parentId = hex.decode(parentId)
    ..balanceLimit = Int64(balanceLimit ?? 0);

  final request = TransactionRequestPayload()
    ..data = (TransactionData()..createLedgerAccount = account);
  final client = getServiceClient(operator);
  final envelop = await requestEnvelope(
    request: request,
    contextId: contextId != null ? hex.decode(contextId) : null,
  );
  final response = await client.tx.createTransaction(envelop);
  return hex.encode(response.accountCreated);
}