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.

  • Is there a reason eth_getLogs() cannot be used? It has almost the same call signature as eth_newFilter. – Mikko Ohtamaa Aug 16 '16 at 11:51
  • @MikkoOhtamaa this is exact same question I'm typing right now. Why use filters at all?)) – takeshi Aug 16 '16 at 12:37
4

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

  • 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 5:05
  • + this answer helped me. Would you happen to know the answer to my question on filters: ethereum.stackexchange.com/questions/22954/… – Webeng Jul 24 '17 at 22:42

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.