sendTransferTx method

Future<String> sendTransferTx(
  1. String senderAddress,
  2. String targetAddress,
  3. int amountInFlake,
  4. HydraPrivate hydraPrivate, {
  5. int? nonce,
})

Implementation

Future<String> sendTransferTx(
  String senderAddress,
  String targetAddress,
  int amountInFlake,
  HydraPrivate hydraPrivate, {
  int? nonce,
}) async {
  final senderBip44PubKey = hydraPrivate.public.keyByAddress(senderAddress);
  nonce ??= (await getWalletNonce(senderAddress)) + 1;

  final builder = HydraTxBuilder(_networkConfig.network);
  final transferTx = builder.transfer(
    senderBip44PubKey.publicKey(),
    targetAddress,
    amountInFlake,
    nonce,
  );

  final signedTx = hydraPrivate.signHydraTransaction(
    senderAddress,
    transferTx,
  );

  final resp = await sendTx(signedTx.toString());
  return resp;
}