If your app already manages wallet connection — through Wagmi, RainbowKit, or a custom adapter — you can pass that wallet directly to Trustware instead of letting the SDK run its own discovery. The widget UX stays the same; only wallet ownership changes.Documentation Index
Fetch the complete documentation index at: https://docs.trustware.io/llms.txt
Use this file to discover all available pages before exploring further.
When to use this pattern
Choose this pattern when:- your app has an existing Wagmi or RainbowKit setup
- you have custom wallet orchestration and do not want the SDK to interfere
- you want the full widget flow but need Trustware to use your connected wallet
Setup
Import the Wagmi adapter
The
useWagmi adapter is exported from a separate sub-path to keep the main bundle lean. It converts a viem WalletClient into the wallet interface that TrustwareProvider expects.Create a stable wallet reference with useMemo
useWalletClient returns a new object reference on every render. Wrap the adapter in useMemo so the wallet reference only changes when walletClient itself changes.How it works
What useWagmi does
useWagmi adapts a viem WalletClient to the WalletInterFaceAPI that TrustwareProvider accepts. It exposes the address, chain, and signing methods Trustware needs to build and submit routes — without requiring you to implement that bridge yourself.
autoDetect={false}
Setting autoDetect={false} tells TrustwareProvider not to run its own wallet discovery. Without this, the SDK would attempt auto-detection even when a wallet is already provided, which can cause conflicts with your existing wallet state.
Why useMemo matters
useWalletClient from Wagmi returns a new object reference on every render cycle, even when the underlying wallet hasn’t changed. Without useMemo, every render would produce a new wallet value, causing TrustwareProvider to treat each one as a wallet change and unnecessarily re-initialize its internal state.
Using with RainbowKit
TrustwareProvider must sit inside your Wagmi and RainbowKit providers so it has access to their React context. If you place it outside WagmiProvider, calls to useWalletClient will fail.
