SDK quickstart
You'll install @stablechain/sdk, create a client signed by a private key, send a USDT0 transfer on Stable Testnet, and fetch a mainnet bridge quote. Total time: about five minutes.
Prerequisites
- Node.js 20 or later
- A test private key with testnet USDT0. See Fund your testnet wallet.
1. Install
mkdir stable-sdk-quickstart && cd stable-sdk-quickstart
npm init -y && npm pkg set type=module
npm install @stablechain/sdk viem dotenvadded 3 packages, audited 4 packages in 2stype=module lets you use top-level await in the steps below; without it, tsx rejects the script.
Save your test key:
echo "PRIVATE_KEY=0xYOUR_TEST_KEY" > .env2. 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: 0xYourAddresscreateStable 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.tsSigner: 0xYourAddress
Transfer: 0x8f3a...2d41Open the hash on the testnet explorer to confirm.
4. Quote a bridge
Bridge and swap routing goes through LI.FI, which supports Stable Mainnet but no testnets. quoteBridge is a read-only call (no signature, no gas, no funds needed), so you can preview a mainnet bridge with the same key. Append:
import { Chain } from "@stablechain/sdk";
const stableMainnet = createStable({
network: Network.Mainnet,
account,
});
const bridgeQuote = await stableMainnet.quoteBridge({
fromChain: Chain.Ethereum,
toChain: Chain.Stable,
fromToken: "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT on Ethereum
toToken: "0x779Ded0c9e1022225f8E0630b35a9b54bE713736", // USDT0 on Stable
amount: 100,
});
console.log("Bridge quote:", bridgeQuote);Bridge quote: { toAmount: 99.73 }Pass the quote into stableMainnet.bridge({ ...params, quote }) to execute. Routing goes through LI.FI, which picks the bridge route; the SDK handles approval and chain switching.
5. Swaps
Same-chain swaps follow the same pattern: stable.quoteSwap returns the expected output and a pre-built transaction, and stable.swap({ ...params, quote }) executes it with ERC-20 approval handled internally.
Next recommended
- SDK reference: Every parameter, return type, and error class.
- Earn yield with the SDK: Deposit USDT0 into a mainnet vault, check your APY and position, and withdraw.
- Use with viem: Switch between private-key, browser-wallet, and pre-built
WalletClientsigning. - Use with wagmi: Wire the SDK into a React app using wagmi hooks.

