Instruction
Get started
Put this script tag to the
<head>
of your page
2. Put this div
tag to the place, where the Rubic Widget will be
3. Put this script tag to the bottom of <body>
⚠️ You should enter tokens addresses in ethereum checksum format. To avoid errors, copy the token address from a blockchain explorer, for example, etherscan.
You can customize the configuration parameters the way you want. Below is a description of the options available.
Available configuration parameters
Parameter | Possible values | Default | Description |
| Token symbol (e.g. 'ETH', 'RBC') or address (e.g. '0x32Be343B94f860124dC4fEe278FDCBD38C102D88') |
| Can be used to specify tokens to trade. |
| Token symbol (e.g. 'ETH', 'RBC') or address (e.g. '0x32Be343B94f860124dC4fEe278FDCBD38C102D88') |
| Can be used to specify tokens to trade. |
| 'ETH', 'BSC', 'POLYGON', 'HARMONY', 'FANTOM', 'MOONRIVER' etc |
| Can be used to specify chain to trade. |
| 'ETH', 'BSC', 'POLYGON', 'HARMONY', 'FANTOM', 'MOONRIVER', 'XDAI' etc |
| Can be used to specify chain to trade. |
|
| Can be used to specify the initial trade amount. | |
| 'true', 'false' |
| Can be used to specify widget appearance. flex -- the widget adjusts to the rubic-widget-rootcontainer size: if the width of the container is less than 1180px, then the widget is vertical, otherwise, it is horizontal |
| 'true', 'false' |
| Allows you to block the selection of tokens on the form. Thus, it will be possible to exchange only the tokens specified in the parameters. |
| 'true', 'false' |
| Allows you to block the selection of tokens on the form. Thus, it will be possible to exchange only the tokens specified in the parameters. |
| 'dark', 'light' |
| Can be used to specify the theme of the visual design. |
| 'en', 'es', 'ko', 'ru', 'zh' |
| Allows you to set widget language. |
|
| Allows you to add your tokens to the tokens selection list inside widget. | |
|
| Allows you to set default slippage for Instant Trades and Cross-Chain swaps. | |
not set | Allows you to charge fee from every swap, means fee percent (e.g. 0.1 is 0.1%). Not required. If not set, swaps will be without fee. If set, property feeTarget must be set too. | ||
| not set | Target address to charge fee to. Not required if fee property not set. If set, property fee must be set too. | |
['izumi', 'jupiter', ...] | not set | List of available providers for on-chain swap. | |
['lifi', 'changenow', ...] | not set | List of available providers for cross-chain swap. | |
['izumi', 'jupiter', ...] | not set | List of unavailable providers for on-chain swap. | |
['lifi', 'changenow', ...] | not set | List of unavailable providers for cross-chain swap. |
Dynamic change parameters
You can change the theme of the widget when changing the theme on your site, or any other parameters dynamically. To do this, call the init method again with the updated configuration. The previous widget will be deleted and a new one will be created instead.
Change widget theme when site theme changing
Remember that when using server-side rendering, the script with the widget setting must be executed on the client-side. When adding the widget initialization code, make sure that it will only be executed on the client.
For example, if you use NuxtJs you should use the following code to initialize the widget:
Last updated