0

Currently, I am getting transaction detail from transaction stream using stellar sdk. So for getting the operation details the envelope XDR is decoded. But the operationID couldn't be retrieved from the encoded XDR. So the paging token from transactionID is incremented by 1 to get the operationID. Is this approach ok?

0

I guess that should work but depending on the sdk you should be also able to somehow access the id directly. Here are two options for the js-sdk:

1) You can get operations from the transaction object and access its properties.

horizon.transactions()
        .cursor('now')
        .stream({
            onmessage: async function (tx) {
                let operations = await tx.operations();
                console.log(operations.records[0].id);
            }
        });

2) You could subscribe directly to operations instead of transactions.

horizon.operations()
        .cursor('now')
        .stream({
            onmessage: function (op) {
                console.log(op.id);
            }
        });
  • Currently I use golang sdk, so instead of making extra api calls to stellar. Is it ok to increment the paging token from transaction to get the operationID – Arunagiriswaran Ezhilan Jun 24 at 13:11

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.