I am using web3.js with geth for my application to know which clients are depositing money into 1 specific account (instead of making a new wallet for each new client). The way I am attempting to do this is via the data value in the transactionObject:

transcationObject = {
  from: sender,
  to: receiver,
  value: amount,
  data: 2134235141 //uniquely generated value for this user


The problem is I need a way for my application to store all the transactionObjects of the accounts that are sending Ether to my account. From there it's pretty easy to know who sent how much by looking at the data value.

Potential Solution:

After searching online, I found the function eth.setFilter. To my understanding, what this does is filters all the transactions that are being added to the blockchain of the local node, and only saves the ones that pass through the filter.

source of learning about eth.setFilter: How to trace state of transactions in ethereum


Is the previous explanation how eth.setFilter actually works? Is it integrated with the process of saving new transaction information into the blockchain?

AND could someone provide an example of how it is used? I saw some examples with curl online (the link above), but I had no idea what that code actually does. Does it modify how the blockchain operates indefinitely? Or does it need to be re-run? Is there a better way to do it?

Note: If some of the questions above are irrelevant to the answer you are providing, it's completely fine. I am mostly trying to find a solution of how to use eth.newFilter and understand what it is doing with that code.


1 Answer 1


I've used this javascript code to filter transaction to an address, it uses web3.eth.filter

var filter = eth.filter({fromBlock:0, toBlock:'latest', address: "0xAddress"});
filter.get(function (err, transactions) {
  transactions.forEach(function (tx) {

If instead of get to retrieve existing transaction you can use watch for new transactions.

A couple of warnings:

  • This does not work for 'internal transactions', transactions generated by a contract, for example a multisig wallet or some exchanges. You can use a third party service like etherscan to list 'internal transactions', or use a trace api from geth or parity.

  • A chain reorganization can cause that events to be triggered even when transactions will be dropped from the blockchain. And the opposite an event is not triggered even when the transaction is included in the blockchain. You have to wait some blocks for confirmation, or rescan periodically for chain reorganizations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.