• React
  • Providers
  • Alchemy

Alchemy

The alchemyProvider configures the chains with Alchemy RPC URLs.

import { alchemyProvider } from 'wagmi/providers/alchemy'

Usage

import { mainnet, polygon } from 'wagmi/chains'
import { configureChains } from 'wagmi'
import { alchemyProvider } from 'wagmi/providers/alchemy'
 
const { chains, publicClient } = configureChains(
  [mainnet, polygon],
  [alchemyProvider({ apiKey: 'yourAlchemyApiKey' })],
)

Note: The above example is using chains from the wagmi/chains entrypoint

Return Value

{
  chains: Chain[],
  publicClient: PublicClient,
  webSocketPublicClient: PublicClient
}

Configuration

apiKey

Your Alchemy API key from the Alchemy Dashboard.

import { configureChains } from 'wagmi'
import { mainnet, polygon } from 'wagmi/chains'
import { alchemyProvider } from 'wagmi/providers/alchemy'
 
const { chains, publicClient } = configureChains(
  [mainnet, polygon],
  [alchemyProvider({ apiKey: 'yourAlchemyApiKey' })],
)