Shielded 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-viem. This is the core provider that all Seismic React hooks depend on.
Import
import { ShieldedWalletProvider } from "seismic-react";Props
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:
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.
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:
Lifecycle
The provider follows this initialization sequence:
Public client creation -- On mount, creates a
ShieldedPublicClientusing the chain and transport from the wagmi config (or fromoptions.publicChain/options.publicTransportif provided). This client is available even when no wallet is connected.Wallet client creation -- When a wallet connects through wagmi, the provider creates a
ShieldedWalletClientfrom the connector's client. This enables encrypted write transactions.onAddressChangecallback -- If provided, called after both clients are ready with the new address. Use this to load user-specific data or initialize contract state.Reconnection handling -- When the user switches accounts or reconnects, the provider recreates the wallet client and fires
onAddressChangeagain.
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:
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
Installation -- Package setup and peer dependencies
useShieldedWallet -- Hook to consume the provider context
Hooks Overview -- All available hooks
RainbowKit Guide -- Wallet UI integration
Privy Guide -- Embedded wallet setup
Last updated

