Skip to content
Docs
/
Providers
/
Alchemy

Alchemy

The alchemyProvider configures the chains with Alchemy RPC URLs and also provides an ethers.js AlchemyProvider.

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

Usage

import { chain, configureChains } from 'wagmi'
import { alchemyProvider } from 'wagmi/providers/alchemy'

const alchemyId = process.env.ALCHEMY_ID

const { chains, provider } = configureChains(
  [chain.mainnet, chain.polygon],
  [alchemyProvider({ alchemyId })],
)

Return Value

{
  chains: Chain[],
  provider: AlchemyProvider,
  webSocketProvider: AlchemyWebSocketProvider
}

Configuration

alchemyId (optional)

Your Alchemy ID from the Alchemy Dashboard.

If no Alchemy ID is provided, it will use the public Alchemy ID. It is recommended to provide your own Alchemy ID to prevent being rate-limited.

import { chain, configureChains } from 'wagmi'
import { alchemyProvider } from 'wagmi/providers/alchemy'

const alchemyId = process.env.ALCHEMY_ID

const { chains, provider } = configureChains(
  [chain.mainnet, chain.polygon],
  [alchemyProvider({ alchemyId })],
)