Skip to main content
The converter allows any FunC project to be transformed into Tolk with a single command:
npx @ton/convert-func-to-tolk contracts
This is a syntax-level converter that assists in migrating contracts to Tolk. It rewrites FunC code with one-to-one semantics and emits a Tolk version of the contract that remains close to the FunC original. Example input: jetton-minter.fc.
Example output: jetton-minter.tolk.
The converted contract does not use modern Tolk features such as structures, auto-serialization, or clean message composition. After some manual fixes, it compiles, runs, and passes tests. If a contract does not compile after conversion, refer to the GitHub repository. It contains common issues and provides ways to fix them.

Refactoring

  • Use the modern onInternalMessage.
  • Extract a Storage struct with toCell and fromCell.
  • Refactor incoming messages into structs with 32-bit opcodes – incrementally, one message at a time.
  • Define a union of possible messages and match it using lazy.
  • Extract outgoing messages into structs and send them.
Maintain tests at every stageKeeping tests passing throughout the refactoring process ensures safe, incremental modernization without breaking functionality.

Examples

Tolk vs FunC benchmarks repository contains contracts migrated from FunC, preserving the original logic and passing the same tests. To see how each contract was rewritten step by step, use the Git history.