Use this file to discover all available pages before exploring further.
createStable accepts a viem WalletClient, which is exactly what wagmi’s useWalletClient returns. You connect the wallet through wagmi as you normally would, then memoize a StableClient whenever the wallet client changes.This guide assumes wagmi v2 and @tanstack/react-query.
Memoize a StableClient against the current WalletClient. Recreate it when the wallet client identity changes.
import { useMemo } from "react";import { useWalletClient } from "wagmi";import { createStable, Network, type StableClient } from "@stablechain/sdk";export function useStable(network: Network = Network.Mainnet): StableClient | null { const { data: walletClient } = useWalletClient(); return useMemo(() => { if (!walletClient) return null; return createStable({ network, walletClient }); }, [walletClient, network]);}
useWalletClient() returns undefined before the user connects. Always guard before calling SDK methods, or the destructured walletClient will be falsy and createStable will not have a signer.
Caching quotes with useQuery works well: pass quoteSwap / quoteBridge as the query function and forward the cached quote into swap / bridge. The SDK skips its internal quote call when one is provided.