You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/ecosystem-adapters/getting-started.mdx
+201Lines changed: 201 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,8 +184,209 @@ try {
184
184
}
185
185
```
186
186
187
+
## Using with React
188
+
189
+
Adapters integrate with React through three layers: a **wallet context provider** that manages wallet SDK state, **`configureUiKit`** that selects and configures the wallet UI kit, and a **hook facade** that exposes a uniform set of React hooks across every ecosystem.
190
+
191
+
### Wallet Context Provider
192
+
193
+
Each adapter exports a root React component via `getEcosystemReactUiContextProvider()`. This component wraps your application (or the relevant subtree) and bootstraps the wallet SDK context — for example, EVM adapters render `WagmiProvider` and `QueryClientProvider` internally, while the Stellar adapter renders its own `StellarWalletContext.Provider`.
194
+
195
+
You don't render these providers yourself. Instead, pass the runtime to a shared `WalletStateProvider` from `@openzeppelin/ui-react`, which delegates to the correct ecosystem provider automatically:
The `loadConfigModule` callback lets the adapter lazily load user-authored wallet configuration files (e.g. `src/config/wallet/rainbowkit.config.ts` for a RainbowKit setup). If you don't use a native config file, pass a function that returns `null`.
213
+
214
+
### Configuring the UI Kit
215
+
216
+
Before rendering wallet UI components, configure the UI kit on the runtime's `uiKit` capability. This selects which wallet UI library to use (RainbowKit, a custom theme, or none) and passes kit-specific options:
`connectWallet` and `disconnectWallet` are imperative calls on the runtime — they are independent of the React rendering layer. You can call them from event handlers, effects, or outside React entirely.
266
+
</Callout>
267
+
268
+
### Hook Facade Pattern
269
+
270
+
Every adapter exports a **facade hooks** object that conforms to the `EcosystemSpecificReactHooks` interface. This gives consuming applications a uniform set of React hooks regardless of the underlying wallet library.
271
+
272
+
The EVM adapter maps its facade to [wagmi](https://wagmi.sh/) hooks, the Stellar adapter provides custom implementations, and other adapters follow the same pattern:
|`useAccount`| Returns the connected account address, connection status, and chain info |
287
+
|`useConnect`| Provides a `connect` function and available connectors |
288
+
|`useDisconnect`| Provides a `disconnect` function |
289
+
|`useSwitchChain`| Returns a `switchChain` function (EVM-only; stubs on other ecosystems) |
290
+
|`useChainId`| Returns the currently active chain ID |
291
+
|`useChains`| Returns the list of configured chains |
292
+
|`useBalance`| Returns the native token balance for the connected account |
293
+
294
+
In practice, you access facade hooks through the runtime rather than importing them directly — the runtime's `uiKit.getEcosystemReactHooks()` method returns the correct facade for the active ecosystem:
Hooks that don't apply to a given ecosystem return safe stubs. For example, the Stellar facade's `useSwitchChain` returns `{ switchChain: undefined }` — your components can feature-detect this without conditional imports.
320
+
</Callout>
321
+
322
+
## Multi-Ecosystem Apps
323
+
324
+
Applications that interact with multiple blockchains create one runtime per ecosystem. Each runtime is independent — it manages its own wallet session, RPC connections, and lifecycle.
325
+
326
+
### Setup
327
+
328
+
Install the adapters you need and the shared Vite plugin:
Each runtime is fully isolated. The EVM runtime connects to Ethereum via wagmi, the Stellar runtime connects to Horizon/Soroban — they share no state and can be disposed independently:
Wallet sessions are ecosystem-scoped, not runtime-scoped. Disposing an EVM runtime to switch from Mainnet to Sepolia does not disconnect the user's MetaMask — the wallet session persists across runtime recreation within the same ecosystem.
385
+
</Callout>
386
+
187
387
## Next Steps
188
388
189
389
- Read the [Architecture](/ecosystem-adapters/architecture) page for a deep dive into tiers, profiles, and lifecycle management
190
390
- Explore [Supported Ecosystems](/ecosystem-adapters/supported-ecosystems) to see what each adapter provides
191
391
- Follow the [Building an Adapter](/ecosystem-adapters/building-an-adapter) guide to add support for a new chain
392
+
- Browse the [adapter source code on GitHub](https://github.com/OpenZeppelin/openzeppelin-adapters) for implementation details
Copy file name to clipboardExpand all lines: content/ecosystem-adapters/index.mdx
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,10 @@ title: Ecosystem Adapters
4
4
5
5
**OpenZeppelin Ecosystem Adapters** are a set of modular, chain-specific integration packages that let applications interact with any supported blockchain through a single, unified interface. Built on 13 composable capability interfaces organized in 3 tiers, each adapter encapsulates everything needed — contract loading, type mapping, transaction execution, wallet connection, and network configuration — while keeping consuming applications completely chain-agnostic.
6
6
7
+
<Callouttype="info">
8
+
**Source code**: The adapters are open-source. Browse the implementation, open issues, and contribute at [**github.com/OpenZeppelin/openzeppelin-adapters**](https://github.com/OpenZeppelin/openzeppelin-adapters).
0 commit comments