Installation
Complete Example
React Hook Example
For React applications, here’s a reusable hook:Key Points
Authentication
- Use
sdk.login(clientId)- it registers a local session key and signs every authenticated request (public market reads are unsigned); there are no tokens to copy or refresh - The WebSocket is NOT auto-connected by default — pass
sdk.login(clientId, { connectWebSocket: true })(or connect explicitly) before usingsdk.ws.orders()to subscribe - Handle 401/403 status codes for authentication errors
Deposits & Withdrawals
- Get
assetIdfrom trading pairs viasdk.market.getTradingPairBySymbol()- usequoteAssetIdorbaseAssetId assetId(UUID) is used for vault operations:approve(),deposit(),withdraw(),getAllowance(), andneedsApproval()- Check balances using
sdk.profile.getUserBalanceByAssetId(assetId)for detailed balance info (available, locked, total) - Always check
needsApproval()before depositing - Use
parseUnits()with correct decimals for token amounts - Vault operations require authentication
Trading
- All amounts are strings (e.g.,
'1.5','2000.50') - Trading operations require authentication
- Orders return an
orderIdfor tracking - Time-In-Force (TIF) options:
'GTC'(default),'IOC', or'FOK'- GTC: Order stays active until filled or canceled
- IOC: Fill immediately, cancel unfilled portion
- FOK: Fill completely or reject entirely
Error Handling
- Check
error.statusCodefor HTTP errors (401, 403) - All operations can throw
APIError,ContractError, etc.
Next Steps
This example covers the core SDK functionality. For detailed guides on each feature:- Authentication Guide - Wallet-based authentication
- Deposit Guide - Token deposits and withdrawals
- Order Management - Order placement and management
- REST API - Direct REST API usage
Comprehensive example repositories with Vite and Next.js are in development for more complete project setups.

