Skip to main content
FunC contracts depend on the stdlib.fc file, which contains asm functions closely tied to TVM instructions. Tolk provides a standard library that gradually evolved from FunC’s stdlib. Therefore, many functions from stdlib.fc can be mapped to Tolk. But since Tolk is much more flexible as a language, most of the functions turned into methods.

Functions vs methods

Tolk supports declaring methods (see syntax) — even for primitives. That’s why lots of FunC’s global-scope functions are now methods: cell.hash(), tuple.size(), etc.

List of renamed and removed functions

For load_xxx, store_xxx, and skip_xxx — use automatic serialization. Methods slice.loadXXX, builder.storeXXX, and slice.skipXXX still exist for manual cell parsing, but their use is not recommended. For idict_xxx, udict_xxx, and dict_xxx — use native maps. Old-fashioned dictionaries still exist in a file @stdlib/tvm-dicts, but their use is not recommended. Other functions are listed below.
  • some were renamed to clean, descriptive names
  • some became methods and are called via dot
  • some were removed, because they are rarely used in practice
  • some were removed, because they can be expressed syntactically
    • pair(a, b) => [a, b]
    • fourth(t) => dot-access t.3
    • etc.
Lisp-style lists require an explicit import (an IDE inserts it automatically):

Mutating functions

In FunC, x~method mutates, whereas x.method returns a copy. In Tolk, methods are called via dot. A method may (or may not) mutate the object.
  • If cs~load_uint(…) was used, cs.loadUint(…) behaves identically.
  • If cs.load_uint(…) was used to obtain a copy, a different approach is required. Read about mutability.

Added functions

Tolk provides much more capabilities out of the box. See Tolk stdlib. The standard library is split into multiple files. Functions from common.tolk are always available (most of FunC’s analogues are, actually), but those from other files require an explicit import.