我启动了一个本地节点(一个雪崩节点),并使用geth成功地连接到它。
❯❯❯ geth attach http://127.0.0.1:65130/ext/bc/C/rpc
Welcome to the Geth JavaScript console!
instance: v0.8.4-rc.3
coinbase: 0x0100000000000000000000000000000000000000
at block: 0 (Wed Dec 31 1969 18:00:00 GMT-0600 (CST))
modules: eth:1.0 net:1.0 rpc:1.0 web3:1.0我想订阅这个节点上的事件。盖斯博士提到,通过控制台发送json应该是可能的。当我试图发送这个json时,我会收到关于json格式的抱怨:
> {"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]}
SyntaxError: SyntaxError: (anonymous): Line 1:6 Unexpected token : (and 2 more errors)尽管我直接从文档中复制了这个json (在我看来,它的格式很好)。
文档还提到,我需要最低版本的1.4,并且我有版本1.10:
❯❯❯ geth version
Geth
Version: 1.10.16-stable
Architecture: amd64
Go Version: go1.17.6
Operating System: darwin
GOPATH=
GOROOT=go我如何使用geth订阅事件?
发布于 2022-03-01 17:08:05
了解了如何使用websocket客户端wscat进行订阅:
❮❮❮ wscat -c ws://127.0.0.1:35260/ext/bc/C/ws
Connected (press CTRL+C to quit)
> {"id": 1, "method": "eth_subscribe", "params": ["newPendingTransactions"]}
< {"jsonrpc":"2.0","id":1,"result":"0x94be2b853229f8ea4b60b80b4a45b13e"}我想我错误地使用了geth客户机,尽管还不清楚geth应该如何用于订阅。
https://ethereum.stackexchange.com/questions/122859
复制相似问题