0

eth_subscribe method of JSON-RPC API requires a full duplex connection, such as WebSocket, hence subscribing to events is impossible via a HTTP connection.

I use Ganache as an ethereum node and Metamask as a browser provider to test my dapp. The Ganache server is listening to requests by means of HTTP. Nevertheless, the dapp have no glitches to receive notifications from the provider after subscription.

Have I got it right that Metamask, being encountered with a HTTP server, trys to get its events through any other way (like polling) deep under the hood? And then the dapp developer should not worry about whether the user's node supports duplex conections or not, as long as there is a Metamask. Or it's all Ganache - does it just support WebSockets?

1 Answer 1

0

Metamask does not support websocket yet. All the data is posted to the RPC. I am working on a custom RPC and I'm kinda hacking it. I got to the point where I sent raw transaction but Metamask waiting on the response process is hardly documented. So far what I can tell is that Metamask seems to be waiting on the next block.

eth_blockNumber

This is what i'm trying to figure out but from the call made by Metamask.

I believe metamask is waiting on a new block while pending.

When that block number increase. It fetches the following;

eth_getBlockByNumber

To get the block and then

eth_getTransactionReceipt

after that it fetches balance and the block on every new block.

1
  • So, to get it straight, Metamask effectively does the polling Oct 25, 2021 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.