0

I'm developing an Ethereum platform and need to fetch the events log of a desired address. I found a code like this:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]}],"id":74}'

but when I replace my own address in this code, I receive an empty result as below:

{"jsonrpc":"2.0","id":1,"result":[]}

May you tell me what is my mistake here?

2 Answers 2

1

An ethereum log entry contains a list of topics. This list contains the contract address, event's signature and indexed parameters.

If you want to filter events with your address then it has to be included in an event as an indexed parameter.

For example standard ERC-20 tokens have the event event Transfer(address indexed _from, address indexed _to, uint256 _value), and you can filter by sender and recipient address.

If your address wasn't included as an indexed parameter getLogs will return an empty list.

2
  • Ismael, I have not any problem with ERC-20 tokens logs, the issue I have face with is logs of ETH itself. Jun 14, 2020 at 16:30
  • @MohammadSaberi Since ether transfers do not generate any events you cannot use getLogs to retrieve them. I answered similar question here ethereum.stackexchange.com/a/84275.
    – Ismael
    Jun 14, 2020 at 16:33
0

can you please try using the following format for the request, just replace ADDRESS with the address that you want, TOPIC with the topics signatures that you want and the ENDPOINT with the HTTP endpoint of your node :

curl -X POST -H "Content-type: application/json" -d '{"method": "eth_getLogs","params":[ {"address": "ADDRESS","topics":["TOPIC"]}], "id":1,"jsonrpc": "2.0"}' ENDPOINT

'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.