so i'm runing this to prompt a transaction on nami wallet, sign and submit. the ideal scenario was to nami wallet submit transaction for herself but somehow that is not happening, so i tried to submit via blockfrost api.
the script that i paste on devtools console:
// Replace this with your transaction data
const cborEncodedTransaction =
// Your CBOR encoded transaction data here
"MY_TX_CBOR";
// Replace this with your API key from Blockfrost
const apiKey = "PROJECT_ID_BLOCKFROST";
async function signAndSubmitTransaction(cborEncodedTransaction) {
try {
// Check if Nami Wallet is available
if (!window.cardano) {
throw new Error("Nami Wallet is not available. Make sure you have the Nami Wallet extension installed.");
}
// Sign the transaction using Nami Wallet
const partialSign = true; // Set this to true to enable partial signing
const transactionWitnessSet = await window.cardano.signTx(cborEncodedTransaction, partialSign);
// Convert the transactionWitnessSet to a hex-encoded string
const signedCborTransaction = transactionWitnessSet;
console.log("Signed Transaction (hex-encoded):", signedCborTransaction);
// Submit the transaction using Blockfrost API
console.log("Submitting transaction to Blockfrost...");
console.log("CBOR Encoded Transaction with Witness:", signedCborTransaction);
const response = await fetch("https://cardano-mainnet.blockfrost.io/api/v0/tx/submit", {
method: "POST",
headers: {
"Content-Type": "application/cbor",
"Project_id": apiKey,
},
body: signedCborTransaction,
});
console.log("Blockfrost Response Status:", response.status);
console.log("Blockfrost Response Data:", await response.json());
if (!response.ok) {
const errorData = await response.json();
throw new Error(`Blockfrost API error: ${errorData.error}, ${errorData.message}`);
}
console.log("Transaction submitted successfully.");
} catch (error) {
console.error("Error signing or submitting transaction:", error);
throw error;
}
}
// Call the signAndSubmitTransaction function with the transaction data
signAndSubmitTransaction(cborEncodedTransaction);
the error that i get:
{
"error": "Bad Request",
"message": "\"transaction read error RawCborDecodeError [DecoderErrorDeserialiseFailure \\\"Byron Tx\\\" (DeserialiseFailure 0 \\\"expected list len\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\"),DecoderErrorDeserialiseFailure \\\"Shelley Tx\\\" (DeserialiseFailure 0 \\\"expected list len or indef\\\")]\"",
"status_code": 400
}
the nami window pops up with the correct transaction for me to signed it, and after that the error happens.