sendTokens method Null safety

Future<PaymentResponse> sendTokens(
  1. String recipient,
  2. int amount,
  3. {String? memo}
)

Sending Tokens

Creates a TX in order to deposit the amount of SNR into the recipient account. A succesful transaction will return a PaymentResponse and will return null if the transaction fails.

final res = await MotorFlutter.to.deposit('did:snr:abc123', 3.29);
if (res == null) {
   throw Exception('Failed to deposit SNR');
}
print(res); // prints: {txHash: '0x1234567890abcdef', amount: 3.29}

Next Steps

Implementation

Future<PaymentResponse> sendTokens(String recipient, int amount, {String? memo}) async {
  final res = await MotorFlutterPlatform.instance.issuePayment(PaymentRequest(
    to: recipient,
    from: address.value,
    amount: Int64(amount),
    memo: memo,
  ));
  if (res == null) {
    throw UnmarshalException<PaymentResponse>();
  }
  return res;
}