Does anyone know how long events can be retrieved for?

I have events on the Kovan contract at 0x86e5b6d7648b8b994886aeb98e2b4770675e608d and it appears I can no longer retrieve events older than 14 days?

The code I'm using is as follows. Both get and watch are not retrieving events that are older than 14 days. I don't have anything in between today and 14 days, so I don't know if it stopped retrieving events older than a few days, or if there's a limit.

Thanks in advance for any help.

UPDATE: Ok, it seems the issue was that Parity had a different meaning of "fully sync'd" than I thought. If you see a line such as

2017-11-02 15:31:11 #4098136 23/25 peers 301 MiB chain 83 MiB db 0 bytes queue 10 MiB sync RPC: 1 conn, 3 req/s, 142 µs

in the console output, then what it means is that Parity hasn't fully downloaded all the logs yet, and it has only downloaded the logs for block 4098136 (in this case), even though you see

2017-11-02 15:31:13 Imported #4569744 1c13…0e14 (0 txs, 0.00 Mgas, 0.81 ms, 0.57 KiB)

let ContractAddr = "0x86E5b6D7648b8B994886aeB98E2B4770675e608D"; // on Kovan

    optionsShout = {
      fromBlock: 4289879,
      toBlock: 'latest',
      address: ContractAddr,
      topics: [web3.sha3('__Shout(string)')]

    let filter, w;

    function getLogs() {
      var filter = web3.eth.filter(optionsShout);
      filter.get(function(error, event) {
        if (!error) {
          console.log("Event: " + event);
        } else
          console.log("Error: " + error);

    function startFilter() {
      console.log("Starting filter");
      filter = web3.eth.filter(optionsShout);

      filter.watch(function(error, event) {
        if (!error) {
          if (event.blockNumber > optionsShout.fromBlock) {
            optionsShout.fromBlock = event.blockNumber;
            displayEvent("event1", event);
        } else
          console.log("Error: "+error);

  • What web3 provider are you using? Have you confirmed it is fully synced? And what error message are you getting, or are you just not getting anything? I have errors on the past saying my range is too large (fromBlock to toBlock). – carlolm Nov 1 '17 at 7:26
  • I'm not getting any errors. I tried both Infura (remotely) and Parity (locally). Yes, Parity is sync'd locally. I believe Infura is always synced. – chuacw Nov 1 '17 at 7:34
  • Infura doesn’t support events: ethereum.stackexchange.com/q/25451/12555. I use Parity for events and can retrieve events quite far back. Have you tried with the topics param? – carlolm Nov 1 '17 at 11:20
  • Thanks! That still leaves Parity working, ie, my code is able to retrieve event before 14 days, but nothing beyond 14 days. – chuacw Nov 1 '17 at 11:24
  • OK so I had a similar problem, but on Ropsten (ethereum.stackexchange.com/questions/28198/…). The way I resolved it was I found out my geth node was not syncing properly. I would just try this: web3.eth.getSyncing(console.log). Just confirm that this returns 'false', just to be completely sure it's not a syncing problem. – carlolm Nov 1 '17 at 11:36

There are a few possible problems here:

1) The node you're connected to may not have old events, or may have a policy against letting you retrieve them.

2) The range of logs you're requesting may be too wide. This can cause nodes to time out. Try finding a block where your contract has events and specifying just that block number as the range. If that shows your logs, try increasing the range until you find where the practical limit is, and fetch in batches limited to that range.

3) If you're using metamask, there seems to be some buggy behaviour around log fetching. After making sure you're on the right network, try closing all open Chrome windows then reopening it.

  • Thanks, Edmund. How does one know (programmatically) whether a time-out has occurred? – chuacw Nov 2 '17 at 8:21
  • Normally you should eventually get a reply from web3.js reporting an error. However, I wouldn't be 100% confident that this will happen, especially if you're using infura or something with a custom setup. – Edmund Edgar Nov 3 '17 at 0:55

It doesn't really sound like you need a filter, just grab all the events:

let transferEvent = MyContract.Event({}, {fromBlock: 0, toBlock: 'latest'})
transferEvent.get((error, logs) => {
  // we have the logs, now print them
  logs.forEach(log => console.log(log.args))
  • This seems the same as web3.eth.filter(optionsShout).get(function(error, events) { ... } and it still doesn't retrieve events beyond 14 days. I have remove the db, and re-sync'd. Still not getting events older than 14 days. Wonder if this is a limitation of Parity. – chuacw Nov 1 '17 at 13:10

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.