Skip to content

Use JsonRpcProvider as listener instead of WebsocketProvider #4114

Answered by therealjmj
therealjmj asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone else experiencing this... try this wrapper class:

import { JsonRpcProvider } from 'ethers';

/**
 * Uses a setting in JsonRpcProvider to poll for events,
 * rather than using sparsely-implemented eth_filter events.
 */
export class PollingJsonRpcProvider extends JsonRpcProvider {
  constructor(url: string) {
    super(url, undefined, { polling: true });
  }
}

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ricmoo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #4108 on June 02, 2023 00:22.