Skip to main content
@stablechain/sdk is built on viem. createStable accepts three signing modes, and you pick one based on where the code runs: server-side with a private key, browser-side with the user’s wallet, or with a WalletClient you’ve already constructed (for example, in a wagmi app). This guide shows each mode end-to-end.

Server-side: private-key Account

Use privateKeyToAccount from viem to sign with a private key held by your backend.

Browser-side: Transport from a wallet

Pass custom(window.ethereum) (or any EIP-1193 provider) as transport. The SDK builds the WalletClient and reads the signer address from the provider.
transfer, bridge, and swap call switchChain to put the wallet on the right network. If the user rejects, the SDK throws StableTransactionError with phase: "switch_chain". Catch it and surface a retry to the user.

Bring your own WalletClient

When you already have a WalletClient (for example, from wagmi or a custom signer), pass it directly. It takes precedence over account and transport.

Pick a mode

Use with wagmi

Wire the SDK into a React app through wagmi hooks.

SDK reference

Every config field, method, enum, and error class.

SDK quickstart

Run your first transfer, bridge, and swap on testnet.
Last modified on May 11, 2026