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