TransWikia.com

Inferring operationID from get transactions stream data

Stellar Asked by Arunagiriswaran Ezhilan on August 21, 2021

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?

One Answer

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

Answered by sui on August 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP