How to export your Widget
There are two main ways of handling transaction signing: Local Signer and Parent Signer.
It is controlled by the "Use wallet connection inside the widget - Local Signer" switch on the export page. This choice determines the implementation method;
1. Local Signer
Local Signer, is an option with a separate session within the Widget for those looking for simplified implementation. The widget handles the wallet connection and the transaction signing.
Steps
Configure the widget according to your preferences.
Copy the iframe embed code.
Paste the code in your application code.
That’s it!
2. Parent Signer:
Parent Signer, is a more advanced option and aims to use the existing Parent App's session; it does not need a separate session for the users. If you want to use your existing wallet connection in the widget, you need to install our JS SDK for easy integration.
Steps
First, install the SDK with npm:
(optional) To get the function parameters easily, you can copy the
Parameters Object
on the export page.Then, you should use
generateIframeUrl
to generate the iframe URL, for example:
Use this URL to add the iframe element to your page:
Now you should be able to see the widget on your page, but still, you need to establish communication between the application and the widget. We use the
postMessage
API for this. Create an instance ofWidgetController
and set up event listeners with your own callbacks. This way, your application will get a message when the widget needs a signature on a transaction, or when there is an error. And you can send the transaction back to the widget after it’s signed.
Please follow our quick start guide here: https://github.com/tinymanorg/tinyman-swap-widget-sdk#quick-start
Last updated