referenced by https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_newFilter. I am confused by topic parameter. Could give some examples? some information referenced by the following,but I still do not know. How can I create a listener for new transaction with Ethereum RPC calls?

2 Answers 2


The topic is used for filtering on indexed parameters in events/logs. If you have looked at Solidity (the most popular language for writing smart contracts in Ethereum), you can write events with the following format:

event myEvent (type1 indexed arg1, type2 indexed arg2, type3 arg3);

The indexed keyword allows you to filter on it when browsing event logs. For example:

"topics": ["0x01","0x02"]

would mean you are interested in events that have arg1 and arg2 with values of 1 and 2 respectively. As the documentation details, you can pass null to the first as a wildcard (to accept anything on that topic).


you can use eth_newFilter just like this

1 specify your filter params

here is a param demo:

params =  {
      "fromBlock": "0x0",
      "toBlock": "latest",
      "address": address,
      "topics": [event_id, None, None]

which means look for logs from the genesis block until the recently block mined

address varaible use to specfic the where the logs are generated, generally, it's a contract address which you interested

topics is the filter params. The first topic is the hash of event signature and the other is the indexed param in event declaration

Here is the link with detail information and you can calcu the hash of the event signature via pyethereuem.ethereum.abi.event_id method

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.