Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Stable SDK

@stablechain/sdk is the official TypeScript client for Stable. It wraps viem with a small, typed API for the operations you reach for most: transfer USDT0, bridge between chains, swap tokens, and earn yield on Stable. Routing, approvals, decimals, and chain switching are handled for you.

import { createStable, Network } from "@stablechain/sdk";
import { privateKeyToAccount } from "viem/accounts";
 
const stable = createStable({
  network: Network.Mainnet,
  account: privateKeyToAccount("0x..."),
});
 
const { txHash } = await stable.transfer({
  from: "0xYourAddress",
  to: "0xRecipient",
  amount: 10,
});
txHash: 0x8f3a...2d41

What the SDK does

  • transfer: send native USDT0 or any ERC-20 on Stable. Gas is paid in USDT0 automatically.
  • quoteBridge / bridge: cross-chain transfers via LI.FI, which picks the bridge route for you. Approval and chain switching are handled internally.
  • quoteSwap / swap: same-chain token swaps via LI.FI, with ERC-20 approval handled internally.
  • earn: supply USDT0 into a Morpho V2 vault to earn yield, withdraw or redeem, and claim Merkl incentive rewards. Approvals and adapter deallocations are handled for you.
  • createStableReader: a read-only client for vault APY, your position, yield projections, and instant-withdrawability checks. No signer required.

The SDK is published on npm as @stablechain/sdk and requires viem >= 2.0.0 as a peer dependency.

When to use it (and when not to)

Use the SDK when you want a typed, opinionated client that hides routing and approval boilerplate. Drop down to raw viem or ethers when you need direct control over transaction construction, custom gas strategies, or contract calls outside transfer / bridge / swap.

Start here

  • Quickstart: Install the SDK and run your first transfer, bridge, and swap on testnet.
  • Earn yield with the SDK: Deposit into a vault, read your APY and position, withdraw, and claim rewards.
  • SDK reference: Every method, config option, enum, and error class.
  • Use with viem: Server-side accounts, browser wallets, and bring-your-own WalletClient.
  • Use with wagmi: Wire the SDK into a React app with useWalletClient and hooks.

Next recommended