How to build smart contracts and Mini Apps with TON
Telegram's rules, Tolk and Acton, initData and ton_proof validation, and how to accept a jetton payment without fake notifications.

Since January 21, 2025, Telegram's terms for bot developers only allow a Mini App to integrate blockchain features if it uses the TON network exclusively to create and distribute assets and only connects to wallets linked through TON Connect, according to its blockchain guidelines. A Mini App is a web application that opens inside Telegram, with no separate installation, and receives from the messaging client the data of the user who opens it. Building one means working with three systems at once: the web interface inside Telegram, your own server and TON smart contracts, which communicate through messages rather than synchronous calls.
That split decides where each check happens. A payment in a TON Mini App is reliable when the server validates the Telegram session, links that session to the signing wallet and the contract accepts notifications only from its own jetton wallet. None of the three checks replaces the others, and the third has a property that changes contract design: a jetton payment notification does not bounce, so a contract that rejects it does not return the tokens. The case of a shop that takes payment in a jetton, further down, shows the consequences.
What Telegram requires and which tools to build with in November 2026
Telegram's guidelines set two deadlines: February 1, 2025 to comply with the wallet connection clauses and February 21, 2025 for Mini Apps running on other networks to migrate to TON. Since then, issuing or distributing tokens or NFTs from other networks inside a Mini App is not allowed, and other wallet connection protocols are only accepted for bridging assets to TON. Bots without a Mini App are exempt. A second rule affects the business model: Telegram requires digital goods and services to be paid for exclusively in Telegram Stars, to comply with App Store and Google Play guidelines, while sales of physical goods or services can use other currencies and providers. A payment in TON or in a jetton therefore fits the sale of physical goods, not in-app digital content.
The language and tooling have changed too. TON's documentation presents Tolk as the recommended language for contracts, an evolution of FunC, which is now listed with Fift among the legacy languages. Its changelog reaches version 1.5, and the JavaScript compiler package (@ton/tolk-js) published that version on October 15, 2026. To build, test and deploy, the contract development documentation recommends Acton, whose version 1.2.1 was released on October 5, 2026, and keeps Blueprint as a legacy environment still supported for existing projects; the web IDE at ide.ton.org has been retired. Versions are pinned in the repository from the first commit, because compiler behavior changes between them: version 1.2, for example, made address an internal-only type and added information about bounced messages.
Three identities the server has to link
When a user opens the Mini App, Telegram hands the page two versions of their data. initDataUnsafe is an already parsed object that the Mini Apps documentation says should not be trusted; initData is the raw string, which the server can verify. Verification is an HMAC-SHA-256: the secret key is the HMAC of the bot token with the string "WebAppData" as the key, and signing all received fields with it, sorted alphabetically in key=value format, must match the hash field. The auth_date field also lets the server reject stale sessions. A third party that does not know the bot token can instead check, since Bot API 8.0 in November 2024, the Ed25519 signature in the signature field against the public key Telegram publishes.
That validation proves who the Telegram user is, not which wallet they control. Connecting a wallet through TON Connect does not prove it to the server either, since the server only receives an address from the browser. To link both identities, TON Connect offers ton_proof: the server generates an unpredictable value for each login attempt and the wallet signs it together with the application's domain and a timestamp. The server rebuilds the message, checks that the domain is its own, that the timestamp falls within a short window (the documentation suggests up to ten minutes) and that the value has not been used before, and verifies the signature with the public key it reads from the wallet's walletStateInit. Only after both checks can it record that a specific Telegram user operates a specific wallet.
The third identity is the one the contract sees: the address that sends each message. The contract knows nothing about Telegram or the server session; it decides based on the sender, the attached value and the message content. That is why the identifier linking a payment to an order has to travel inside the message itself, and why, when payment arrives in jettons, the security of the payment depends on which sender the contract accepts.
How a jetton payment travels to the contract
A jetton is a fungible TON token defined by the TEP-74 standard, and it does not work like an ERC-20. No single contract holds every balance: each holder has their own jetton wallet, a contract holding their balance of that jetton whose address the token's master contract can derive from the holder's address. According to the jetton payments guide, to pay, the buyer does not send a message to the seller but to their own jetton wallet: a transfer with the amount, the recipient, an address to return leftover TON and two fields that matter here, forward_ton_amount and forward_payload. Their jetton wallet debits the balance and sends an internal_transfer to the recipient's jetton wallet, which credits it.
The recipient only finds out if it receives a third message. The TEP-74 standard states that, if forward_ton_amount is greater than zero, the recipient's jetton wallet sends its owner a transfer_notification (opcode 0x7362d09c) with the amount, the original sender and the forward_payload, and that if it equals zero the notification should not be sent. Leftover TON goes back to the given address in an excesses message. In the reference jetton wallet, the notification is also sent as a non-bounceable message, because the recipient could be an account with no deployed contract: if the receiving contract fails while processing it, nothing returns to the jetton wallet and the tokens stay in the recipient's balance.
Hypothetical case: a Telegram shop that takes payment in a jetton
Consider a hypothetical clothing brand that opens a shop as a Mini App and takes payment for its orders, which are physical garments, in a dollar jetton. The server validates initData in every session, links each customer's wallet with ton_proof and creates an order with an identifier. At checkout, the Mini App asks the customer's wallet, through TON Connect, to sign a transfer addressed to the customer's own jetton wallet, with the shop contract as recipient, the order identifier in forward_payload and an amount of TON in forward_ton_amount so that the notification arrives. The shop contract receives the transfer_notification, reads the identifier and marks the order as paid, and the server follows those messages to prepare shipping.
The first version of the contract accepts any transfer_notification with a valid identifier. Anyone can send a message with that opcode, and the payments guide warns that anyone can deploy fake jetton wallets with arbitrary balances: an attacker who deploys one imitating the dollar jetton can notify the shop of a payment that never happened and walk away with the garment. The fix is to compare the sender of each notification with the jetton wallet that belongs to the shop contract under the accepted jetton's master. That address is unknown at deployment, because it depends on the contract's own address. The on-chain jetton processing documentation proposes three routes: request it from the master with the TEP-89 ProvideWalletAddress message and store the reply, set it with an admin message after computing it off-chain, or compute it in the contract by emulating the master's get_wallet_address method with the RUNVM instruction.
The second failure shows up in the interface. If the Mini App builds the transfer with forward_ton_amount set to zero, the jetton changes hands but the contract receives no notification: the customer sees the payment completed in their wallet while the order stays pending. The payments guide asks services to set forward_ton_amount above zero, and the server also needs a reconciliation path for payments that arrive without a notification, such as those the customer sends from their wallet outside the Mini App, by reading the transactions of the shop's jetton wallet.
The third comes with inventory. If a garment sells out between order creation and payment, the intuitive move is for the contract to reject the notification. Because the notification does not bounce, that rejection returns nothing: the tokens are already in the shop's jetton wallet and the payment goes unrecorded. The contract has to accept every authentic notification, record the payment even when it cannot fulfil it and offer a refund, which means sending its jetton wallet a transfer back to the original buyer, whose address arrives in the notification itself. The same applies to an unknown or repeated order identifier: it is recorded and refunded, not rejected.
What to test before deploying to mainnet
Testing a project like this combines the contract, tested with Acton's test runner (or Blueprint's sandbox in a legacy project), and the full flow on the TON testnet. The case yields these minimum checks:
- A notification sent from a fake jetton wallet, which the contract ignores without changing the state of any order.
- A payment with forward_ton_amount set to zero, which the server detects through the reconciliation path.
- A payment for a sold-out order, another with an unknown identifier and another repeated, each with its refund.
- A session with tampered initData or a stale auth_date, and a ton_proof with a reused value or a different domain.
- A payment the customer signs and abandons before confirmation, to check what they see when they reopen the Mini App.
Each test has its expected result written down, and the suite runs again whenever the Tolk or Acton version changes and whenever the shop accepts a new jetton, because the jetton wallet the contract must recognize is different for each master.
In a TON Mini App, Telegram brings distribution and payment reliability depends on the contract and server
The Telegram integration offers something no other network can inside that application: the user opens the shop from a chat, identifies without signing up and connects a wallet without leaving Telegram. That advantage comes with two conditions. It depends on Telegram's terms, which in 2025 gave Mini Apps on other networks a month to migrate to TON and may change again, so the project takes on a platform dependency comparable to a mobile app's dependency on its store. And opening the app inside Telegram does not guarantee users: distribution is still the product's job.
On the technical side, TON requires thinking of each payment as a sequence of messages between contracts that execute separately, a shift that a team coming from EVM, where a transfer and its effect happen in the same transaction, has to absorb before writing the first line. The case shows it: the three failures are not in Tolk's syntax but in the model, since they consist of accepting a sender without checking it, forgetting that the notification is optional and assuming that a rejection returns the funds. The TON page summarizes the network and its standards, the guide to TON development companies compares providers, and at Metlabs we build smart contracts and Mini Apps covering that full flow, from contract to server.
- Telegram: Blockchain Guidelines for Mini Apps
- Telegram: Payments in Telegram Stars
- Telegram: Mini Apps (validating initData)
- TON Docs: Tolk overview
- TON Docs: Tolk changelog
- TON Docs: Contract development overview
- Acton releases (GitHub)
- TON Docs: TON Connect ton_proof
- TEP-74: Jettons standard
- TON Docs: Jettons payments processing
- TON Docs: On-chain jetton processing
- Reference jetton wallet (ton-blockchain/jetton-contract)
Got a blockchain project in mind?
From idea to product, strategy and technology must move forward together.







