0

I am planning to build a system where users will get notified through an email and app notification if there was any change in their ether balance. I was confused how to monitor a large set of ethereum address for 24/7 to check the balance and to trigger an event based on that. Does web3.js provides any function for monitoring a large set of ethereum address?

  • This is an old answer to a similar question ethereum.stackexchange.com/a/27525. I'd suggest to explore using debug_getModifiedAccountsByNumber together with a block filter and possibly an external db. – Ismael Feb 17 at 6:21
2

I think that to most efficient way to do this would be to watch for new blocks and to extract the changes of account balances from the transactions you find in the new block.

This way you will basically monitor all accounts, and you can send notifications to those that subscribed to your service.

Another advantage if this approach is that you are able to detect balance changes as soon as they happen. And you could notify your clients of other things that happen on the blockchain, which do not have effect on the account balance.

0

I don't think web3 gives you this kind of functionality, instead you can build it by your own using getBalance.

You only need to call the function for each address that subscribed your service and send a notification in case the current balance reflect the conditions that you're looking for and then you can trigger the correspondent action.

Iterate this over the time after a certain timeout and you'll have a 27/7 service.

0

In this answer to a similar question, I wrote sample code that monitors the balances of a set of addresses. Simply change the fund transfer code to call your event trigger. Note that the code depends on remote web3 provider, which may be OK for low performance requirements. For high performance requirements, it might worth consider building directly on top of Geth or Parity.

  • Actually ignore my answer, just found out I was giving the same answer to the same OP :) – Linmao Song May 2 '18 at 9:29

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.