3

I'd like to monitor the blockchain and react to when ada is deposited to my wallet. I'm curious about the most efficient way of going about this. For example, if I use the cardano-wallet api it has the route /wallets/{walletId}/transactions which I assume I could poll. Of course, this would require polling behavior, which is not as efficient as event-based architecture (ie. using a listener or callback).

Can anyone describe the current state of the art for watching a particular wallet for new transactions?

2

2 Answers 2

3

If you think about watching a local wallet, created on cardano-wallet, I do not think there is more efficient way than just pooling it in an interval.

If it is a wallet that does not use enterprise or mangled addresses, you can watch the chain from cardano-db-sync stack or a remote API provider such as blockfrost.io.

If using Blockfrost.io, I recommend using the websocket-link where you can create a WebSocket subscription.

In any of these implementation, make sure you account for possible roll-backs of the blockchain.

3
  • Does the chain roll-back?
    – melchoir55
    Nov 17, 2021 at 20:28
  • 1
    Yes, several times a day. Nov 17, 2021 at 23:30
  • 1
    Very interesting. Would you mind linking to any sort of writeup or documentation suggesting how to account for that?
    – melchoir55
    Nov 17, 2021 at 23:43
2

It is a bit late for this, but if you have a cardano-db-sync and want to receive notifications you can use this solution.

It requires you to provide when deploying the schema the address to monitor and the number of blocks after which your application considers a transaction settled. The solution will take care of rollbacks and only notify through the PostgreSQL channel if the transaction passed the block's depth threshold.

If you just need to monitor chain rollback events you can use this one. which follows a similar approach of notifying using PostgreSQL channels.

Your Answer

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

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