Skip to main content
The converter may look like magic: any FunC project can be immediately transformed into Tolk with a single command:
npx @ton/convert-func-to-tolk contracts
GitHub repo.

Key idea: transform and gradually modernize

  1. Take a FunC project and apply the converter
    => get a contract that “looks and feels” like FunC.
  2. Refactor it with modern features, step by step, keeping green tests
    => resulting in an idiomatic Tolk project for further development.

Step 1: convert and make it compile

This is a syntax-level converter that assists in migrating contracts to Tolk. It rewrites FunC code with 1:1 semantics, — emitting a Tolk version of a contract that remains very close to the FunC original. Example input: jetton-minter.fc.
Example output: jetton-minter.tolk.
The converted contract won’t use modern Tolk features like structures, auto-serialization, or clean message composition. But after some manual fixes, it compiles, runs, and passes tests.
A contract does not compile after conversion?Please, refer to a GitHub repo — it contains common problems and provides ways to fix them.
From there, the codebase can be gradually modernized — step by step, while keeping it functional at every stage.

Step 2: gradually refactor

  • use the modern onInternalMessage, see handling messages
  • extract a Storage struct, with toCell/fromCell like in examples
  • refactor incoming messages into structs with 32-bit opcodes — incrementally, one message at a time
  • define a union of possible messages and lazy match it
  • extract outgoing messages into structs and send them
Key idea: keep the tests running at every stageThis is what makes the approach safe — confidently refactor and modernize the codebase without breaking anything.

Where to find examples?

Examples: Tolk vs FunC benchmarks. This repository contains several contracts migrated from FunC — preserving original logic and passing the same tests. Explore the Git history to see how each contract was gradually rewritten, step by step.