I'm trying to obtain all the transactions of a contract, but in all cases I only obtained [] or undefined.

I'm following this posts:

And I read others posts too, but i can't solve my problem.

I try to use this:

var filter=web3.eth.filter({fromBlock: 866705, toBlock: 909023, address: contractAddress});
filter.get(function(error, log) {

With different values of fromblock, to block and the others options ('latest',fromblock: 0 , ...). But i don't obtain any result.

I'm trying to do this :

var filter = web3.eth.filter({fromBlock:9000, toBlock: 'latest', address: contractAddress});
filter.get(function(error, result) {
    var info = web3.eth.getBlock(result , function(error, result){
         var trans = web3.eth.getTransaction(result.transactions[1], function(error,result){
             var str = web3.toAscii(result.input,);

(If i forget some token sorry)

All of this only for obtain the data of a transaction like "from", "to" and "input". Where is the problem?

More information:

  • I'm using metamask and meteor.js
  • I'm running this in Ropsten test-net
  • If I use the function web3.eth.getBlock wiht a correct blocknumber I can obtain all the data, the problem is the filter and how I use it.
  • IN the first snippet, I suspect that filter.stopWatching executes before the callback has a chance to work. The way it's laid out suggests an expectation that those commands will execute in order, but it's not the case with JavaScript. I would consider commenting out filter.stopWatching and start from block 0, then build up complexity after I see it work. Hope it helps. May 12, 2017 at 18:29
  • @Rob Hitchens yes man, I think the problem lies in the order and speed of javascript execution, but i don't found how to fix it.
    – Gawey
    May 15, 2017 at 7:20

3 Answers 3


Another way (perhaps much simpler) to get a list of transactions on an account is to use an API from a block scraper such as http://etherscan.io. The trouble with this is it's fully centralized.

A fully decentralized way is go against the node (as you're doing). The trouble here is that, while it is decentralized, it's slow. Especially if your smart contract has a very long transaction history.

An even deeper problem with going against the node is that simply getting the transactions is not enough. You will also need to get the transaction receipts. You need these to determine if the transactions completed with an error or not.

Worse yet even than that is incoming message calls (what used to be called internal transactions). These are "transactions" initiated by an outside smart contract directly into your address. These "transactions" do not appear on the blockchain directly, but are buried down in an internal trace of the initiating transaction. If you're looking only at your address, these will be missed.

  • My smart contract don't ahve a very long transaction but is slow too. I read about internal trnasactions, but i test it and my transaction don't are internals because in etherescan.io they doesn't put this transactions like internals transactions in their blocks scaned's. I will try the api of etehrscan.io, but this is a hotfix not a real fix for this problem :/
    – Gawey
    May 15, 2017 at 7:24
  • Etherscan's public API for this use case seems to be deprecated...
    – CQM
    Aug 16, 2017 at 22:29
  • @CQM I'm not seeing that, but maybe I missed it. Do you have s link? Aug 16, 2017 at 22:56
  • etherscan.io/apis#tokens see the deprecated ones, is there a more applicable endpoint?
    – CQM
    Aug 16, 2017 at 23:12
  • I'm guessing, but I would bet they depreciated it because it was a maintenance issue. You don't have etherscan, you could use the RPC directly against a node. Aug 17, 2017 at 3:37

Arrays are indexed starting from '0'. You're indexing from '1'. Try transactions[0].


The answer is rather simple. I also tried to solve this by coding my way through it. Etherscan has a feature allowing you to download all the transactions as a csv file. At the bottom of the page: Download CSV Export

enter image description here

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.