1

To track the payments we can use streaming API is good solution. already answered.

In my case I have a master account(M) as well sub-master(SM) account, I need to have multiple sub-master(SM) accounts.

the process is like when a user trusts MyAsset and buy MyTokens on DEX and now and in return gets MyTokens.

With these tokens, the user will now trade with sub-master(SM) accounts

so I need to track the payment of MyAsset on sub-master account

as I have multiple sub-master accounts possibly 15-20

I need to track received transaction on each and every sub-master(SM) account.

Note: Master account does not have Secret Keys of Sub-Master account.

As a master account owner ,now I need to perform some operations when the user sends mytoken to sub-master account.

is it possible to achieve in a single job without watching separately all the sub-master accounts?

2 Answers 2

2

Check StellarNotifier, a standalone service that tracks all operations for the unlimited number of accounts using a single Horizon stream. I made it as flexible as possible to simplify standard pub-sub tasks of tracking multiple update streams for anchors and payments processors.

You can dynamically create subscriptions with guaranteed delivery to track specific accounts, assets, operations types.

2
  • I followed all the steps and now doing ** npm run test**. the test fails with this error; 1.expects valid maxSize argument: 2.evicts old entries when the limit is reached: Commented Nov 21, 2018 at 5:43
  • 1
    I think this is the correct approach. I have a similar project that pushes to GCP Pub/Sub and uses cloud functions to process the events.
    – Francesco
    Commented Dec 16, 2018 at 11:03
0

not very optimized answer but this will watch payment on both the accounts.

app.get("stream", function (req, res) {
    let funding_account1 = issuer.publicKey // This needs to be a valid account on the network and should return an Account object
    let stream = server.payments()
        .forAccount(funding_account1)
        .cursor('now')
        .stream({
            onmessage: function (message) {
                if ((message.type == "create_account") || (message.type == "payment")) {
                    var details = "from:" + message.from + ",to:" + message.to + ",amount:" + message.amount;
                    console.log(details)
                    // Set your own code after we find our create account event
                    stream()
                }
            }
        })
    let stream2 = server.payments()
        .forAccount(funding_account2.publicKey)
        .cursor('now')
        .stream({
            onmessage: function (message) {
                if ((message.type == "create_account") || (message.type == "payment")) {

                    var details = "from:" + message.from + ",to:" + message.to + ",amount:" + message.amount;
                    console.log(details)
                    // Set your own code after we find our create account event
                    stream()
               }
            }
        })
})

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.