0

I'm trying to get do a eth_getLogs call, but I'm having problems getting a response with the Polygon chains. Strangely, I make the request with Polygon Mainnet data that I know exists, but when I do I get the following error

{"code":-32602,"message":"missing value for required argument 0"}

but when I make the same request on the Eth mainnet, it works.

My failing request is

curl https://polygon-mainnet.infura.io/v3/myKey \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","parameters":[{"fromBlock":"29597527","toBlock":"29597529","topics":["0x788f224aea8528cb3199d1615151d4b851c884ad39e72c306356520ec6d2cf95"]}],"id":1}'

However this request works.

curl https://mainnet.infura.io/v3/myKey \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getLogs","parameters":[{"fromBlock":"29597527","toBlock":"29597529","topics":["0x788f224aea8528cb3199d1615151d4b851c884ad39e72c306356520ec6d2cf95"]}],"id":1}'

Could anyone help me to understand this? Thanks!

1 Answer 1

0

Figured it out by reading the docs more closely.

fromBlock [optional, default is "latest"] - hexadecimal block number, or the string "latest", "earliest" or "pending"

toBlock [optional, default is "latest"] - hexadecimal block number, or the string "latest", "earliest" or "pending"

My block numbers needed to be hexademicals, starting with 0x

Strange how the request worked for Eth

1
  • This behaviour actually also seems to be the case for all non-mainnet-related chains. I.e. Rinkeby, and Kovan, for example behave the same as mainnet whereas Optimism and Arbitrum behave like Polygon. Still have no idea why.
    – Shiri
    Sep 15, 2022 at 8:20

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.