# Monetization

You can charge widget users a fee for any of their successful transactions performed through the widget. Below, we present a detailed tutorial on activating affiliate functionality for your decentralized application (dApp) using the Rango Widget Config.

## 1. Create Affiliate Ref Code

To begin, you should navigate to the [Rango dApp affiliate section](https://app.rango.exchange/affiliate) and establish a connection with your EVM-compatible wallet. From there, you can generate a referral link by clicking on the "Invite Friends" button.

<figure><img src="/files/fTgyAb2KkxHWQ2rIISve" alt=""><figcaption></figcaption></figure>

After creating the link, you will notice that your `affiliateRef` code is located at the end of the link, similar to the illustration provided. By default, Rango will utilize the wallet address you used during the link creation process to deliver your affiliate reward.

## 2. Update Widget Affiliate Config

By utilizing the `affiliateRef` that you generated in step 1, you can enable the fee collection feature within the widget by passing this parameter to the widget configuration as shown below:

<pre class="language-typescript"><code class="lang-typescript">import { Widget, WidgetConfig } from "@rango-dev/widget-embedded";

export default function App() {

  const config = {
    // This API key is only for test purpose. Don't use it in production.
    apiKey: 'c6381a79-2817-4602-83bf-6a641a409e32',
<strong>    affiliate: {
</strong><strong>      // The affilaite ref code you've created on step above
</strong><strong>      ref: 'YOUR_AFFILIATE_REF_CODE',
</strong><strong>      // The affiliate percent you want to charge users based on input amount
</strong><strong>      // Setting 0.1 means 0.1% of input amount
</strong><strong>      percent: 0.1,
</strong><strong>      // If you want to change the default wallet that you want to earn reward,  
</strong><strong>      // you could pass your desired wallets in this property 
</strong><strong>      wallets: {
</strong><strong>        'ETH': 'your wallet',
</strong><strong>        'BSC': 'your wallet',
</strong><strong>        'POLYGON': 'your wallet',
</strong><strong>        // ...
</strong><strong>      }
</strong><strong>    }
</strong>  }
              
  return (
    &#x3C;div className="App">
      &#x3C;Widget config={config} />
    &#x3C;/div>
  );
}
</code></pre>

Whenever a user initiates a swap using the Rango Widget, you will receive a referral percent of 0.1% from the input amount. If desired, you can customize the affiliate percent by including the parameter "affiliate.percent" in the configuration. Please note that the maximum allowed value for the affiliate percent is 3 percent.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rango.exchange/widget-integration/monetization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
