Hi I was working with Stellar on Javascript for offline signing and to keep the QR code after signing short I enveloped the transaction and converted it to XDR.


const signedTx = await transaction.toEnvelope().toXDR('base64');

Now how do I convert it back to the transaction object so that I can submit it?

I tried submitting this transaction but I keep on getting the error,

TypeError: transaction.toEnvelope is not a function
     at Server.<anonymous> (/opt/game/main/node_modules/stellar-sdk/lib/server.js:115:22)
     at step (/opt/game/main/node_modules/tslib/tslib.js:136:27)
     at Object.next (/opt/game/main/node_modules/tslib/tslib.js:117:57)
     at /opt/game/main/node_modules/tslib/tslib.js:110:75
     at new Promise (<anonymous>)
     at Object.__awaiter (/opt/game/main/node_modules/tslib/tslib.js:106:16)
     at Server.submitTransaction (/opt/game/node_modules/stellar-sdk/lib/server.js:111:24)

Alright even though I could not find any function to deserialize the signedTx, I did find a way.

If you create a new StellarSdk Object, call Transaction and input signedTx as a parameter into it, you get back the original transaction object.

Like so,

const transaction = new StelladSdk.Transaction(signedTx);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.