A powerful TypeScript SDK for seamless cross-chain token swaps. Built with type safety in mind, this SDK enables developers to easily integrate cross-chain swapping functionality into their applications with minimal setup.
- Node.js >= 16
- npm / yarn / pnpm
# Using npm
npm install stableflow-ai-sdk
# Using yarn
yarn add stableflow-ai-sdk
# Using pnpm
pnpm add stableflow-ai-sdkimport { OpenAPI, QuoteRequest, SFA } from 'stableflow-ai-sdk';
// Initialize the API client
OpenAPI.BASE = 'https://api.stableflow.ai';
// Configure your JSON Web Token (JWT) - required for most endpoints
OpenAPI.TOKEN = "your-JSON-Web-Token";
// Create a quote request
const quoteRequest: QuoteRequest = {
dry: true, // set to true for testing / false to get `depositAddress` and execute swap
swapType: QuoteRequest.swapType.EXACT_INPUT,
slippageTolerance: 100, // 1%
originAsset: 'nep141:arb-0xaf88d065e77c8cc2239327c5edb3a432268e5831.omft.near', // USDC on Arbitrum
depositType: QuoteRequest.depositType.ORIGIN_CHAIN,
destinationAsset: 'nep141:sol-5ce3bf3a31af18be40ba30f721101b4341690186.omft.near', // USDC on Solana
amount: '1000000', // 1 USDC (in smallest units)
refundTo: '0x2527D02599Ba641c19FEa793cD0F167589a0f10D', // Valid Arbitrum address
refundType: QuoteRequest.refundType.ORIGIN_CHAIN,
recipient: '13QkxhNMrTPxoCkRdYdJ65tFuwXPhL5gLS2Z5Nr6gjRK', // Valid Solana Address
recipientType: QuoteRequest.recipientType.DESTINATION_CHAIN,
deadline: "2025-08-06T14:15:22Z"
};
// Get quote
const quote = await SFA.getQuote(quoteRequest);const quote = await SFA.getQuote(quoteRequest);const status = await SFA.getExecutionStatus(depositAddress);const result = await SFA.submitDepositTx({
txHash: '0x...',
depositAddress: '0x...'
});const tokens = await SFA.getTokens();The StableFlow AI API requires JWT authentication for all endpoints.
To use the SDK, you need to apply for a JWT token:
- Visit https://app.stableflow.ai/apply
- Submit an application form for API access
- Once approved, you will receive your JWT token
// Set your JWT token
OpenAPI.TOKEN = 'your-JSON-Web-Token-here';All API endpoints require JWT authentication:
SFA.getTokens()- Get supported tokensSFA.getQuote()- Get swap quoteSFA.submitDepositTx()- Submit transactionSFA.getExecutionStatus()- Check transaction status
The SDK throws typed errors that you can catch and handle:
try {
const quote = await SFA.getQuote(quoteRequest);
} catch (error) {
if (error instanceof ApiError && error.status === 401) {
// Handle authentication errors
console.error('Authentication failed: JWT is missing or invalid');
} else if (error instanceof ApiError && error.status === 400) {
// Handle bad request
console.error('Invalid request:', error.body);
} else {
// Handle other errors
console.error('Error:', error);
}
}The SDK provides full TypeScript type definitions, including:
QuoteRequest- Parameters for requesting a quoteQuoteResponse- Quote response dataGetExecutionStatusResponse- Execution status responseSubmitDepositTxRequest- Submit deposit transaction requestSubmitDepositTxResponse- Submit deposit transaction responseTokenResponse- Token information
Try our interactive web app with real wallet connection:
cd examples/web-demo
npm install
npm run devFeatures:
- π Wallet Connection - Connect MetaMask or compatible wallets
- π¨ Modern UI - Beautiful dark theme with gradients
- π 6 Major Networks - Ethereum, Arbitrum, Polygon, BNB Chain, Optimism, Avalanche
- π° USDT Bridging - Seamless USDT transfers across networks
- π΅ Real-Time Quotes - Get accurate fee and time estimates
- π Execute Transactions - Bridge USDT across chains with one click
- π Transaction History - Track your bridging activity
Tech Stack: TypeScript, Vite, ethers.js, StableFlow SDK
See examples/web-demo/README.md for full documentation.
Developer commands:
# Install dependencies
npm install
# Build the SDK
npm run build
# Clean build artifacts
npm run clean
# Watch mode for development
npm run devMIT
For issues or support:
- Open an issue on GitHub
- Check the documentation
- Contact our support team
- Initial release
- Support for cross-chain token swaps
- JWT authentication support
- Full TypeScript type definitions