Using the javascript sdk, I'm sending a payment like so:

const operation = Operation.payment({
    destination: toAddress,
    asset: asset,
    amount: amount.toString()

const account = await server.loadAccount(address);
const transactionBuilder = new StellarSdk.TransactionBuilder(account);

const transaction = transactionBuilder.build();

const payment = await this.server.submitTransaction(transaction);

This works well, but I also want to get the operation record for that transaction.
It seems that the type of payment should be TransactionRecord:

interface TransactionRecord extends Record {
    id: string;
    paging_token: string;
    hash: string;
    ledger_attr: number;
    created_at: string;
    max_fee: number;
    fee_paid: number;
    operation_count: number;
    result_code: number;
    result_code_s: string;
    source_account: string;
    source_account_sequence: string;
    envelope_xdr: string;
    result_xdr: string;
    result_meta_xdr: string;
    memo: string;

    account: CallFunction<AccountRecord>;
    effects: CallCollectionFunction<EffectRecord>;
    ledger: CallFunction<LedgerRecord>;
    operations: CallCollectionFunction<OperationRecord>;
    precedes: CallFunction<TransactionRecord>;
    self: CallFunction<TransactionRecord>;
    succeeds: CallFunction<TransactionRecord>;

But when I try to do this:

(await payment.operations())._embedded.records[0] as PaymentOperationRecord;

I get an error because payment.operations is undefined.
I logged the value of payment and it was something like:

    _links: {
        transaction: { 
            href: '...' 
    hash: '...',
    ledger: 0000000,
    envelope_xdr: '...',
    result_xdr: '...',
    result_meta_xdr: '...' 

Am I mistaken in thinking that the type of the result should be TransactionRecord? And if so, what is this type? I couldn't find anything in the typescript definition files to match it, and the official documentation doesn't say much about it.


2 Answers 2


That is the object returned from a successful submitTransaction call, it is not the transaction record object that you get from calling server.transactions().transaction(hash).

If you would like to get the operation object, you can either decode the envelope_xdr or call server.operations.forTransactions(transactionID) just parse the transactionID from the _links object of the submitTransaction result. Sample:

      .then(function (opResult) {
      .catch(function (err) {

and you'll get an operation object with this format:

{ records:
   [ { _links: [Object],
       id: '44177754433802241',
       paging_token: '44177754433802241',
       type: 'payment',
       type_i: 1,
       created_at: '2018-07-30T10:16:34Z',
       transaction_hash: 'e52bbe411b14501514420958287c3d0a50554ebff662a26b16a45de6d09fd076',
       asset_type: 'native',
       amount: '2.9900000',
       self: [Function],
       transaction: [Function],
       effects: [Function],
       succeeds: [Function],
       precedes: [Function] } ],
  next: [Function: next],
  prev: [Function: prev] 
  • Yeah, I know how to get the operation by issuing a new request (server.operations().forTransaction(payment.hash).call()) but I was hoping to avoid that. Does the js-sdk offer any functionality for decoding the envelope_xdr? Commented Jul 31, 2018 at 8:51
  • JSON.stringify(StellarSdk.xdr.TransactionEnvelope.fromXDR(transactionResult.envelope_xdr, 'base64'))
    – tracy
    Commented Jul 31, 2018 at 9:43
  • although you will not get the same transactionrecord object as well.. decoding the envelope_xdr will result to something like this, see the operations object included: `{"_attributes":{"tx":{"_attributes":{"sourceAccount":{"_switch":{"name":"publicK eyTypeEd25519","value":0},"_arm":"ed25519","_armType":{"_length":32,"_padding":0 },"_value":{"type":"Buffer","data":[159,21,194,29,247,20,234,18,229,33,76,225,20 9,96,158,152,79,200,83,199,96,79,70,70,64,39,154,150,22,45,90,33]}},"fee":100,"s eqNum":{"low":48,"high":10125641,"unsigned":true},"memo":{"_switch":{"name":"mem oText","value":1},"_arm":"
    – tracy
    Commented Jul 31, 2018 at 9:44
  • 1
    Ok, thanks, I'll stick with the extra server.operations().forTransaction(payment.hash).call() Commented Jul 31, 2018 at 12:54

According to the Stellar docs and source code, what you get back is just a plain object, straight from Horizon.



Here is more documentation on what Horizon returns:


  • The kind of TransactionRecord you're mentioning might be what gets returned from the transaction query endpoint though Commented Jul 30, 2018 at 0:58
  • Thanks for the links. The first two are pretty useless though (I have nothing to do with "Promise that resolves or rejects with response from horizon"). But the last one is good. Commented Jul 31, 2018 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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