React
Flow-based guide for integrating the Omniston React SDK in applications
The React SDK gives you Omniston as ready-to-use hooks on top of the base SDK. 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
Migrating an existing app from @ston-fi/omniston-sdk-react@0.7 and Omniston API v1beta7? Use the React SDK v0.7 to v0.8 migration guide.
Installation
@ston-fi/omniston-sdk-react NPM Package
Install the SDK in your project:
npm install @ston-fi/omniston-sdk-reactCreating an instance
Create an Omniston instance, then provide it through OmnistonProvider.
If you are integrating against the sandbox environment, use:
If your application already uses a TanStack Query client, you can pass it to OmnistonProvider to reuse the same client instead of creating a separate one:
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. useRfq() is backed by the same RFQ stream as requestForQuote(), so your integration should handle it as a stream of updates 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 useTonBuildSwap(), 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 useActiveOrders().
Last updated