0

My server stores many accounts.

How do i know when and what account has received eth or i have to check them manually one by one by looping many address to check the balance?

account := common.HexToAddress(address)
balance, err := client.BalanceAt(context.Background(), account, nil)
  • You have to check it manually. – goodvibration Jun 13 at 10:43
  • You will most likely not get anymore answers once you've marked an answer with a V. And from what I could tell from your comment to that answer, it does not solve your problem. – goodvibration Jun 13 at 13:40
  • What language is your server written it, looks like maybe go? – foba Jun 13 at 17:24
  • @foba yes, i'm using go – TomSawyer Jun 13 at 19:08
0

You can setup server cronjob which fires javascript and checking every 30min or 1h the balance of the accounts and save records. Checking balance is only reading blockchain, you don't need to fire transaction for this, it can be done with this method:

web3.eth.getBalance

In the loop of accounts if saved record timestamp is different than the latest transactions for THIS account then save this record and submit email to your email address or whatever fits you.

  • This is equivalent to "doing it manually", which in the context of this question means "polling" instead of "event-based". In fact, even with Ethereum events, the only available method remains polling the blockchain in one way or another. A code for doing it manually is already given in the question, and on top of all that, your suggestion seems to apply for Javascript, while the question is technically in Go. So I can't quite see any added value in what you wrote. – goodvibration Jun 13 at 11:30
  • Thank you, but yes, this is checking manually. If i have million acounts, using cronjob to check all of them requires so much resources. – TomSawyer Jun 13 at 11:37
  • @goodvibration It's about what you understand by 'manually', manually for me is to place a query everytime you want to check the result, the proposal I gave is automatic. The guy asked for notifications and didn't specify where and what kind of notification he wants so I though we're talking about email notification. And if you don't want to get technical solutions as proposals perhaps you might wanna change the forum. – Miroslav Nedelchev Jun 13 at 13:14
  • The guy who asked the question told you the exact same thing (and the V is most likely because he simply doesn't understand the actual purpose of it). I love solutions, but your suggestion does not solve the problem at hand! – goodvibration Jun 13 at 13:39

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.