With just a few lines of code, all projects and developers can embed a cross-chain exchange between arbitrary assets within your app (mobile app, website, dApp, etc.) based on the deBridge protocol. You can make the widget part of your app and you're fully free to customize colors, fonts, chains, and tokens according to your design and preferences. Here's an example:
Here are the different steps to add the widget:
- Connect js script to your app
- Add html element with unique id on page
- Generate js object with the description of the widget settings. You can use the builder of deSwap Widget for auto-generation js object.
- Initialize deBridge.widget(initObject) , where initObject. - object with all settings.
Initializing must be executed after connection from step 1.
- 1.element: string (mandatory) - unique id of Html element on page
- 2.v: string - widget version( possible value '1')
- 3.mode: string - type of project (possible value ‘deswap’)
- 4.title: string - widget header
- 5.width: number - width of widget
- 6.height: number - height of widget
- 7.inputChain: number - id of inputChain (possible value: 1, 56, 137, 42161, 43114)
- 8.outputChain: number - id of outputChain (possible value: 1, 56, 137, 42161, 43114)
- 9.inputCurrency: string - address of input token
- 10.outputCurrency:string - address of output token
- 11.address: string - address of receiver
- 12.amount: - amount of exchange
- 13.lang: string - default language of widget( possible value: 'en', 'fr', 'jp', 'ko', 'ru', 'vi', 'zh')
- 14.styles: string - base64 view of styles object. Described below
- 15.theme: string - day/night theme (possible value ’dark’,’light’)
- 16.r: string - refferal address
At this moment only the "element" attribute is mandatory
must be "inputChain": "56",
object Styles consist of the following fields:
- 1.Widget settings fields.
- 2.Widget preview.
- 3.Field with source code for embedding in the application
- 1.Fill in the fields of widget settings to see your future widget. All field changes are updated in real-time.
- 2.Once UI and other settings suit your requirements, you can just copy the source code to your project to embed the widget according to the "Widget embedding" section.