3

I've put the same filter with eth_newFilter before and after a set of transactions. The one which is installed after transactions catched 0 events. Is it how events work? Is there any other way to catch events retrospectively except eth_getLogs?

from ethjsonrpc import EthJsonRpc
c = EthJsonRpc('127.0.0.1', 8545)
ADDRESS = "0xdb1154368ba2645e6c090f3d1f3ddd5c8c1f8008"
params = {
    "fromBlock": "0x01",
    "address": ADDRESS
}
before = c.eth_newFilter(params)
for i in range(100):
    tx = c.call_with_transaction(c.eth_coinbase(), ADDRESS, 'setValue(uint32)', [i])
    receipt = c.eth_getTransactionReceipt(tx)
after = c.eth_newFilter(params)

print len(c.eth_getFilterLogs(before)) // 100
print len(c.eth_getFilterLogs(after)) // 0
print len(c.eth_getLogs(params)) // 100

I'm using testrpc as blockchain client.

jrbedard
  • 524
  • 1
  • 6
  • 15
takeshi
  • 1,760
  • 1
  • 13
  • 33

1 Answers1

4

TestRPC doesn't support past events unfortunately. You could try using a private Geth chain as detailed here.

bozzle
  • 896
  • 6
  • 13
  • Thank you very much! I suspected this, but couldn't find in the docs. Is it the same for filter topics? As I cannot make them work too. – takeshi Aug 23 '16 at 05:05
  • this answer helped me. Would you happen to know the answer to my question on filters: https://ethereum.stackexchange.com/questions/22954/mistake-when-using-web3-eth-filter-and-filter-get
  • – Webeng Jul 24 '17 at 22:42