[Ethereum] Using eth_newFilter

ethereumjgo-ethereumjson-rpc

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?

Best Answer

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).

Related Topic