Menu
Home
About
Our Role
Goals
The Team
Roadmap
Tokenomics
How To Buy
Knowledge Base
Contacts
Sitemap & Links
A.I.
Chart
Shop
IMMORTALITY
🏠
⬇️
Chart
New name
B
I
U
S
link
image
code
HTML
list
Show page
Syntax
{html} <iframe id="dextools-widget" title="DEXTools Trading Chart" width="100%" height="700" src="https://www.dextools.io/widget-chart/en/bnb/pe-light/0xfa56e9abcaa45207be5e43cf475ee061768ca915?theme=light&chartType=2&chartResolution=30&drawingToolbars=false"></iframe> <b>As a rough guide, 100 million IMT entered as 100000000 is about <s>2.30</s>, <s>3.00</s>, 4.00 USD or about 0.0033 BNB.</b> The max calculation requires the network fee to be set to slowest otherwise not enough deducted for gas. <div style="display: flex; justify-content: center; gap: 1rem; margin-top: 2rem;"> <button id="connect2" type="button" style="flex: 0 0 33%; padding: 0.75rem; border-radius: 4px; border: none; background: #007bff; color: #fff; cursor: pointer;"> ➡️ Connect to Wallet </button> <button id="addToken" type="button" style="flex: 0 0 33%; padding: 0.75rem; border-radius: 4px; border: none; background: #007bff; color: #fff; cursor: pointer;"> ➡️ Add Immortality </button> </div> <script> (function() { const ui_connectButton = document.getElementById('connect2'); const ui_addTokenButton = document.getElementById('addToken'); const ui_bscParams = { chainId: '0x38', chainName: 'Binance Smart Chain', nativeCurrency: { name: 'BNB', symbol: 'BNB', decimals: 18 }, rpcUrls: ['https://bsc-dataseed.binance.org/'], blockExplorerUrls: ['https://bscscan.com'] }; const ui_tokenDetails = { address: '0x2bf2141ed175f3236903cf07de33d7324871802d', symbol: 'IMT', decimals: 8, image: 'https://imt.cx/imtmm.png' }; let isConnecting = false; let listenersSet = false; function ui_isMobile() { return /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); } function ui_isMetaMaskBrowser() { return typeof window.ethereum !== 'undefined' && window.ethereum.isMetaMask; } function ui_redirectToMetaMaskApp() { const ui_dappUrl = encodeURIComponent(window.location.href); window.location.href = `https://metamask.app.link/dapp/${ui_dappUrl}`; } function ui_updateButtonState() { if (!ui_connectButton) return; ui_connectButton.textContent = isConnecting ? '⏳ Connecting...' : '➡️ Connect to Wallet'; ui_connectButton.disabled = isConnecting; } async function ui_waitForEthereum(timeout = 5000) { const interval = 100; const maxAttempts = timeout / interval; let attempt = 0; while (attempt++ < maxAttempts) { if (window.ethereum) return true; await new Promise(res => setTimeout(res, interval)); } return false; } async function ui_connectDeepLink() { if (isConnecting) return; isConnecting = true; ui_updateButtonState(); if (ui_isMobile() && !ui_isMetaMaskBrowser()) { // Reset state so button isn't stuck isConnecting = false; ui_updateButtonState(); ui_redirectToMetaMaskApp(); return; } const found = await ui_waitForEthereum(); if (!found) { alert('MetaMask not detected!'); isConnecting = false; ui_updateButtonState(); return; } try { await window.ethereum.request({ method: 'eth_requestAccounts' }); try { // Try switching chain first await window.ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: ui_bscParams.chainId }] }); } catch (switchErr) { if (switchErr.code === 4902) { // Chain not found, try adding await window.ethereum.request({ method: 'wallet_addEthereumChain', params: [ui_bscParams] }); } else { throw switchErr; } } alert('✅ Wallet connected and switched to BSC!'); setupListeners(); } catch (err) { console.error('Connection error:', err); if (err.code === 4001) { alert('Connection request rejected.'); } else if (err.code === -32002) { alert('A connection request is already pending in MetaMask. Please check MetaMask and approve it.'); } else { alert('Error connecting wallet.'); } } finally { isConnecting = false; ui_updateButtonState(); } } async function ui_addTokenToWallet() { if (ui_isMobile() && !ui_isMetaMaskBrowser()) { ui_redirectToMetaMaskApp(); return; } if (!window.ethereum) { alert('MetaMask not detected!'); return; } try { const wasAdded = await window.ethereum.request({ method: 'wallet_watchAsset', params: { type: 'ERC20', options: ui_tokenDetails } }); alert(wasAdded ? '✅ IMT added to wallet!' : 'Token not added.'); } catch (err) { console.error('Add token error:', err); alert('Error adding token.'); } } function setupListeners() { if (!window.ethereum || listenersSet) return; listenersSet = true; window.ethereum.on('accountsChanged', (accounts) => { if (accounts.length === 0) { console.log('MetaMask disconnected'); } else { console.log('Accounts changed:', accounts); } }); window.ethereum.on('chainChanged', (chainId) => { console.log('Network changed to:', chainId); if (chainId !== ui_bscParams.chainId) { alert('Please switch back to BSC.'); } }); } // Initialize UI ui_updateButtonState(); if (ui_connectButton) { ui_connectButton.addEventListener('click', ui_connectDeepLink); } if (ui_addTokenButton) { ui_addTokenButton.addEventListener('click', ui_addTokenToWallet); } })(); </script> <script src="https://cdn.jsdelivr.net/npm/ethers@5/dist/ethers.umd.min.js"></script> <div style="font-family: Arial, sans-serif; background: #fff; display: flex; flex-direction: column; align-items: center; padding: 2rem;"> <div style="background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); width: 100%; max-width: 100%;"> <h3 style="color: #000">Swap IMT ↔ BNB</h3><br> <label for="amount">Amount:</label> <input type="number" id="amount" placeholder="0.004" min="0" step="0.0001" value="0.004" style="width: 100%; padding: 0.75rem; margin: 0.5rem 0; border-radius: 4px; border: 1px solid #ccc;" /> <div style="display: flex; gap: 0.5rem; margin-bottom: 1rem;"> <button id="maxImt" style="flex: 1; padding: 0.75rem; border-radius: 4px; border: none; background: #17a2b8; color: #fff; cursor: pointer;">Max IMT</button> <button id="maxBnb" style="flex: 1; padding: 0.75rem; border-radius: 4px; border: none; background: #28a745; color: #fff; cursor: pointer;">Max BNB</button> </div> <label for="slippage">Slippage Tolerance (%):</label> <input type="number" id="slippage" placeholder="e.g. 15" min="0" max="100" value="15" style="width: 100%; padding: 0.75rem; margin: 0.5rem 0; border-radius: 4px; border: 1px solid #ccc;" /> <button id="connect" style="width: 100%; padding: 0.75rem; margin: 0.5rem 0; border-radius: 4px; border: none; background: #007bff; color: #fff; cursor: pointer;"> Connect Wallet </button> <button id="swap" disabled style="width: 100%; padding: 0.75rem; margin: 0.5rem 0; border-radius: 4px; border: none; background: #aaa; color: #fff;"> Swap IMT → BNB </button> <button id="reverse" disabled style="width: 100%; padding: 0.75rem; margin: 0.5rem 0; border-radius: 4px; border: none; background: #aaa; color: #fff;"> Swap BNB → IMT </button> <p id="status" style="min-height: 1.5em; white-space: pre-line;"></p> <p id="summary" style="min-height: 1.5em; white-space: pre-line;"></p> </div> </div> <style> button#swap[disabled], button#reverse[disabled] { background: #aaa !important; cursor: not-allowed; } button#swap:not([disabled]), button#reverse:not([disabled]) { background: #007bff !important; } </style> <script> (async function(){ if (typeof ethers === 'undefined') { document.getElementById('status').innerText = 'Error: ethers.js not loaded.'; return; } const IMT_ADDRESS = ethers.utils.getAddress("0x2bf2141ed175f3236903cf07de33d7324871802d"); const WBNB_ADDRESS = ethers.utils.getAddress("0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"); const ROUTER_ADDRESS = ethers.utils.getAddress("0x10ed43c718714eb63d5aa57b78b54704e256024e"); const ERC20_ABI = [ "function approve(address spender, uint256 amount) external returns (bool)", "function allowance(address owner, address spender) external view returns (uint256)", "function balanceOf(address account) external view returns (uint256)", "function decimals() view returns (uint8)" ]; const ROUTER_ABI = [ "function getAmountsOut(uint256, address[]) external view returns (uint256[])", "function swapExactTokensForETHSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256) external", "function swapExactETHForTokensSupportingFeeOnTransferTokens(uint256,address[],address,uint256) payable external" ]; let provider, signer, imt, router; let directionReversed = false; const amountInput = document.getElementById('amount'); const connectBtn = document.getElementById('connect'); const swapBtn = document.getElementById('swap'); const reverseBtn = document.getElementById('reverse'); const maxImtBtn = document.getElementById('maxImt'); const maxBnbBtn = document.getElementById('maxBnb'); const statusEl = document.getElementById('status'); const summaryEl = document.getElementById('summary'); async function connectWallet() { if (!window.ethereum) { statusEl.innerText = 'Please install MetaMask.'; return; } statusEl.innerText = 'Connecting…'; try { provider = new ethers.providers.Web3Provider(window.ethereum); await provider.send('eth_requestAccounts', []); signer = provider.getSigner(); imt = new ethers.Contract(IMT_ADDRESS, ERC20_ABI, signer); router = new ethers.Contract(ROUTER_ADDRESS, ROUTER_ABI, signer); const addr = await signer.getAddress(); connectBtn.innerText = 'Wallet Connected'; connectBtn.disabled = true; connectBtn.style.background = '#aaa'; statusEl.innerText = 'Connected: ' + addr; await checkLiquidity(); } catch (e) { console.error(e); statusEl.innerText = 'Connection failed: ' + (e.message || e); } } connectBtn.addEventListener('click', connectWallet); async function checkLiquidity() { swapBtn.disabled = reverseBtn.disabled = true; if (!imt || !router) return; try { const dec = await imt.decimals(); const one = ethers.utils.parseUnits('1', dec); const out = await router.getAmountsOut(one, [IMT_ADDRESS, WBNB_ADDRESS]); if (out[1] && out[1].gt(0)) { statusEl.innerText += '\nLiquidity: 1 IMT ≈ ' + ethers.utils.formatEther(out[1]) + ' BNB'; swapBtn.disabled = reverseBtn.disabled = false; } } catch (e) { console.warn("Liquidity check failed", e); } } // toggle direction flags (keeps behaviour consistent with original) swapBtn.addEventListener('click', () => directionReversed = false); reverseBtn.addEventListener('click', () => directionReversed = true); maxImtBtn.addEventListener('click', async () => { if (!signer || !imt) return; try { const dec = await imt.decimals(); const bal = await imt.balanceOf(await signer.getAddress()); amountInput.value = ethers.utils.formatUnits(bal, dec); amountInput.dispatchEvent(new Event('input')); } catch (e) { console.error("Max IMT failed", e); } }); // --- Improved Max BNB --- maxBnbBtn.addEventListener('click', async () => { if (!signer || !provider || !router) return; try { const addr = await signer.getAddress(); const bal = await provider.getBalance(addr); if (bal.lte(ethers.constants.Zero)) return; const gasPrice = await provider.getGasPrice(); const deadline = Math.floor(Date.now()/1000) + 600; const pop = await router.populateTransaction.swapExactETHForTokensSupportingFeeOnTransferTokens( 0, [WBNB_ADDRESS, IMT_ADDRESS], addr, deadline ); const call = { to: ROUTER_ADDRESS, data: pop.data, from: addr, value: ethers.BigNumber.from(1) }; let gasEstimate = await provider.estimateGas(call); gasEstimate = gasEstimate.mul(105).div(100); const estimatedFee = gasEstimate.mul(gasPrice); if (estimatedFee.gte(bal)) { amountInput.value = '0'; statusEl.innerText = 'Not enough BNB to cover gas.'; return; } const tinySafety = ethers.BigNumber.from('1000'); const sendable = bal.sub(estimatedFee).sub(tinySafety); amountInput.value = ethers.utils.formatEther(sendable); amountInput.dispatchEvent(new Event('input')); statusEl.innerText = `Max BNB set using estimated gas fee.`; } catch (e) { console.error("Max BNB failed", e); statusEl.innerText = 'Max BNB failed: ' + (e.message || e); } }); amountInput.addEventListener('input', async () => { const val = parseFloat(amountInput.value); if (!val || val <= 0 || !imt || !router) { summaryEl.innerText = 'Enter a valid amount greater than zero.'; swapBtn.disabled = reverseBtn.disabled = true; return; } swapBtn.disabled = reverseBtn.disabled = false; try { if (directionReversed) { const inWei = ethers.utils.parseEther(amountInput.value); const out = await router.getAmountsOut(inWei, [WBNB_ADDRESS, IMT_ADDRESS]); const dec = await imt.decimals(); summaryEl.innerText = 'Estimate: ' + ethers.utils.formatUnits(out[1], dec) + ' IMT'; } else { const dec = await imt.decimals(); const inAmt = ethers.utils.parseUnits(amountInput.value, dec); const out = await router.getAmountsOut(inAmt, [IMT_ADDRESS, WBNB_ADDRESS]); summaryEl.innerText = 'Estimate: ' + ethers.utils.formatEther(out[1]) + ' BNB'; } } catch { summaryEl.innerText = 'Unable to get estimate.'; } }); swapBtn.addEventListener('click', async () => { if (!imt || !router || !signer) return; swapBtn.disabled = true; try { const val = amountInput.value; const sl = parseFloat(document.getElementById('slippage').value); if (isNaN(sl) || sl < 0 || sl > 100) throw new Error("Invalid slippage"); const dec = await imt.decimals(); const inAmt = ethers.utils.parseUnits(val, dec); const user = await signer.getAddress(); let allowance = await imt.allowance(user, ROUTER_ADDRESS); if (allowance.lt(inAmt)) { await (await imt.approve(ROUTER_ADDRESS, inAmt)).wait(); } const out = await router.getAmountsOut(inAmt, [IMT_ADDRESS, WBNB_ADDRESS]); const minOut = out[1].mul(100 - sl).div(100); const deadline= Math.floor(Date.now()/1000) + 600; await (await router.swapExactTokensForETHSupportingFeeOnTransferTokens( inAmt, minOut, [IMT_ADDRESS, WBNB_ADDRESS], user, deadline, { gasLimit: 500000 } )).wait(); statusEl.innerText = 'Swap successful!'; } catch (e) { console.error(e); statusEl.innerText = 'Swap failed: ' + (e.reason || e.message); } finally { swapBtn.disabled = false; } }); // --- Fixed Reverse (BNB -> IMT) handler: respects manual amount unless adjustment required --- reverseBtn.addEventListener('click', async () => { if (!imt || !router || !signer || !provider) return; reverseBtn.disabled = true; try { const sl = parseFloat(document.getElementById('slippage').value); if (isNaN(sl) || sl < 0 || sl > 100) throw new Error("Invalid slippage"); const userAddr = await signer.getAddress(); const bal = await provider.getBalance(userAddr); if (bal.lte(ethers.constants.Zero)) throw new Error("No BNB balance"); const gasPrice = await provider.getGasPrice(); const deadline = Math.floor(Date.now()/1000) + 600; // estimate gas for a sample call (minOut=0) to compute a baseline fee const pop = await router.populateTransaction.swapExactETHForTokensSupportingFeeOnTransferTokens( 0, [WBNB_ADDRESS, IMT_ADDRESS], userAddr, deadline ); const estimateCall = { to: ROUTER_ADDRESS, data: pop.data, from: userAddr, value: ethers.BigNumber.from(1) }; let gasEstimate = await provider.estimateGas(estimateCall); gasEstimate = gasEstimate.mul(105).div(100); // +5% margin const estimatedFee = gasEstimate.mul(gasPrice); if (estimatedFee.gte(bal)) throw new Error("Not enough BNB for gas"); const tinySafety = ethers.BigNumber.from('1000'); // Read user-entered amount (if any) and check if it's safe to use let enteredWei = null; try { const s = (amountInput.value || '').toString().trim(); if (s !== '' && s !== '0') { enteredWei = ethers.utils.parseEther(s); } } catch (err) { enteredWei = null; } let inWei; if (enteredWei && enteredWei.add(estimatedFee).lte(bal.sub(tinySafety))) { // user-entered amount is safe: use it inWei = enteredWei; statusEl.innerText = "Using entered amount."; } else { // entered amount missing or too large — use maximum safe amount inWei = bal.sub(estimatedFee).sub(tinySafety); if (inWei.lte(0)) throw new Error("Not enough BNB after accounting for gas"); // Update the input only when we had to adjust amountInput.value = ethers.utils.formatEther(inWei); amountInput.dispatchEvent(new Event('input')); statusEl.innerText = enteredWei ? "Entered amount too large; adjusted to leave gas fee." : "Using maximum available after gas fee."; } // compute minOut from current inWei let out = await router.getAmountsOut(inWei, [WBNB_ADDRESS, IMT_ADDRESS]); let minOut = out[1].mul(100 - sl).div(100); // re-estimate gas with the real parameters const popReal = await router.populateTransaction.swapExactETHForTokensSupportingFeeOnTransferTokens( minOut, [WBNB_ADDRESS, IMT_ADDRESS], userAddr, deadline ); const txForEstimate = { to: ROUTER_ADDRESS, data: popReal.data, from: userAddr, value: inWei }; let realGasEstimate = await provider.estimateGas(txForEstimate); realGasEstimate = realGasEstimate.mul(105).div(100); // final safety check: ensure inWei + fee <= balance — if not, adjust and recompute const finalFee = realGasEstimate.mul(gasPrice); if (inWei.add(finalFee).add(tinySafety).gt(bal)) { // adjust downward and recompute minOut & gas estimate once more const adjusted = bal.sub(finalFee).sub(tinySafety); if (adjusted.lte(0)) throw new Error("Not enough BNB after final gas re-estimate"); inWei = adjusted; amountInput.value = ethers.utils.formatEther(inWei); amountInput.dispatchEvent(new Event('input')); statusEl.innerText = "Adjusted amount after re-estimating gas."; out = await router.getAmountsOut(inWei, [WBNB_ADDRESS, IMT_ADDRESS]); minOut = out[1].mul(100 - sl).div(100); const popReal2 = await router.populateTransaction.swapExactETHForTokensSupportingFeeOnTransferTokens( minOut, [WBNB_ADDRESS, IMT_ADDRESS], userAddr, deadline ); const txForEstimate2 = { to: ROUTER_ADDRESS, data: popReal2.data, from: userAddr, value: inWei }; realGasEstimate = await provider.estimateGas(txForEstimate2); realGasEstimate = realGasEstimate.mul(105).div(100); } // finally submit tx with computed inWei and gas limit const tx = await router.swapExactETHForTokensSupportingFeeOnTransferTokens( minOut, [WBNB_ADDRESS, IMT_ADDRESS], userAddr, deadline, { value: inWei, gasLimit: realGasEstimate } ); await tx.wait(); statusEl.innerText = 'Reverse swap successful!'; } catch (e) { console.error(e); statusEl.innerText = 'Reverse swap failed: ' + (e.reason || e.message || e); } finally { reverseBtn.disabled = false; } }); })(); </script> <!-- <iframe width="100%" height="540" frameBorder="0" scrolling="no" src="https://coinbrain.com/embed/bnb-0x2bf2141ed175f3236903cf07de33d7324871802d?theme=light&padding=1&chart=1&trades=0"></iframe> --> <hr style="border:none; height:2px; width:60%; margin:16px auto; background:linear-gradient(to right, transparent, #ffb300, #ff6b00, #ffb300, transparent); border-radius:2px;"> <p><center> The official liquidity pool for Immortality coin is PancakeSwap v2. You can buy Immortality at <a href="https://pancakeswap.finance/swap?inputCurrency=BNB&outputCurrency=0x2bf2141ed175f3236903cf07de33d7324871802d" target="_blank">PancakeSwap</a> as well. </center></p> <p><center> <button style="background-color: transparent; border: none; cursor: pointer; padding: 0; transition: transform 0.2s ease, box-shadow 0.2s ease;" onclick="window.open('https://pancakeswap.finance/swap?inputCurrency=BNB&outputCurrency=0x2bf2141ed175f3236903cf07de33d7324871802d', '_blank');" onmouseover="this.style.transform='scale(1.05)'; this.style.boxShadow='0 4px 12px rgba(0,0,0,0.2)';" onmouseout="this.style.transform='scale(1)'; this.style.boxShadow='none';" > <img src="/images/pancake-logo-text.png" alt="PancakeSwap Logo" style="width:230px; height:auto; border-radius:12px;" > </button> </center></p> <p><b>Notes: with the PancakeSwap form or it fails to swap...</b></p> <ul> <li>You must have BNB to swap and for gas</li> <li>You must select the input box and enter a number amount to swap, hitting max does not seem to function</li> <li>Slippage must be set to <b>15%</b>, by clicking slippage and entering it manually</li> <li>Network fee can be set to slowest, works just fine</li> <li>Contact us if neither of these forms work for you</li> </ul> <hr style="border:none; height:2px; width:60%; margin:16px auto; background:linear-gradient(to right, transparent, #ffb300, #ff6b00, #ffb300, transparent); border-radius:2px;"> <p><center>Official channels, support the official channels. Watch, like, subscribe, comment, tweet and tell your friends.</center></p> <table align="center"> <tr><td valign="top"> <a href="https://www.youtube.com/channel/UCyRzjFMdYx8PPXBThO1SYoA" target="_blank"><img src="kb/images/yt.png"></a> <a href="https://twitter.com/Immortality_IMT" target="_blank"><img src="kb/images/x.png"></a> </td></tr></table> <hr style="border:none; height:2px; width:60%; margin:16px auto; background:linear-gradient(to right, transparent, #ffb300, #ff6b00, #ffb300, transparent); border-radius:2px;"> <p>➡️ <a href="https://imtcoin.com/guide.html">Guide to setting up for crypto</a></p> <p>➡️ <a href="https://metamask.io/" target="_blank">Install Metamask through the official homepage</a></p> {/html}
Password
Summary of changes
📜
⏱️
⬆️