Telegram Mini App Development with Crypto Functionality
Telegram Mini App is WebView inside Telegram, opens via bot button or link tg://resolve?domain=BotName&appname=appname. For crypto apps interesting niche: ~900M Telegram users, built-in messenger, TON ecosystem with native wallet. But WebView isn't native app, gap felt every step of blockchain integration.
TON Connect: Wallet Authorization
For TON ecosystem — TON Connect 2.0. User connects Tonkeeper, MyTonWallet or Telegram's built-in wallet (W5). Mini App gets wallet address and can request transaction signatures.
import TonConnect from '@tonconnect/sdk';
const connector = new TonConnect({
manifestUrl: 'https://your-app.com/tonconnect-manifest.json'
});
// Wallet connection
async function connectWallet() {
const walletsList = await connector.getWallets();
// For Telegram Mini App use built-in wallet
const telegramWallet = walletsList.find(w => w.appName === 'telegram-wallet');
if (telegramWallet) {
// Opens built-in Telegram wallet
connector.connect({ jsBridgeKey: telegramWallet.jsBridgeKey });
} else {
// QR or deep link for external wallets
const universalLink = connector.connect({ universalLink: walletsList[0].universalUrl });
window.Telegram.WebApp.openLink(universalLink);
}
}
connector.onStatusChange(wallet => {
if (wallet) {
console.log('Connected:', wallet.account.address);
}
});
For EVM networks (Ethereum, Polygon, BSC) — WalletConnect, though in Telegram Mini App context integration harder: QR inside WebView, Deep Link leads out of Telegram to MetaMask and back. Works but UX worse than native app.
Telegram Wallet: Built-in Wallet
Since 2023 Telegram has built-in wallet (@wallet bot) supporting TON and USDT (TON). In Mini App available via window.Telegram.WebApp.openInvoice() for crypto payments without external wallets. Simplest way to accept crypto in Mini App — user pays straight from Telegram without installing extra apps.
// Create invoice for Stars or TON payment
const tg = window.Telegram.WebApp;
async function createCryptoInvoice(amount, description) {
// On server create invoice via Telegram Payments API or @wallet API
const invoiceLink = await fetch('/api/create-invoice', {
method: 'POST',
body: JSON.stringify({ amount, description, currency: 'XTR' }) // XTR = Telegram Stars
}).then(r => r.json()).then(d => d.link);
tg.openInvoice(invoiceLink, (status) => {
if (status === 'paid') {
// Successful payment
handlePaymentSuccess();
}
});
}
Telegram Stars (XTR) — Telegram internal currency since August 2024. Accepted for digital goods and services inside Mini Apps. Converts to money via Telegram Fragment.
DeFi in Mini App: WebView Limitations
Main limitation — Mini App runs in WebView inside Telegram, not browser. window.ethereum not injected automatically. MetaMask doesn't inject provider into Telegram WebView.
Solutions:
- TON-only functionality via TON Connect — works natively
- Server-side Web3 logic — client doesn't work with blockchain directly, all on-chain ops via your backend
- Iframe with Metamask Snaps — experimental, not for production
Practically for EVM DeFi in Telegram Mini App best architecture — custodial wallets or MPC (Multi-Party Computation) via Privy or Dynamic. User authorizes via Telegram initData, gets wallet from service, all transactions signed server-side.
initData Verification
Any Mini App request to your backend must be verified via Telegram initData:
import hmac
import hashlib
from urllib.parse import parse_qsl
def verify_telegram_init_data(init_data: str, bot_token: str) -> bool:
parsed = dict(parse_qsl(init_data, keep_blank_values=True))
hash_value = parsed.pop('hash', '')
data_check = '\n'.join(f'{k}={v}' for k, v in sorted(parsed.items()))
secret_key = hmac.new(b'WebAppData', bot_token.encode(), hashlib.sha256).digest()
expected = hmac.new(secret_key, data_check.encode(), hashlib.sha256).hexdigest()
return hmac.compare_digest(hash_value, expected)
Without this check anyone can send POST with arbitrary user_id and get someone else's crypto balance.
Notifications via Bot
One of main Telegram Mini App advantages — instant notifications via bot without APNs/FCM. Transaction confirmed — bot sends message. Suspicious activity — push to Telegram. Implemented via bot.sendMessage(chatId, text) from python-telegram-bot or grammy (Node.js).
Tech Stack
Frontend Mini App: React or Vue + Vite, CSS via Tailwind or native CSS accounting for Telegram color theme (tg.themeParams). Dark theme supported via tg.colorScheme. Mobile viewport adaptation — tg.viewportHeight, tg.viewportStableHeight.
Backend: any language. Node.js with grammy or telegraf, Python with aiogram — popular choices for Telegram bots.
Timeline
3–5 weeks for Mini App with TON Connect, crypto payment, DeFi functionality via server layer and notifications via bot. Cost calculated individually after requirements analysis.







