Key idea: transform and gradually modernize
-
Take a FunC project and apply the converter
=> get a contract that “looks and feels” like FunC. -
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.
Step 2: gradually refactor
- use the modern
onInternalMessage, see handling messages - extract a
Storagestruct, 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.