Management API Reference

Wagmi template to create a web app

Kickstart your app with Wagmi and cross-app wallets.

The following is a quick and easy implementation for getting started with Wagmi template and the cross-app wallet of choice.

To make these instructions concrete, we have created a sample cross-app wallet called Rapidfire ID. To interact with it, you can find its SDK in the NPM package directory: @rapidfire/id.

You can check out the GitHub repository for Rapidfire Wallet to learn how to create your own wallet.

This guide will walk you through integrating the cross-app wallet Rapidfire ID.

If you need a template or scaffold to start with, you can check out the Rapidfire Wagmi Example.

1

Create a new Wagmi project

  • Run the project creation command using your preferred package manager
  • Follow the CLI prompts to set up your project
terminal

_10
npm create wagmi

2

Install dependencies and start development server

  • Install all required dependencies
  • Start the development server
  • Your app should now be running on localhost
terminal

_10
npm install @rapidfire/id
_10
npm install
_10
npm run dev

3

Configure Wagmi with Smart Wallet

  • Update the Wagmi configuration file.
  • Set up polygonAmoy as the primary chain.
  • Configure wallet connector with injected wallet preference.
wagmi.ts

_19
import { http, createConfig } from 'wagmi';
_19
import { polygonAmoy } from 'wagmi/chains';
_19
import { injected } from 'wagmi/connectors';
_19
_19
export const config = createConfig({
_19
chains: [polygonAmoy],
_19
connectors: [
_19
injected(),
_19
],
_19
transports: {
_19
[polygonAmoy.id]: http(),
_19
},
_19
});
_19
_19
declare module 'wagmi' {
_19
interface Register {
_19
config: typeof config;
_19
}
_19
}

4

Wrap App in Context Provider

Wrap your app in the WagmiProvider React Context Provider and pass the config you created earlier to the value property.

app.tsx
config.ts

_13
import { WagmiProvider } from 'wagmi'
_13
import { config } from './config'
_13
_13
function App() {
_13
useEffect(() => {
_13
config.getEthereumProvider();
_13
}, []);
_13
return (
_13
<WagmiProvider config={config}>
_13
{/** ... */}
_13
</WagmiProvider>
_13
)
_13
}

5

Keep building

You can find everything you need here: https://wagmi.sh/react/api/hooks