I have created new wallet in Nami and Creating a payment using cardano-serialization-lib-asmjs package function its throwing me error Invalid length
Here is my code
setpayLoad(true);
let amount = paymentData.request_amount * 1000000;
const txBuilder = await initTransactionBuilder();
const shelleyOutputAddress = Address.from_bech32(
paymentData.receiving_address
);
const shelleyChangeAddress = Address.from_bech32(changeaddress.current);
txBuilder.add_output(
TransactionOutput.new(
shelleyOutputAddress,
Value.new(BigNum.from_str(amount.toString()))
)
);
const txUnspentOutputs = await getTxUnspentOutputs();
txBuilder.add_inputs_from(txUnspentOutputs, 1);
// calculate the min fee required and send any change to an address
txBuilder.add_change_if_needed(shelleyChangeAddress);
// once the transaction is ready, we build it to get the tx body without witnesses
const txBody = txBuilder.build();
// Tx witness
const transactionWitnessSet = TransactionWitnessSet.new();
const tx = Transaction.new(
txBody,
TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes())
);
let txVkeyWitnesses = await API.current.signTx(Buffer.from(tx.to_bytes(), "utf8").toString("hex"),
true
);
txVkeyWitnesses = TransactionWitnessSet.from_bytes(
Buffer.from(txVkeyWitnesses, "hex")
);
transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());
const signedTx = Transaction.new(tx.body(), transactionWitnessSet);
const submittedTxHash = await API.current.submitTx(
Buffer.from(signedTx.to_bytes(), "utf8").toString("hex")
);
console.log(submittedTxHash);