If one wants to create a trading wallet for ETH what Ethereum JSON-RPC events one needs to listen for incoming balance updates? Idea would be to reflect Ethereum account state in a local database.

Or is there another way to do this... read Ethereum wallet database direcly?

I am using Python as the server-side programming language. I guess purely cliet-side trustles JavaScript wallet might work as well.


I don't believe there is a simple way to filter for only balance-modifying transactions in a given account.

However, with the web3 JS library, it is possible to query for a specific address's balance using the getBalance method. Example usage:

var balance = web3.eth.getBalance(address);
console.log(address, "has", web3.fromWei(balance, "ether")).toString(), "ETH!");

Depending on your needs, you may be able to simply call getBalance when you need it. If you want it to automatically update, or if you don't want the sychronous call, you could use the filter method. Example usage:

var balance;
web3.eth.filter("latest", function(error, result) {
   if (!error) {
       balance = web3.eth.getBalance(address);

web3 must attach to an Ethereum node, so this may not work in a client-side environment. On the bright side, all of these are based on the standard JSON-RPC API, so you may be able to work out something pythonic server-side.

  • Thanks. This is a step to a right direction. Is it possible to know what transactions in filter cause balance updates or how to decode those transactions? E.g filtering the transactions provided by filter :) – Mikko Ohtamaa Jun 15 '16 at 2:42
  • 2
    filter("pending") or filter("latest") just call the callback if there is a new transaction/block respectively. Unfortunately, there's no (easy) way to know exactly what a transaction did, because a subtransaction (contract called by a contract) might have sent funds. However, if you are using a wallet contract, you can write the contract's code to sent an event when a transaction is received/sent. This may be closer to what you need. – Matthew Schmidt Jun 15 '16 at 14:44
  • I spotted a similar question on Ethereum Commmunity forums: forum.ethereum.org/discussion/4324/… - apparently it's possible because etherchain is doing it :) – Mikko Ohtamaa Jun 16 '16 at 16:03
  • Also for substransactions: would they generate separate events or not? I'd assume not the whole transaction chain is processed in one transaction written to a block, so one should check the balances of all involved addresses at the end of the transaction. – Mikko Ohtamaa Jun 16 '16 at 16:04
  • Looks like it is being extensively discussed here github.com/ethereum/go-ethereum/issues/1897 – Mikko Ohtamaa Jun 16 '16 at 16:11

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.