Node.js
Flow-based guide for integrating the Omniston SDK in Node.js with the v1beta8 API
The Node.js SDK gives you direct access to the Omniston API surface. In v1beta8, the main integration flow is:
prepare
settlementParamsfor the settlement methods you want to allowsubscribe to RFQ updates and select a quote from the stream
branch on
quote.settlementData?.$casebuild and sign either a swap flow or an order flow
track the resulting settlement
An end-to-end open source reference implementation is also available in our example app: examples/react-app
Installation
@ston-fi/omniston-sdk NPM Package
Install the SDK in your project:
npm install @ston-fi/omniston-sdkCreating an instance
Create an Omniston instance pointing to the desired API endpoint.
import { Omniston } from "@ston-fi/omniston-sdk";
const omniston = new Omniston({
apiUrl: "wss://omni-ws.ston.fi",
});If you are integrating against the sandbox environment, use:
Preparing settlement params
Before requesting a quote, decide which settlement methods you want the resolver network to consider. In v1beta8, this is controlled through settlementParams, where each item enables one settlement branch.
Use swap-only when you want classic swap execution, typically for simple TON flows. Use order-only when you want order settlement only, for example when your application is built specifically around signed orders or HTLC flows. Use both when you want Omniston to return the best available option and decide later based on the returned quote.
Quote receiving based on parameters
After preparing settlement params, request a quote and subscribe to the RFQ stream. requestForQuote() is a live stream and may emit multiple quoteUpdated events over time, so your integration should handle it as an ongoing subscription rather than as a one-shot request.
Settlement flows
Once you have selected a quote from the RFQ stream, branch on quote.settlementData?.$case and follow the corresponding settlement flow.
Swap quotes
Transaction building and sign
Once you have selected a quote from the stream and it uses swap settlement, build a TON transaction with tonBuildSwap(), then pass the resulting messages to the wallet or signing library you use in your application.
Tracking
After the swap transaction is sent, track the swap with swapTrack(). You need the quoteId, the trader wallet address, and an identifier that lets Omniston find the outgoing transaction.
Order quotes
Transaction building and sign
Once you have selected a quote from the stream and it uses order settlement, the build-and-sign flow depends on the source chain.
For TON order settlement, build an escrow transfer and sign the resulting TON messages:
For EVM order settlement, build the order payload, sign it with your EVM wallet, and register the signed order with Omniston:
Tracking
Once the order is submitted, use orderTrack() to monitor its lifecycle. For HTLC-based partial fills, the application must generate secrets on its own, pass their hashes when building the order payload, and later disclose the original secrets with orderDiscloseHtlcSecret() when executions reach the appropriate phase.
If you are using HTLC order settlement and manage secrets yourself, disclose them once an execution is ready:
Active orders list
If your application needs to restore existing order state or show all active orders for a trader, call orderGetActive(). Unlike requestForQuote(), this is a regular request-response method, so you should call it on demand or poll it from your application if you need periodic refresh.
Last updated