sign method

Future<SignedTransaction> sign(
  1. Account account
)

Sign the transaction with the given account.

If the SK's corresponding address is different than the txn sender's, the SK's corresponding address will be assigned as AuthAddr.

Implementation

Future<SignedTransaction> sign(Account account) async {
  // Get the encoded transaction
  final encodedTransaction = getEncodedTransaction();

  // Sign the transaction with secret key
  final signature = await Ed25519().sign(
    encodedTransaction,
    keyPair: account.keyPair,
  );

  // Create the signed transaction with signature
  final signedTransaction = SignedTransaction(
    signature: Uint8List.fromList(signature.bytes),
    transaction: this,
  );

  // Set the auth address
  if (sender != account.address) {
    signedTransaction.authAddress = account.address;
  }

  return signedTransaction;
}