Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.stable.xyz/llms.txt

Use this file to discover all available pages before exploring further.

You’ll install @stablechain/sdk, create a client signed by a private key, send a USDT0 transfer on Stable Testnet, and fetch a bridge and swap quote. Total time: about five minutes.
Stable uses USDT0 as the gas token. You only need testnet USDT0 to transact — there’s no separate native asset to fund.

Prerequisites

1. Install

mkdir stable-sdk-quickstart && cd stable-sdk-quickstart
npm init -y && npm install @stablechain/sdk viem
added 2 packages, audited 3 packages in 2s
Save your test key:
echo "PRIVATE_KEY=0xYOUR_TEST_KEY" > .env

2. Create a client

Create index.ts:
import "dotenv/config";
import { createStable, Network } from "@stablechain/sdk";
import { privateKeyToAccount } from "viem/accounts";

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);

const stable = createStable({
  network: Network.Testnet,
  account,
});

console.log("Signer:", account.address);
Signer: 0xYourAddress
createStable accepts three signing modes: account (server-side, shown above), transport (browser wallet via custom(window.ethereum)), or walletClient (a pre-built viem WalletClient). See Use the SDK with viem for all three.

3. Send a USDT0 transfer

Append to index.ts:
const { txHash } = await stable.transfer({
  from: account.address,
  to: "0x000000000000000000000000000000000000dEaD",
  amount: 0.001,
});

console.log("Transfer:", txHash);
Run it:
npx tsx index.ts
Signer: 0xYourAddress
Transfer: 0x8f3a...2d41
Open the hash on the testnet explorer to confirm.

4. Quote a bridge

Bridge USDT0 from Ethereum Sepolia to Stable Testnet. quoteBridge is a read-only call — no signature, no gas:
import { Chain } from "@stablechain/sdk";

const bridgeQuote = await stable.quoteBridge({
  fromChain: Chain.Sepolia,
  toChain: Chain.StableTestnet,
  fromToken: "0xc4DCC311c028e341fd8602D8eB89c5de94625927",
  toToken: "0x78Cf24370174180738C5B8E352B6D14c83a6c9A9",
  amount: 1,
});

console.log("Bridge quote:", bridgeQuote);
Bridge quote: { toAmount: 0.999812 }
Pass the quote into stable.bridge({ ...params, quote }) to execute. The SDK picks LayerZero for USDT0 → USDT0 routes and LI.FI for everything else.

5. Quote a swap

Swaps run on Stable through LI.FI. The quote returns the expected output and a pre-built transaction:
const swapQuote = await stable.quoteSwap({
  fromToken: "0x8a2B28364102Bea189D99A475C494330Ef2bDD0B",
  toToken: "0x78Cf24370174180738C5B8E352B6D14c83a6c9A9",
  amount: 1,
  fromDecimals: 6,
});

console.log("You'll receive:", swapQuote.toAmount, "USDT0");
You'll receive: 0.998 USDT0
Call stable.swap({ ...params, quote: swapQuote }) to execute. Approval for ERC-20 sources is handled internally.

SDK reference

Every parameter, return type, and error class.

Use with viem

Switch between private-key, browser-wallet, and pre-built WalletClient signing.

Use with wagmi

Wire the SDK into a React app using wagmi hooks.
Last modified on May 11, 2026