Infura
The infuraProvider
configures the chains with Infura RPC URLs.
import { infuraProvider } from '@wagmi/core/providers/infura'
Usage
import { configureChains } from '@wagmi/core'
import { mainnet, polygon } from '@wagmi/core/chains'
import { infuraProvider } from '@wagmi/core/providers/infura'
const { chains, publicClient } = configureChains(
[mainnet, polygon],
[infuraProvider({ apiKey: 'yourInfuraApiKey' })],
)
Note: The above example is using chains from @wagmi/core/chains
.
Return Value
{
chains: Chain[],
publicClient: PublicClient,
webSocketPublicClient: PublicClient
}
Configuration
apiKey
Your Infura API key from the Infura Dashboard.
import { configureChains } from '@wagmi/core'
import { mainnet, polygon } from '@wagmi/core/chains'
import { infuraProvider } from '@wagmi/core/providers/infura'
const { chains, publicClient } = configureChains(
[mainnet, polygon],
[infuraProvider({ apiKey: 'yourInfuraApiKey' })],
)