transfer method

void transfer({
  1. required String ledgerId,
  2. required Uint8List fromAccountId,
  3. required Uint8List toAccountId,
  4. required Int64 amount,
  5. String? memo,
})

Implementation

void transfer({
  required String ledgerId,
  required Uint8List fromAccountId,
  required Uint8List toAccountId,
  required Int64 amount,
  String? memo,
}) {
  final metadata = <Any>[];
  if (memo != null) {
    metadata.add(Metadata.memo(memo));
  }

  final rand = Random.secure();
  final transfer = tx.CreateLedgerTransfer()
    ..ledgerId = ledgerId
    ..nonce = Int64.fromInts(rand.nextInt(1 << 32), rand.nextInt(1 << 32))
    ..transfer = (tx.CreateTransfer()
      ..setSteps([
        tx.TransferStep()
          ..fromAccountId = fromAccountId
          ..toAccountId = toAccountId
          ..amount = amount
          ..setMetadata(metadata)
      ]));

  _transfers.add(transfer);
}