Passing unsigned transaction from server to client for signing


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 tranform the object to a transaction type?


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


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