<p>Figured it out. I now send my unsigned tx to the client in two forms:</p>
<pre><code>
const tx = await lucid.newTx()
  .payToAddress(request.data.to, request.data.value)
  .complete();

const altFormat = toHex(tx.txComplete.body().to_bytes())

return {
        tx: tx.toString(),
        altFormat: altFormat,
}

</code></pre>
<p>Then on the client side I sign the .tx value but use the altFormat value to construct the final transaction:</p>
<pre><code>
const witnesses = await wallet.signTx(txResult.data.tx);

const witnessSet = C.TransactionWitnessSet.from_bytes(fromHex(witnesses))

const txBody = C.TransactionBody.from_bytes(fromHex(txResult.data.altFormat))

const signedTx = C.Transaction.new(
    txBody,
    witnessSet,
    undefined
)

const result = await wallet.submitTx(toHex(signedTx.to_bytes()));

</code></pre>

CC BY-SA 4.0
2024-08-11T20:28:25.810Z
2024-08-11T20:28:25.810Z
WILL D
<p>Hello and thank you for taking the time to read this.</p>
<p>I am building a transaction using lucid on my backend and returning it to the client. The client is then supposed to sign and submit the transaction using a CIP-30 connection.</p>
<p>Backend:</p>
<pre><code>&gt;   const tx = await lucid.newTx()
&gt;         .payToAddress(request.data.to, request.data.value)
&gt;         .complete();
&gt; 
&gt;     return {
&gt;         tx: tx.toString() // toString converts to cbor hex
&gt;     }
</code></pre>
<p>On my front end I can successfully prompt the user for a signature and get back a witness set using CIP-30's <code>signTx</code> method. This witness set is also in cbor hex.</p>
<p>My issue is that I don't know how to call CIP-30's <code>submitTx</code> method. <strong>How do I put the cbor of the transaction body together with the cbor of the witness set</strong> to get a single cbor string I can use to call <code>submitTx</code>?</p>
<p>My client is React.js with TypeScript. The backend is a node.js environment.</p>
<p>Thanks again!</p>

<transaction><decentralized-applications><development><offchain><cip30>
Sign Then Submit with CIP-30
# Sign Then Submit with CIP-30

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

Hello and thank you for taking the time to read this.
I am building a transaction using lucid on my backend and returning it to the client. The client is then supposed to sign and submit the transaction using a CIP-30 connection.
Backend:
>   const tx = await lucid.newTx()
>         .payToAddress(request.data.to, request.data.value)
>         .complete();
> 
>     return {
>         tx: tx.toString() // toString converts to cbor hex
>     }

On my front end I can successfully prompt the user for a signature and get back a witness set using CIP-30's signTx method. This witness set is also in cbor hex.
My issue is that I don't know how to call CIP-30's submitTx method. How do I put the cbor of the transaction body together with the cbor of the witness set to get a single cbor string I can use to call submitTx?
My client is React.js with TypeScript. The backend is a node.js environment.
Thanks again!

**Tags:** transaction, decentralized-applications, development, offchain, cip30

---

## 1 answers

### Answer by username_0 on 2024-08-11. Score: 0

Figured it out. I now send my unsigned tx to the client in two forms:

const tx = await lucid.newTx()
  .payToAddress(request.data.to, request.data.value)
  .complete();

const altFormat = toHex(tx.txComplete.body().to_bytes())

return {
        tx: tx.toString(),
        altFormat: altFormat,
}


Then on the client side I sign the .tx value but use the altFormat value to construct the final transaction:

const witnesses = await wallet.signTx(txResult.data.tx);

const witnessSet = C.TransactionWitnessSet.from_bytes(fromHex(witnesses))

const txBody = C.TransactionBody.from_bytes(fromHex(txResult.data.altFormat))

const signedTx = C.Transaction.new(
    txBody,
    witnessSet,
    undefined
)

const result = await wallet.submitTx(toHex(signedTx.to_bytes()));


---

