Json-Rpc

如何為 eth_getLogs 設置參數以查詢 ERC721 燒錄事件?

  • May 20, 2021

我想使用 curl 查詢這些數據。 https://rinkeby.etherscan.io/tx/0x0819826eb519a33b5d856fd8566a902b7da3e30dd8635c90b75ccf70cf5cac9b#eventlog

我試過這個命令,但得到一個空的回報。有什麼我想念的嗎?

curl https://rinkeby.infura.io/v3/<my-key>\
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_getLogs","params": [{"topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000003639f46a7c2060fff60c9020bdcc92055a9af1cc","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000002"]}],"id":1}'

結果

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

試試這個。

curl https://rinkeby.infura.io/v3/<your-key>\
                               -X POST \
                               -H "Content-Type: application/json" \
                               -d '{"jsonrpc":"2.0","method":"eth_getLogs","params": [{"fromBlock":"0x00", "address":"0xf62888ad60570cb396f1324dcc250ce5bad9229a" , "topics":["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000003639f46a7c2060fff60c9020bdcc92055a9af1cc","0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000002"]}],"id":1}'

解釋

請參閱此 Infura RPC 端點文件

https://infura.io/docs/ethereum/json-rpc/eth-getLogs

從塊

$$ optional, default is “latest” $$- 一個整數塊號,或字元串“latest”、“earliest”或“pending”

您錯過了“fromBlock”參數,因此設置了預設的最新,這意味著您只獲取沒有目標事件的最新塊資訊。

引用自:https://ethereum.stackexchange.com/questions/99318