[英]How do I properly set up geth to make JSON RPC calls
我安裝了 Geth 以觸發對以太坊測試網 Goerli 的 JSON RPC 調用。 我按照這里的入門教程進行操作。 我按照說明進行了以下操作:
clef newaccount --keystore <my_local_dir>/keystore
生成了一個新賬戶(錢包地址)clef --keystore <my_local_dir>/keystore --configdir <my_local_dir>/clef --chainid 5
geth --datadir <my_local_dir> --signer=<my_local_dir>/clef/clef.ipc --goerli --syncmode snap --http
開始 geth 與節點同步geth attach http://127.0.0.1:8545
附加到正在運行的節點。 雖然,我相信這一步可以跳過,因為我試圖觸發 JSON RPC 請求--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x631e9b031b16b18172a2b9d66c3668a68a668d20", "latest"],
"id": 1
}'
我可能做錯了什么? 我看到該帳戶確實有以太幣( 余額),但由於我的調用,我一直得到 0:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x0"
}
任何想法?
經過一些額外的研究並與同事交談后,我相信我現在知道為什么我無法檢索區塊鏈數據了。 僅在節點完全同步后才可用:
Client execution will initiate its core functions, chosen endpoints, and start looking for peers. After successfully discovering peers, the client starts synchronization. Current blockchain data will be available once the client is successfully synced to the current state.
這可以在此處的最后一段中找到。
所以問題不是安裝或設置失敗,而是客戶端不同步。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.