Continuous eth_getLogs
, eth_chainId
, eth_blockNumber
calls to RPC when using contract.on
event listener
#2659
-
Hi guys, When using event listener on specific contract (using Is this the expected behavior? It seems that such event listener is polling instead of using web socket? Any idea? FYI, I am using ethers.js in a frontend application so continuous calls like this may affect the network usage. Really appreciate any help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, this is how a the Provider works for events. It polls for changes in block number, and when one is detected it checks for new logs. If you are using an endpoint which cannot change its chain ID, you can use the StaticJsonRpcProvider. If you want to use WebSockets you need to use the WebSocketProvider. |
Beta Was this translation helpful? Give feedback.
Yes, this is how a the Provider works for events. It polls for changes in block number, and when one is detected it checks for new logs. If you are using an endpoint which cannot change its chain ID, you can use the StaticJsonRpcProvider.
If you want to use WebSockets you need to use the WebSocketProvider.