rainbowRainbowKit

Set up RainbowKit with Seismic for wallet connection

RainbowKit is the recommended wallet connection library for Seismic React apps. It provides a polished connect modal, chain switching, and account management out of the box.

Prerequisites

npm install @rainbow-me/rainbowkit wagmi viem @tanstack/react-query seismic-react seismic-viem

Step 1: Configure wagmi

Create a wagmi config using RainbowKit's getDefaultConfig with Seismic chains:

import { getDefaultConfig } from "@rainbow-me/rainbowkit";
import { seismicTestnet } from "seismic-react/rainbowkit";

const config = getDefaultConfig({
  appName: "My Seismic App",
  projectId: "YOUR_WALLETCONNECT_PROJECT_ID",
  chains: [seismicTestnet],
});
circle-exclamation

Step 2: Set Up Providers

Wrap your app with the provider stack. The nesting order matters:

circle-info

ShieldedWalletProvider must be inside RainbowKitProvider so it can access the connected wallet from wagmi's context.

Step 3: Add the Connect Button

RainbowKit provides a pre-built connect button component:

Step 4: Use Shielded Hooks

Once the providers are in place, use seismic-react hooks to interact with shielded contracts:

Next.js Setup

Next.js App Router requires client components for providers. Create a separate providers file:

Then wrap your root layout:

circle-info

The 'use client' directive is required because providers use React context, which is only available in client components.

Local Development with Sanvil

For local development, use the sanvil chain (Seismic's local development node) instead of seismicTestnet:

Complete Example

A full working setup in a single file:

See Also

Last updated