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?

1 Answer 1

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);
            }
        });
0

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.