Public
The publicProvider configures the chains with a public RPC URL.
import { publicProvider } from 'wagmi/providers/public'Usage
import { chain, configureChains } from 'wagmi'
import { publicProvider } from 'wagmi/providers/public'
const { chains, publicClient } = configureChains(
[chain.mainnet, chain.polygon],
[publicProvider()],
)⚠️
Only having publicProvider in your providers will make the chain use the
public RPC URL which could lead to rate-limiting. It is recommended to also
include another provider in your list (such as: alchemyProvider,
infuraProvider or jsonRpcProvider).
Return Value
{
chains: Chain[],
publicClient: PublicClient,
webSocketPublicClient: PublicClient
}Configuration
stallTimeout (optional)
The timeout in milliseconds after which another provider will be attempted.
import { chain, configureChains } from 'wagmi'
import { publicProvider } from 'wagmi/providers/public'
const { chains, publicClient } = configureChains(
[chain.mainnet, chain.polygon],
[
alchemyProvider({ apiKey: 'yourAlchemyApiKey' }),
publicProvider({ stallTimeout: 1_000 }),
],
)weight (optional)
The weight a response from this provider provides. This can be used if a given provider is more trusted.
import { chain, configureChains } from 'wagmi'
import { publicProvider } from 'wagmi/providers/public'
const { chains, publicClient } = configureChains(
[chain.mainnet, chain.polygon],
[
alchemyProvider({ apiKey: 'yourAlchemyApiKey', weight: 1 }),
publicProvider({ weight: 2 }),
],
)