Configuration
Configure TON Connect, assets, integrator fees, and Omniston connections for the STON.fi Widget.
Pass the initial configuration to the OmnistonWidget constructor. At runtime, call widget.updateConfig() to update the widget options and read widget.config to get their effective values. Set TON Connect and Omniston connection options when creating the widget.
The constructor accepts three configuration sections:
tonconnect
Yes
No
Configure TON wallet connections.
widget
No
Yes
Configure assets and integrator fees.
omniston
No
No
Configure the Omniston endpoint, logger, and transport.
TON Connect
TON Connect connects your application to TON wallets. The widget uses the connected wallet address to fetch asset balances and requests transaction signing through TON Connect. Choose standalone mode to let the widget manage the connection, or integrated mode to share your application's existing connection.
Both modes require a TON Connect manifest. This JSON file identifies your application to wallets through its URL, name, and icon. Host it at a public HTTPS URL that wallets can access without authentication, and provide that URL as manifestUrl.
Standalone mode
Use type: 'standalone' when your application does not already manage TON Connect. The widget automatically loads the latest version of TON Connect UI from its CDN and creates an instance using tonconnect.options. You do not need to install, load, or upgrade TON Connect separately.
const tonconnect = {
type: 'standalone',
options: {
manifestUrl: 'https://your-app.com/tonconnect-manifest.json',
},
};
const widget = new OmnistonWidget({ tonconnect });The options object accepts TON Connect UI constructor options, including your manifest URL.
Integrated mode
Use type: 'integrated' when your application already manages a TonConnectUI instance. Pass it as tonconnect.instance to share the wallet connection and account state. Configure the manifest URL when creating that instance.
The following example uses TonConnectUI from @tonconnect/ui. If your application already has an instance, pass that instance instead of creating another one:
In React, you can pass the TonConnectUI instance returned by useTonConnectUI() from @tonconnect/ui-react. Integrated mode requires the UI instance, including its wallet selection modal API.
Widget options
Use the widget section to configure the asset list, initial asset pair, and integrator fees. You can also use the visual constructor to configure these options through a web interface and export JavaScript configuration.
Assets
The widget supports native TON and jettons. Use TON address strings for asset options. For jettons, use the jetton master address. Token symbols such as TON or STON are not accepted.
defaultAssets
boolean
true
Include STON.fi's curated asset selection.
customAssets
string[]
None
Add assets by address. With defaultAssets: false, use these as your custom list.
defaultBidAsset
string
USD₮
Preselect the asset to sell.
defaultAskAsset
string
TON
Preselect the asset to receive.
With defaultAssets: true, users can select from assets that STON.fi considers suitable for trading. STON.fi maintains the selection criteria, so you do not need to manage your own default asset list.
Custom and preselected assets are added separately from this default selection. Assets must be available through the STON.fi API with metadata for their symbol and number of decimal places.
The examples below reuse the tonconnect configuration from the standalone example. They use these asset addresses:
Use the defaults
Omit widget or provide an empty object (widget: {}) to use the defaults. The widget includes STON.fi's curated asset selection (defaultAssets: true) and preselects USD₮ to sell and TON to receive:
Extend the default list
Keep defaultAssets enabled and add addresses through customAssets. This example adds STON if it is not already in the default list:
Use only two assets
Disable the default list and provide your custom assets. Set both preselected assets to addresses from that list, since the widget also includes preselected assets in asset requests. This example starts with only TON and STON:
With defaultAssets: false, search is limited to your custom asset list.
Integrator fees
Configure an integrator fee to receive a commission on trades through your widget.
referrerAddress
string
None
TON wallet address that receives the integrator fee.
referrerFeeBps
number
10 when referrerAddress is set
Requested integrator fee in basis points, from 0 to 100 (0% to 1%).
One basis point is 0.01%, so 50 requests a 0.5% integrator fee. Without referrerAddress, the widget does not request an integrator fee. Set both fields to choose the recipient and rate explicitly.
The widget enables Omniston's flexibleIntegratorFee parameter for swap routes. The effective integrator fee rate may vary from your configured rate depending on the route's fee constraints. See Integrator fees for fee amounts and payout details.
Omniston options
The optional omniston object accepts constructor parameters for Omniston from the Omniston SDK. The widget passes these options to the SDK constructor and uses the following defaults for omitted values:
apiUrl
string or URL
wss://omni-ws.ston.fi
Omniston WebSocket endpoint.
logger
Object with log, debug, warn, and error methods
Logging disabled
Use console or a custom logger with these methods.
transport
Omniston SDK Transport
WebSocket transport with automatic reconnection
Override the client's network transport.
For example, connect to the sandbox environment and enable console logging:
Update and read the configuration
Call widget.updateConfig() with the widget fields you want to change. Pass them directly, without a widget wrapper. The method updates the supplied fields and preserves omitted fields:
The config getter returns the effective widget options, including defaults. It does not return the tonconnect or omniston sections.
Next step
See Customization to configure the widget's appearance.
Last updated