sendAda method

  1. @override
Future<Result<ShelleyTransaction, String>> sendAda({
  1. required ShelleyAddress toAddress,
  2. required int lovelace,
  3. int ttl = 0,
  4. int fee = 0,
  5. bool logTxHex = false,
  6. bool logTx = false,
})
override

Send ADA to another address.

Implementation

@override
Future<Result<ShelleyTransaction, String>> sendAda({
  required ShelleyAddress toAddress,
  required int lovelace,
  int ttl = 0,
  int fee = 0,
  bool logTxHex = false,
  bool logTx = false,
}) async {
  final txResult = await buildSpendTransaction(
    toAddress: toAddress,
    lovelace: lovelace,
    ttl: ttl,
    fee: fee,
  );
  if (txResult.isErr()) {
    return Err(txResult.unwrapErr());
  }
  if (logTxHex) {
    print("tx hex: ${HEX.encode(txResult.unwrap().serialize)}");
  }
  if (logTx) {
    print("tx: ${txResult.unwrap().toJson(prettyPrint: true)}");
  }
  final sendResult = submitTransaction(
    tx: txResult.unwrap(),
  );
  return sendResult;
}