thetatoken / theta-eth-rpc-adaptor

An adaptor that translates the Theta RPC APIs to the Ethereum RPC APIs
https://docs.thetatoken.org/
24 stars 11 forks source link

new blockheader subscriber over websocket #13

Open gitloverr opened 3 years ago

gitloverr commented 3 years ago

hi everyone,

Is there any way I can listen to the last block header or block number over websocket? I couldn't find anything in your supported methods?

I tried this:

{"id": 1, "method": "eth_subscribe", "params": ["newHeads", {}]}

but I got this error:

{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"no \"newHeads\" subscription in eth namespace"}}

what should I do?

thank you

jieyilong commented 3 years ago

The eth_subscribe method is not supported yet. Here are the methods that are currently supported:

https://github.com/thetatoken/theta-eth-rpc-adaptor#rpc-apis

jieyilong commented 3 years ago

For now, one workaround is to call eth_blockNumber every 6 seconds (the block interval is roughly 6 seconds), and then call eth_getBlockByNumber to get the details of the newly added block(s).