Skip to main content

Multi-Chain

This guide covers using the useChain hook and ChainClient to build React applications that operate across multiple blockchains.
For an overview of multi-chain concepts, see Multi-Chain Concepts.

The useChain Hook

useChain returns a ChainClient for a specific chain, memoized to prevent unnecessary re-renders:
useChain returns null if the parent SDK is not yet initialized. Chain clients are cached by serverUrl, so calling useChain with the same URL in multiple components returns the same instance.

Setup

Wrap your app with PrivacyBoostProvider as usual. The provider initializes the parent SDK, and useChain creates chain clients from it:

Authentication

Each chain client must be authenticated independently. Use the wallet adapter from useAuth or create one manually:

Multi-Chain Dashboard

Here’s a pattern for building a multi-chain dashboard:

Chain-Scoped Components

Build reusable components that accept a ChainClient:

Balance Display

Deposit Form

Transfer Form

Chain Switching

Build a chain selector that lets users switch between chains:

Available Hooks

useAuth, useVault, useBalances, and useTransactions operate on the primary chain configured in the provider. For other chains, use useChain and access resources directly via the ChainClient (e.g., chain.vault, chain.transactions).

Next Steps