Getting Started
Installation
Inside your React project directory, run the following:
yarn add wagmi ethers
Or with npm:
npm install wagmi ethers
Quick Start
Wrap your app with the Provider component:
import { Provider } from 'wagmi'
const App = () => ( <Provider> <YourRoutes /> </Provider>)
💡
Provider has multiple configuration options: connectors (i.e. WalletConnect), auto connect, websockets, etc. Check here for more info.
Now every component inside and under the Provider is set up with the default InjectedConnector and can use hooks for getting account information, switching networks, fetching token balances, etc:
import { useAccount, useConnect } from 'wagmi'
export const App = () => { const [{ data, error, loading }, disconnect] = useAccount({ fetchBalance: true, fetchEns: true, })
return ...}
wagmi!