# (Legacy) XY Finance Widget (iframe)

XY Finance team has been wracking our brains just to come up with a powerful engagement tool to help strengthen your user retention, making them want to come back more for a satisfying user experience that this widget provides for your website and reducing friction by letting them fast-forward into your app's/site's key functionality. Note that this Widget will be constantly renewed as we're also gathering more resources and collecting feedback from users along the way.&#x20;

The "Get Started" section below gives a step-by-step walkthrough as to how you're supposed to do to complete the embedding process and personalize your web/app experience, making transactions on your protocol way easier and interfaces look gracefully effortless! The "Configuration" section, however, categorizes the elements (keys) in the code, providing a clearer picture with regard to the website embedded.

## Get Started

Step 1. Paste this code as high in the **\<head>** of the page as possible

```html
<script defer type="text/javascript" src="https://widget.xy.finance/js/bundle.min.js"></script> 
```

Step 2. Paste this **\<div>** tag to the place where you need Widget to display in `body`&#x20;

```html
<div id="xy-finance-widget-root"></div>
```

Step 3. Paste this **\<script>** to the bottom of `body`

```html
<script defer>
  setTimeout(() => {
    // set default config
    const config = {
      fromTokenAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
      sourceChainId: '1',
      toTokenAddress: '0x77777777772cf0455fB38eE0e75f38034dFa50DE',
      targetChainId: '1',
      amount: 1,
      slippage: '1',
      orientation: 'portrait',
      theme: 'dark',
      lockmode: 'none',
      pagecolor: null,
      referrer: '0x856ebdc948afFCc6E24FCe08458051B19de652F6'
    }

    // use widget
    xyFinanceWidget.init(config);
  }, 2000)
</script>
```

### Configuration

<table><thead><tr><th width="196">Key</th><th width="179">Type</th><th width="140">Default</th><th>Note</th></tr></thead><tbody><tr><td>fromTokenAddress</td><td>String</td><td>'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'</td><td></td></tr><tr><td>sourceChainId</td><td>String</td><td>'1'</td><td></td></tr><tr><td>toTokenAddress</td><td>String</td><td>'0x77777777772cf0455fB38eE0e75f38034dFa50DE'</td><td></td></tr><tr><td>targetChainId</td><td>String</td><td>'1'</td><td></td></tr><tr><td>amount</td><td>Number</td><td>1</td><td></td></tr><tr><td>slippage</td><td>String</td><td>'1'</td><td>If the difference between the estimated quote and execution price exceeds the rate(default rate 1%),the tx will be revoked.</td></tr><tr><td>orientation</td><td><code>portrait</code> | <code>landscape</code></td><td><code>portrait</code></td><td>For now, only support 'portrait'</td></tr><tr><td>theme</td><td><code>dark</code> | <code>light</code></td><td><code>dark</code></td><td></td></tr><tr><td>lockmode</td><td><code>none</code> or <code>both</code> or <code>fromToken</code> or <code>toToken</code></td><td><code>none</code></td><td>Disable user select Token </td></tr><tr><td>pagecolor</td><td>String or null</td><td>null</td><td>Only use HexColor without <code>#</code></td></tr><tr><td>referrer</td><td>String or null</td><td>null</td><td>Address of the referrer, this address will be used uniformly for any future partner incentive programs</td></tr></tbody></table>

The "sourceChainId" and "targetChainId" in the configuration can be found in the page below.

{% content-ref url="../../supported-blockchains-bridges-dexs" %}
[supported-blockchains-bridges-dexs](https://docs.xy.finance/supported-blockchains-bridges-dexs)
{% endcontent-ref %}

**Theme : Dark**

![](https://3694085950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mcs9EhDrgbKHodtcAT6%2Fuploads%2Fd2v2WG0OVN3GLDzP6f94%2F%E6%88%AA%E5%9C%96%202022-08-18%20%E4%B8%8B%E5%8D%886.27.03.png?alt=media\&token=26361a37-6756-486d-8de8-2b561e62502e)

**Theme : Light**

<figure><img src="https://3694085950-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mcs9EhDrgbKHodtcAT6%2Fuploads%2FJfrOAxaBerTtVEULQBBj%2F%E6%88%AA%E5%9C%96%202022-09-22%20%E4%B8%8B%E5%8D%882.25.17.png?alt=media&#x26;token=7f9d8954-3d7e-4b36-8f9c-6aa7882faf69" alt=""><figcaption></figcaption></figure>
