JSON RPC
The jsonRpcProvider
configures the chains with the RPC URLs.
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc'
Usage
import { chain, configureChains } from 'wagmi'
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc'
const { chains, publicClient } = configureChains(
[chain.mainnet, chain.polygon],
[
jsonRpcProvider({
rpc: (chain) => ({
http: `https://${chain.id}.example.com`,
}),
}),
],
)
Return Value
{
chains: Chain[],
publicClient: PublicClient,
webSocketPublicClient: PublicClient
}
Configuration
rpc
Accepts a function which provides the chain
and expects to receive a http
URL and optionally a webSocket
URL.
import { chain, configureChains } from 'wagmi'
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc'
const { chains, publicClient } = configureChains(
[chain.mainnet, chain.polygon],
[
jsonRpcProvider({
rpc: (chain) => ({
http: `https://${chain.id}.example.com`,
webSocket: `wss://${chain.id}.example.com`,
}),
}),
],
)