Before I submit the transaction to the network I want to convert the 'transaction' in XDR format so that I can save it to database for future reference. I am using Stellar JS library. How to do it?
1 Answer
Given transaction
is a Transaction
object then this will give you base64 encoded XDR:
transaction.toEnvelope().toXDR().toString("base64")
-
Thanks for quick reply. works. Another quick question, is the transaction hash and operation id generated before the transaction is submitted to the network or after? Feb 27, 2018 at 13:03
-
Transaction hash can be generated before submitting to the network using
hash()
method. Operation ID (Horizon) can be generated once transaction is in the ledger. Feb 27, 2018 at 14:30