Docs
/Providers
/Infura
Infura
The infuraProvider
configures the chains with Infura RPC URLs and also provides an ethers.js InfuraProvider
.
import { infuraProvider } from 'wagmi/providers/infura'
Usage
import { chain, configureChains } from 'wagmi'
import { infuraProvider } from 'wagmi/providers/infura'
const infuraId = process.env.INFURA_ID
const { chains, provider } = configureChains(
[chain.mainnet, chain.polygon],
[infuraProvider({ infuraId })],
)
Return Value
{
chains: Chain[],
provider: InfuraProvider,
webSocketProvider: InfuraWebSocketProvider
}
Configuration
infuraId (optional)
Your Infura ID from the Infura Dashboard.
If no Infura ID is provided, it will use the public Infura ID. It is recommended to provide your own Infura ID to prevent being rate-limited.
import { chain, configureChains } from 'wagmi'
import { infuraProvider } from 'wagmi/providers/infura'
const { chains, provider } = configureChains(
[chain.mainnet, chain.polygon],
[infuraProvider({ infuraId })],
)