Telegram Mini App Slot Development
Players complain about unfair slots? We guarantee fairness with verifiable randomness on TON and public contracts. Needs: randomness, wallet integration, fast transactions. TMA is a WebApp inside the messenger with 900M+ users. TON blockchain is natively integrated with Telegram via @wallet bot and TON Connect protocol. We break down the full stack: from TMA API to smart contract on TON. We have years of experience in blockchain development and are ready to share our know-how.
Why Tact is Better than FunC for TON Slots
Tact is a modern language for TON smart contracts, similar to TypeScript. It reduces errors by 40% compared to FunC due to strict typing and built-in checks. FunC requires manual memory management and is prone to bugs like incorrect type conversions. For slots, where every transaction is precious, contract reliability is critical.
How Telegram Mini App Handles Transactions
TMA is a regular web app (React/Vue) opening in Telegram’s built-in browser. Interaction with Telegram via the window.Telegram.WebApp object:
import WebApp from "@twa-dev/sdk";
WebApp.ready();
WebApp.expand();
const user = WebApp.initDataUnsafe.user;
const isValid = await verifyTelegramData(WebApp.initData, BOT_TOKEN);
WebApp.HapticFeedback.impactOccurred("medium");
WebApp.MainButton.setText("SPIN");
WebApp.MainButton.show();
WebApp.MainButton.onClick(() => spinReels());
Verify initData on Backend
import crypto from "crypto";
function verifyTelegramWebAppData(initData: string, botToken: string): boolean {
const urlParams = new URLSearchParams(initData);
const hash = urlParams.get("hash");
urlParams.delete("hash");
const dataCheckString = Array.from(urlParams.entries())
.sort(([a], [b]) => a.localeCompare(b))
.map(([key, value]) => `${key}=${value}`)
.join("\n");
const secretKey = crypto
.createHmac("sha256", "WebAppData")
.update(botToken)
.digest();
const computedHash = crypto
.createHmac("sha256", secretKey)
.update(dataCheckString)
.digest("hex");
return computedHash === hash;
}
TON Smart Contract for Slots
Provably Fair Randomness with Server Signature
Randomness is generated on the server and signed with a private key. The contract verifies the signature before payout. Additionally, you can integrate Chainlink VRF for decentralized verification. But for TMA slots, server signature is sufficient provided the server is trusted. Example slot contract in Tact:
import "@stdlib/deploy";
struct SpinResult {
reel1: Int as uint8;
reel2: Int as uint8;
reel3: Int as uint8;
payout: Int as coins;
}
contract SlotMachine with Deployable {
owner: Address;
houseBalance: Int as coins = 0;
const MIN_BET: Int = ton("0.1");
const MAX_BET: Int = ton("10");
serverPublicKey: Int as uint256;
init(owner: Address, serverPublicKey: Int) {
self.owner = owner;
self.serverPublicKey = serverPublicKey;
}
receive("spin") {
let ctx: Context = context();
require(ctx.value >= self.MIN_BET, "Bet too small");
require(ctx.value <= self.MAX_BET, "Bet too large");
emit(SpinRequested{player: ctx.sender, betAmount: ctx.value, nonce: now()}.toCell());
self.houseBalance += ctx.value;
}
receive(msg: ClaimWin) {
let hash: Int = beginCell()
.storeAddress(msg.player)
.storeCoins(msg.betAmount)
.storeUint(msg.nonce, 64)
.storeUint(msg.reel1, 8)
.storeUint(msg.reel2, 8)
.storeUint(msg.reel3, 8)
.endCell()
.hash();
require(checkSignature(hash, msg.signature, self.serverPublicKey), "Invalid signature");
let payout: Int = self.calculatePayout(msg.reel1, msg.reel2, msg.reel3, msg.betAmount);
if (payout > 0) {
require(self.houseBalance >= payout, "Insufficient house balance");
self.houseBalance -= payout;
send(SendParameters{to: msg.player, value: payout, mode: SendIgnoreErrors});
}
}
fun calculatePayout(r1: Int, r2: Int, r3: Int, bet: Int): Int {
if (r1 == 7 && r2 == 7 && r3 == 7) { return bet * 100; }
if (r1 == r2 && r2 == r3) { return bet * 10; }
if (r1 == r2 || r2 == r3 || r1 == r3) { return bet * 2; }
if (r1 == 6 && r2 == 6) { return bet * 3; }
return 0;
}
receive("deposit") {
self.houseBalance += context().value;
}
get fun balance(): Int { return self.houseBalance; }
}
TON Connect: Connect Wallet
import TonConnect from "@tonconnect/sdk";
const connector = new TonConnect({
manifestUrl: "https://yourapp.com/tonconnect-manifest.json",
});
const walletsList = await connector.getWallets();
connector.connect({ universalLink: walletsList[0].universalLink, bridgeUrl: ... });
connector.onStatusChange((wallet) => {
if (wallet) {
console.log("Connected:", wallet.account.address);
initGame(wallet.account.address);
}
});
async function placeBet(amount: number) {
await connector.sendTransaction({
validUntil: Math.floor(Date.now() / 1000) + 300,
messages: [{
address: SLOT_CONTRACT_ADDRESS,
amount: String(amount * 1e9),
payload: "spin",
}],
});
}
Game Loop and Animation
Slots are all about reel animation. We use CSS/Canvas animation or Pixi.js:
- Player presses "Spin" → TON transaction is sent.
- While transaction is pending → reels spin in waiting animation.
- Game server detects the transaction → generates random result → signs it → calls
ClaimWinon the contract. - Frontend receives the event via TON Center API or ton-sdk → reels stop on final symbols.
- If win — haptic feedback + coin effect.
async function watchSlotEvents(contractAddress: string) {
const client = new TonClient({ endpoint: "https://toncenter.com/api/v2/jsonRPC" });
setInterval(async () => {
const transactions = await client.getTransactions(Address.parse(contractAddress), { limit: 10 });
for (const tx of transactions) {
if (tx.inMessage?.body) {
const result = parseSpinResult(tx.inMessage.body);
if (result && result.player === currentPlayerAddress) {
animateReels(result.reel1, result.reel2, result.reel3);
}
}
}
}, 2000);
}
Monetization and the TON Ecosystem
TON provides several advantages for TMA slots:
- @wallet integration — Telegram users often already have a TON wallet via the built-in @wallet.
- Fees — TON transactions cost ~$0.003–0.01, which is 10x cheaper than Ethereum L2. Savings per bet can reach $0.05.
- TON Stars — Telegram internal currency (for non-crypto users).
- Viral mechanics — native sharing of results to chats via
WebApp.openTelegramLink.
| Parameter | TON | Ethereum (L2) |
|---|---|---|
| Transaction speed | ~3-5 sec | ~2-10 sec (Arbitrum) |
| Average fee | $0.003 | $0.01-0.05 |
| Telegram integration | Native | Via Web3 |
We guarantee stable economics with RTP 95–97%. House edge 3–5% ensures sustainable economics at sufficient game volume.
What’s Included in TMA Slot Development
- Architecture documentation and server-side API docs.
- Smart contract source code in Tact (open access).
- Contract deployment to testnet and mainnet.
- Web application in React/Next.js with reel animation.
- Integration of TON Connect and @wallet for deposits/bets.
- Security testing (logic audit).
- Administration instructions.
Development Process for TMA Slots
We work in phases to minimize risks and meet deadlines:
- Analysis — agree on mechanics, RTP, symbol design.
- Design — smart contract architecture, TMA schemas.
- Implementation — write contract in Tact, frontend in React, server side.
- Testing — unit tests for scenarios (win, lose, bonus), fuzzing on Tenderly.
- Deployment — deploy testnet, then mainnet with multisig.
| Phase | Duration |
|---|---|
| Analysis | 1-2 days |
| Design | 2-3 days |
| Implementation | 2-3 weeks |
| Testing | 1 week |
| Deployment | 2-3 days |
What Risks Do We Eliminate?
- Reentrancy: TON is asynchronous, but we use a check-after-effect pattern in the contract.
- RNG manipulation: server signature + public key in the contract excludes tampering.
- Balance overflow: minimum and maximum bets, houseBalance check before payout.
We guarantee security through proven patterns and code audit.
Contact us to discuss your idea and get a detailed estimate. Order TON slot development — we’ll launch the project in 4 weeks.







