walletShielded Wallet Provider

React context provider for shielded wallet and public client

React context component that wraps wagmi's connector client to provide ShieldedPublicClient and ShieldedWalletClient from seismic-viemarrow-up-right. This is the core provider that all Seismic React hooks depend on.

Import

import { ShieldedWalletProvider } from "seismic-react";

Props

Prop
Type
Required
Description

children

React.ReactNode

Yes

Child components that can access shielded wallet context

config

Config (from wagmi)

Yes

wagmi configuration object

options

object

No

Additional configuration options

options.publicTransport

Transport

No

Custom transport for the public client

options.publicChain

Chain

No

Custom chain for the public client

options.onAddressChange

(params: OnAddressChangeParams) => Promise<void>

No

Callback fired when the connected wallet address changes

OnAddressChangeParams

type OnAddressChangeParams = {
  publicClient: ShieldedPublicClient;
  walletClient: ShieldedWalletClient;
  address: Hex;
};

Context Value

The provider exposes a WalletClientContextType to all descendant components via React context:

Field
Description

publicClient

Shielded public client for encrypted reads. null until initialization completes.

walletClient

Shielded wallet client for encrypted writes. null until a wallet is connected.

address

Connected wallet address. null when no wallet is connected.

error

Error message if client creation fails. null when healthy.

loaded

true once the provider has finished its initial setup, regardless of whether a wallet is connected.

circle-info

Access these values through the useShieldedWallet hook rather than consuming the context directly.

Setup

Basic Setup with RainbowKit

Next.js Setup

For Next.js, create the provider in a client component:

Then wrap your layout:

Provider Nesting Order

The providers must be nested in this order:

circle-exclamation

Lifecycle

The provider follows this initialization sequence:

  1. Public client creation -- On mount, creates a ShieldedPublicClient using the chain and transport from the wagmi config (or from options.publicChain / options.publicTransport if provided). This client is available even when no wallet is connected.

  2. Wallet client creation -- When a wallet connects through wagmi, the provider creates a ShieldedWalletClient from the connector's client. This enables encrypted write transactions.

  3. onAddressChange callback -- If provided, called after both clients are ready with the new address. Use this to load user-specific data or initialize contract state.

  4. Reconnection handling -- When the user switches accounts or reconnects, the provider recreates the wallet client and fires onAddressChange again.

Usage with onAddressChange

The onAddressChange callback is useful for initializing state when a wallet connects:

Error Handling

The provider captures errors during client creation and exposes them through the context:

Error State
Cause
Resolution

Public client creation fails

Invalid chain config or transport

Check wagmi config and chain definitions

Wallet client creation fails

Connector incompatibility or network mismatch

Ensure the wallet supports the target chain

onAddressChange throws

Error in your callback

The error is caught and set on context.error

Access the error state through useShieldedWallet:

See Also

Last updated