4

I'm trying to build an ethereum explorer and want to be able to monitor a bunch of addresses. I was thinking of just having a script on a 5 minute cron to check for any activity on these addresses.

But I realized that Bitcoin had a -walletnotify flag that lets the wallet software run a script you declare in the config file whenever it detects activity in one of the addresses.

Is there a -walletnotify equivalent flag in ethereum?

2

You can use the tracing API of Parity for that. The trace_filter RPC call will return all transactions that involved a given set of addresses including balances transfers as a result of contract invocations.

For the tracing feature to work you will need to sync parity using the --tracing=on flag.

The call accepts an optional from and to block parameter that allows for efficient polling.

Example to return all transactions sent to the address 0x18bAaa49ccaa9096aB78945824734036ed667B3B:

curl --data '{"method":"trace_filter","params":[{"toAddress":["0x18bAaa49ccaa9096aB78945824734036ed667B3B"]}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

I am not aware of any native push based feature that is similar to bitcoins walletnotify feature.

  • See deviatefish answer below. This answer is, I think, incorrect and should not be checked. – Thomas Jay Rush Aug 22 '17 at 9:53
  • In my opinion Paritys tracing feature does exactly what is described in deviatefishs answer (implements an instrumented EVM that can be used to get information about every balance change for a given set of addresses). – P.P. Aug 24 '17 at 11:18
  • There are invocations into a contract that change state but not balance. I'm not sure if Parity's trace filter includes those or not. If you find out, can you post here because that would be interesting. – Thomas Jay Rush Aug 24 '17 at 12:25
  • Yes, the trace filter includes all state transitions (call, delegatecall, create & suicide) independent if they change the balance of the account or not. – P.P. Aug 24 '17 at 13:32
  • 1
    That's nice. That may be enough. Does geth have a trace filter? – Thomas Jay Rush Aug 24 '17 at 13:34
3
+100

To do this completely, you need what's referred to as an "instrumented EVM".

However, if you only care about value transfers and interactions directly from/to certain addresses, this is pretty straightforward to do. You simply set up a script that watches for new blocks, then executes whatever task you want it to perform. If you want to watch a finite list of addresses for change of value, it's pretty straightforward to just do a balance check on every block.

Now, if you want to watch for all interactions, it becomes a much more complex task. This is due to the arbitrary nature of contract code. If you set up an instrumented EVM (not a simple task!), you can hook into all operations that interact with other addresses, and extract the relevant metadata generated. This is how etherscan works, for example.

  • Can you recommend any literature on instrumented EVMs ? – Nikita Fuchs Aug 21 '17 at 11:15
  • My answer was based on some information I remembered reading, but I couldn't remember from where. However, a quick search turned up this answer, which pretty much summarizes everything I remember – DeviateFish Aug 21 '17 at 22:55
  • 1
    It's also worth adding that you might be able to do this with Parity and Geth out of the box, using transaction traces. I doubt it'll be the fastest thing in the world, so I'd highly recommend caching the results somehow. – DeviateFish Aug 28 '17 at 21: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.