<p>Your variable <code>signedCborTransaction</code> is just key witnesses for inputs being spent in this transaction that belong to your wallet, specifically, it's CBOR of <code>transaction_witness_set</code> with only entries for <code>0</code>th key as per <a href="https://github.com/input-output-hk/cardano-ledger/blob/bf2dc0fdde313723b4f7a35362839920670e67ea/eras/babbage/test-suite/cddl-files/babbage.cddl#L293-L294" rel="nofollow noreferrer">this</a> CDDL specification.
You would need to add this witness to your original transaction (<code>cborEncodedTransaction</code>) and then submit it.</p>

CC BY-SA 4.0
2023-08-12T11:08:06.557Z
2023-08-12T11:08:06.557Z
Sourabh
<p>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.</p>
<p>the script that i paste on devtools console:</p>
<pre><code>// Replace this with your transaction data
const cborEncodedTransaction =
  // Your CBOR encoded transaction data here
  &quot;MY_TX_CBOR&quot;;

// Replace this with your API key from Blockfrost
const apiKey = &quot;PROJECT_ID_BLOCKFROST&quot;;

async function signAndSubmitTransaction(cborEncodedTransaction) {
  try {
    // Check if Nami Wallet is available
    if (!window.cardano) {
      throw new Error(&quot;Nami Wallet is not available. Make sure you have the Nami Wallet extension installed.&quot;);
    }

    // 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(&quot;Signed Transaction (hex-encoded):&quot;, signedCborTransaction);

    // Submit the transaction using Blockfrost API
    console.log(&quot;Submitting transaction to Blockfrost...&quot;);
    console.log(&quot;CBOR Encoded Transaction with Witness:&quot;, signedCborTransaction);

    const response = await fetch(&quot;https://cardano-mainnet.blockfrost.io/api/v0/tx/submit&quot;, {
      method: &quot;POST&quot;,
      headers: {
        &quot;Content-Type&quot;: &quot;application/cbor&quot;,
        &quot;Project_id&quot;: apiKey,
      },
      body: signedCborTransaction,
    });

    console.log(&quot;Blockfrost Response Status:&quot;, response.status);
    console.log(&quot;Blockfrost Response Data:&quot;, await response.json());

    if (!response.ok) {
      const errorData = await response.json();
      throw new Error(`Blockfrost API error: ${errorData.error}, ${errorData.message}`);
    }

    console.log(&quot;Transaction submitted successfully.&quot;);
  } catch (error) {
    console.error(&quot;Error signing or submitting transaction:&quot;, error);
    throw error;
  }
}

// Call the signAndSubmitTransaction function with the transaction data
signAndSubmitTransaction(cborEncodedTransaction);
</code></pre>
<p>the error that i get:</p>
<pre><code>{
    &quot;error&quot;: &quot;Bad Request&quot;,
    &quot;message&quot;: &quot;\&quot;transaction read error RawCborDecodeError [DecoderErrorDeserialiseFailure \\\&quot;Byron Tx\\\&quot; (DeserialiseFailure 0 \\\&quot;expected list len\\\&quot;),DecoderErrorDeserialiseFailure \\\&quot;Shelley Tx\\\&quot; (DeserialiseFailure 0 \\\&quot;expected list len or indef\\\&quot;),DecoderErrorDeserialiseFailure \\\&quot;Shelley Tx\\\&quot; (DeserialiseFailure 0 \\\&quot;expected list len or indef\\\&quot;),DecoderErrorDeserialiseFailure \\\&quot;Shelley Tx\\\&quot; (DeserialiseFailure 0 \\\&quot;expected list len or indef\\\&quot;),DecoderErrorDeserialiseFailure \\\&quot;Shelley Tx\\\&quot; (DeserialiseFailure 0 \\\&quot;expected list len or indef\\\&quot;),DecoderErrorDeserialiseFailure \\\&quot;Shelley Tx\\\&quot; (DeserialiseFailure 0 \\\&quot;expected list len or indef\\\&quot;)]\&quot;&quot;,
    &quot;status_code&quot;: 400
}
</code></pre>
<p>the nami window pops up with the correct transaction for me to signed it, and after that the error happens.</p>

<transaction><nami-wallet><cbor>
Console devtools sign and submit transaction
# Console devtools sign and submit transaction

(Asked by: username_0 on 2023-08-10)

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.

**Tags:** transaction, nami-wallet, cbor

---

## 1 answers

### Answer by username_1 on 2023-08-12. Score: 0

Your variable `signedCborTransaction` is just key witnesses for inputs being spent in this transaction that belong to your wallet, specifically, it's CBOR of `transaction_witness_set` with only entries for `0`th key as per [this](https://github.com/input-output-hk/cardano-ledger/blob/bf2dc0fdde313723b4f7a35362839920670e67ea/eras/babbage/test-suite/cddl-files/babbage.cddl#L293-L294) CDDL specification.
You would need to add this witness to your original transaction (`cborEncodedTransaction`) and then submit it.


---

