copy Copy chevron-down
Developer book-heart SDK IntegrationDeveloper Guide: SDK Integration
A comprehensive guide for developers to integrate StableFlow’s crosschain transfers into your applications.
Table of Contents
Getting Started
Copy npm install stableflow-ai-sdk Node.js : Version 16 or higher
TypeScript (recommended): For full type safety
API Configuration
Configuration Options
Option
Type
Description
Required
Include credentials in requests
Additional request headers
Retrieves the list of all supported tokens across different blockchains.
Signature
Returns
Array of TokenResponse objects containing:
Example Usage
Use Cases
Building token selection UI
Validating supported tokens
Getting current token prices
Discovering available networks
Requests a quote for cross-chain token swap, including fees, estimated time, and deposit address.
Signature
Request Parameters
Response
Example Usage
Important Notes
dry: true : Testing mode, no real deposit address
dry: false : Production mode, returns real deposit address
Amount Format : Always use smallest token unit (e.g., 1 USDT = 1000000 for 6 decimals)
Deadline : Must be a future timestamp in ISO 8601 format
Address Validation : Ensure addresses match the respective network format
3. submitDepositTx()
Notifies StableFlow that you've sent tokens to the deposit address.
Signature
Request Parameters
Response
Example Usage
When to Call
After sending tokens to depositAddress
After transaction is confirmed on blockchain
Before checking execution status
4. getExecutionStatus()
Checks the current status of a cross-chain swap.
Signature
Parameters
Deposit address from quote
Response
Example Usage
Polling Example
Working Examples
The SDK includes a complete web application example demonstrating real-world usage.
Web Demo Application
Location: examples/web-demo/
Features
â
Real wallet connection (MetaMask)
â
Token balance checking
Running the Example
Key Files to Study
app.ts - Main application logic
Wallet connection: connectWallet()
Network switching: switchNetwork()
Getting quotes: handleGetQuote()
Executing swaps: executeBridge()
Learning Path
Start with : Understanding the flow in app.ts
Study : Network configuration and asset IDs
Review : Error handling patterns
Examine : UI/UX best practices
Customize : Adapt for your use case
1. Error Handling
Always wrap SDK calls in try-catch blocks:
2. Token Amount Conversion
Always convert human-readable amounts to smallest units:
3. Deadline Management
Set reasonable deadlines:
4. Network Validation
Validate network compatibility:
5. Status Polling
Implement exponential backoff:
Common Use Cases
Use Case 1: Simple USDT Bridge
Bridge USDT from Ethereum to Arbitrum:
Use Case 2: Dynamic Token Selection
Let users choose any supported token pair:
Use Case 3: Fee Calculator
Calculate bridge fees before execution:
Troubleshooting
1. "Invalid token" Error
Cause : Using incorrect assetId format
Solution : Always get asset IDs from getTokens():
2. "Deadline is not valid" Error
Cause : Deadline is in the past or incorrect format
Solution : Use ISO 8601 format with future timestamp:
3. Authentication Errors
Cause : Missing or invalid JWT token
Solution :
ð Apply for JWT Token Here arrow-up-right
After receiving your token, set it before any API calls:
4. Network Mismatch
Cause : Wallet on wrong network when sending transaction
Solution : Check and switch network before transaction:
5. Transaction Stuck
Cause : Transaction not confirmed on blockchain
Solution : Wait for confirmation before submitting:
Additional Resources
Examples: examples/ directory
Issues: Report bugs via GitHub Issues
Website: https://app.stableflow.ai/
API Access: Apply for JWT token
Documentation: Latest API specs
Quick Reference
Function
Purpose
Required Fields
JWT Token, txHash, depositAddress
JWT Token, depositAddress
Integration Checklist
Happy Building!
For questions or support, visit our GitHub repositoryarrow-up-right or join our Discord communityarrow-up-right .