Client

The vagmi Client manages wallet connection state and configuration, such as: auto-connection, connectors, and ethers providers.


Usage

import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider, webSocketProvider } = configureChains(defaultChains, [  publicProvider(),]);const client = createClient({  provider,  webSocketProvider,});

Configuration

autoConnect (optional)

Enables reconnecting to last used connector on mount. Defaults to false.

import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider } = configureChains(defaultChains, [  publicProvider(),]);const client = createClient({  autoConnect: true,  provider,});

connectors (optional)

Connectors used for linking accounts. Defaults to [new InjectedConnector()].

import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';import { InjectedConnector } from 'vagmi/connectors/injected';import { WalletConnectConnector } from 'vagmi/connectors/walletConnect';const { chains, provider } = configureChains(defaultChains, [publicProvider()]);const client = createClient({  connectors: [    new InjectedConnector({ chains }),    new WalletConnectConnector({      chains,      options: {        qrcode: true,      },    }),  ],  provider,});

provider (optional)

ethers interface for connecting to the Ethereum network.

import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider } = configureChains(defaultChains, [publicProvider()]);const client = createClient({  provider,});

webSocketProvider (optional)

ethers WebSocket interface for connecting to the Ethereum network. If you provide a WebSocket provider, it will be used instead of polling in certain instances.

import { configureChains, createClient, defaultChains } from 'vagmi';import { publicProvider } from 'vagmi/providers/public';const { provider, webSocketProvider } = configureChains(defaultChains, [  publicProvider(),]);const client = createClient({  provider,  webSocketProvider,});