sendPayment method

Future<String> sendPayment({
  1. required Account account,
  2. required Address recipient,
  3. required BigInt amount,
  4. String? note,
  5. bool waitForConfirmation = false,
  6. int? timeout,
})

Send a payment to the given recipient with the recommended transaction parameters.

Account is the account used as the sender and signer of the transaction. Recipient is the address of the recipient Amount is the number of Algos to send (in microAlgos) You can pass an optional note. You can use the waitForConfirmation parameter to asynchronously wait on the transaction to be commited on the blockchain.

The timeout parameter indicates how many rounds do you wish to check pending transactions for.

Throws an AlgorandException if unable to send the payment.

Implementation

Future<String> sendPayment({
  required Account account,
  required Address recipient,
  required BigInt amount,
  String? note,
  bool waitForConfirmation = false,
  int? timeout,
}) async {
  // Fetch the suggested transaction params
  final params = await getSuggestedTransactionParams();

  // Build the transaction
  final transaction = await (PaymentTransactionBuilder()
        ..sender = account.address
        ..noteText = note
        ..amount = amount
        ..receiver = recipient
        ..suggestedParams = params)
      .build();

  // Sign the transaction
  final signedTx = await transaction.sign(account);

  // Send the transaction
  return sendTransaction(
    signedTx,
    waitForConfirmation: waitForConfirmation,
    timeout: timeout ?? _options.timeout,
  );
}