I need to check for customers' deposits and need to scan for receiving transactions for those addresses for Ether and in next step ERC-20 tokens. What's the most efficient way to do this with go-ethereum?
I am looking for the same solution, as far as I know, web3js can watch events, but after received the events, also need to wait for more confirmations(say 30) in case of rollback(double spending). My target solution is to use golang to interactive with geth(installed in local and open rpc service), but haven't find the way. Node may do the work.
One options is to run your own node and enable tracing.
With this, code can :
- Listen for new blocks (E.g.: Event on Mining of a new block )
- For each new block, iterate over all transactions ("transactions" property of Block)
- For each transaction, trace the transaction to find out all value transfers (geth : https://github.com/ethereum/go-ethereum/wiki/Tracing:-Introduction ; parity : https://github.com/paritytech/wiki/blob/master/JSONRPC-trace-module.md#trace_replaytransaction. Some details : Instrumenting EVM)
- This should provide list of all addresses that were impacted by a particular transaction (By direct value transfer or internal transactions as part of contract)
- For each address; Either implement your own code to reconstruct value from trace or query value as of that block
- Update your own DB / Storage with these changes