Tolk language overview
Tolk is a next-generation language for developing smart contracts on TON. It replaces FunC with an expressive syntax, a robust type system, and built-in serialization—while generating highly optimized assembly code.
This page introduces Tolk’s core features, explains how it compares to FunC, and outlines how to get started with the language— whether you're migrating from FunC or writing smart contracts from scratch.
Why choose Tolk
- Clean, expressive syntax inspired by TypeScript and Rust.
- Built-in primitives for TON, including auto-serialized structs, pattern matching, and first-class message handling.
- Strong static type system with null safety, type aliases, union types, and generics for safer, clearer code.
- Gas-efficient by design — contracts can cost up to 50% less than FunC equivalents thanks to compiler optimizations and lazy functionality.
- Low-level control is available when needed, with direct access to the TVM stack and instructions.
Getting started with Tolk
If you're starting with Tolk, follow these steps:
- Explore the TON smart contract documentation to learn the fundamentals.
- Set up the first Tolk counter project using
npm create ton@latest
. - Follow the step-by-step guide to build a counter-contract.
- Read the Tolk language guide for a high-level overview of the language.
- Continue exploring the documentation. When you come across FunC or Tact code, compare it to its Tolk equivalent — you'll often find it's cleaner and more declarative.
The TON documentation will continue evolving to support Tolk as the primary smart contract language.
How to migrate from FunC
If you’ve written contracts in FunC, migrating to Tolk is straightforward — and often results in simpler, more maintainable code.
- Try building a basic contract in Tolk — for example, a counter using
npm create ton@latest
. You’ll quickly notice the shift from stack logic to expressive constructs with structured types, unions, pattern matching,toCell()
, and more. - Explore the Tolk vs FunC benchmarks. These are real-world contracts (Jetton, NFT, Wallet, etc.) migrated from FunC — same logic, but expressed in a cleaner, more expressive style.
- Read Tolk vs FunC: in short for a quick comparison of syntax and concepts.
- Use the FunC-to-Tolk converter to migrate existing codebases incrementally.
Example of a basic Tolk smart contract:
import "utils"
struct Storage {
counter: int32
}
fun Storage.load() {
return Storage.fromCell(contract.getData());
}
fun onInternalMessage(in: InMessage) {
// ...
}
get fun currentCounter(): int {
val storage = lazy Storage.load();
return storage.counter;
}
Equivalent implementation in FunC
#include "utils.fc";
global int ctx_counter;
int load_data() impure {
slice cs = get_data().begin_parse();
ctx_counter = cs~load_uint(32);
}
() recv_internal(int msg_value, cell msg_full, slice msg_body) impure {
slice cs = msg_full.begin_parse();
int flags = cs.load_uint(4);
if (flags & 1) {
return ();
}
...
}
int currentCounter() method_id {
load_data(); ;; fills global variables
return ctx_counter;
}
Convert FunC to Tolk
Compare Tolk and FunC
Tooling around Tolk
A set of tools is available to support development with Tolk — including IDE support, language services, and migration utilities.
Tool | Description |
---|---|
JetBrains IDE plugin | adds support for Tolk, FunC, Fift, and TL-B |
VS Code extension | provides Tolk support and language features |
Language server | works with any LSP-compatible editor |
FunC-to-Tolk converter | migrates entire projects with a single npx command |
tolk-js | WASM wrapper for the Tolk compiler is integrated into blueprint |
The Tolk compiler itself lives in the ton-blockchain
repository.
Is Tolk production-ready?
All contracts in the Tolk vs FunC benchmarks pass the same test suites as their FunC counterparts — with identical logic and behavior.
The compiler is new, so some edge cases may still occur. However, Tolk already serves as a production-ready replacement for FunC, suitable for real-world use.
Regardless of the language, well-tested code is the key to building reliable smart contracts.
Issues and contacts
If you encounter an issue, please connect with the developer society on TON Dev chats or create a GitHub issue.