• Core
  • Actions
  • watchProvider

watchProvider

Action for subscribing to Provider changes.

import { watchProvider } from '@wagmi/core'

Usage

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

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

Configuration

chainId (optional)

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

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