• Core
  • Actions
  • getPublicClient

getPublicClient

Action for accessing viem's Public Client.

import { getPublicClient } from '@wagmi/core'

Usage

import { getPublicClient } from '@wagmi/core'
 
const publicClient = getPublicClient()

Return Value

PublicClient

Configuration

chainId (optional)

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

import { getPublicClient } from '@wagmi/core'
 
const publicClient = getPublicClient({
  chainId: 1,
})