• Core
  • Getting Started

Getting Started

@wagmi/core is a VanillaJS library containing everything you need to start working with Ethereum. It makes it easy to "Connect Wallet," display ENS and balance information, sign messages, interact with contracts, and much more.

Installation

Install @wagmi/core and its ethers peer dependency.

npm i @wagmi/core ethers

Configure chains

First, configure your desired chains to be used by wagmi, and the providers you want to use.

import { configureChains, mainnet } from '@wagmi/core'
import { publicProvider } from '@wagmi/core/providers/public'
 
const { chains, provider, webSocketProvider } = configureChains(
  [mainnet],
  [publicProvider()],
)

This example uses the Ethereum Mainnet chain (mainnet) from @wagmi/core, however, you can also pass in any EVM-compatible chain.

Note: In a production app, it is not recommended to only pass publicProvider to configureChains as you will probably face rate-limiting on the public provider endpoints. It is recommended to also pass an alchemyProvider or infuraProvider as well.

Read more about configuring chains

Create a wagmi client

Next, create a wagmi Client instance using createClient, and pass the result from configureChains to it.

import {
  createClient,
  configureChains,
  mainnet,
} from '@wagmi/core'
import { publicProvider } from '@wagmi/core/providers/public'
 
const { chains, provider, webSocketProvider } = configureChains(
  [mainnet],
  [publicProvider()],
)
 
const client = createClient({
  autoConnect: true,
  provider,
  webSocketProvider,
})

Read more about client configuration

You're good to go!

Use actions! You can now import and use actions throughout your app.

import { connect, fetchEnsName } from '@wagmi/core'
import { InjectedConnector } from '@wagmi/core/connectors/injected'
 
const { address } = await connect({
  connector: new InjectedConnector(),
})
const ensName = await fetchEnsName({ address })

Want to learn more? Continue on reading the documentation.