Passing unsigned transaction from server to client for signing - General - Algorand

Passing unsigned transaction from server to client for signing

post by kubot on Jun 2, 2022

Hello,

I’m currently using a server (nodejs) to generate transactions and then pass them to the client (react) to sign with AlgoSigner and submit with algosdk. I have an issue casting the transaction from object (as fetched from the server) to a transaction type so I can use algosdk and AlgoSigner on that unsigned transaction.

On the server I am constructing the transaction and the returning it with res.end(JSON.stringify(unsignedTx)), the client then fetches the response with const txData = await response.json().

I tried to cast it to an algosdk.Transaction type with const tx = Object.assign(new algosdk.Transaction, {txData}); but that doesn’t seem to work (error: TypeError: Cannot destructure ‘_ref28’ as it is undefined.

** at new f (transaction.ts:202:1))*

Anyone got any ideas on how to transform the object to a transaction type?

Thanks!

613 views 1 link

post by Ben on Jun 2, 2022

Hi Kubot,

Please see the docs here for the best way to encode/decode transaction objects when passing them over the wire: Encoding and Decoding - Algorand Developer Portal

post by kubot on Jun 3, 2022

Thanks Ben, using the approach as suggested on that link did it