• Core
  • Actions
  • watchWebSocketProvider

watchWebSocketProvider

Action for subscribing to WebSocketProvider changes.

import { watchWebSocketProvider } from '@wagmi/core'

Usage

By default, the callback will be invoked when WebSocket Provider changes.

import { watchWebSocketProvider } from '@wagmi/core'
 
const unwatch = watchWebSocketProvider(
  {
    chainId: 1,
  },
  (webSockerProvider) => console.log(webSockerProvider),
)

Configuration

chainId (optional)

Force a specific chain id for the WebSocket Provider. The wagmi Client's ethers provider must be set up as a chain-aware function for this to work correctly.

import { watchWebSocketProvider } from '@wagmi/core'
 
const unwatch = watchWebSocketProvider(
  {
    chainId: 1,
  },
  (webSockerProvider) => console.log(webSockerProvider),
)