createSendTx method

SendTx createSendTx({
  1. required Address toAddress,
  2. required BigInt amountRaw,
  3. required List<Utxo> spendableUtxos,
  4. required BigInt feePerInput,
  5. String? note,
})

Implementation

SendTx createSendTx({
  required Address toAddress,
  required BigInt amountRaw,
  required List<Utxo> spendableUtxos,
  required BigInt feePerInput,
  String? note,
}) {
  final txBuilder = TransactionBuilder(utxos: spendableUtxos);
  final selectedUtxos = txBuilder.selectUtxos(
    spendAmount: amountRaw,
    feePerInput: feePerInput,
  );
  final fee = BigInt.from(selectedUtxos.length) * feePerInput;

  return SendTx(
    uri: KaspaUri(
      address: toAddress,
      amount: Amount.raw(amountRaw),
    ),
    amountRaw: amountRaw,
    utxos: selectedUtxos,
    fee: fee,
    note: note,
  );
}