transfer method

  1. @override
Future<(String, bool)> transfer({
  1. required Account account,
  2. required String recipientAddress,
  3. required double amount,
  4. required double fee,
})
override

transfer coins from the account address to the a recipient address

Implementation

@override
Future<(String, bool)> transfer({
  required Account account,
  required String recipientAddress,
  required double amount,
  required double fee,
}) async {
  try {
    final status = await _grpc.getStatus();
    final expirePeriod = status.lastExecutedFinalSlot.period + status.config.operationValidityPeriods;
    final operation = await sendTransaction(account, recipientAddress, amount, fee, expirePeriod.toInt());
    String operationID = "";
    await for (final resp in _grpc.sendOperations([operation])) {
      if (resp.operationIds.operationIds.isEmpty) {
        return (operationID, false);
      }
      operationID = resp.operationIds.operationIds[0];
      final status = await waitForFinalOperationStatus(operationID);
      return (operationID, status);
    }
    return (operationID, false);
  } catch (error) {
    throw Exception(error);
  }
}