Skip to main content
Tolk provides a standard library that evolved from FunC’s standard library. Therefore, many functions from stdlib.fc can be mapped to Tolk, and most of these functions were converted into methods.

Functions vs methods

Tolk supports declaring methods, including primitives. Consequently, many FunC global-scope functions are now methods, e.g., cell.hash(), tuple.size(), etc.
@pure
fun cell.hash(self): uint256
    asm "HASHCU"
In FunC, x.f() works equally to f(x). For instance, someTuple.tuple_size() and tuple_size(someTuple). In Tolk, someTuple.size() is the only valid notation.

Renamed and removed functions

For load_xxx, store_xxx, and skip_xxx, use automatic serialization. Methods slice.loadXXX, builder.storeXXX, and slice.skipXXX are available for manual cell parsing, but their use is not recommended. For idict_xxx, udict_xxx, and dict_xxx, use native maps. Dictionaries remain available in the file @stdlib/tvm-dicts, but their is not recommended. Other functions:
FunC nameTolk name
empty_tuplecreateEmptyTuple
t~tpush(v)t.push(v)
first(t) or t.first()t.first()
at(t,i) or t.at(i)t.get(i) or dot-access t.{i}
touch(v)v.stackMoveToTop()
impure_touch(deleted)
single(deleted)
unsingle(deleted)
pair(deleted)
unpair(deleted)
triple(deleted)
untriple(deleted)
tuple4(deleted)
untuple4(deleted)
second(deleted)
third(deleted)
fourth(deleted)
pair_first(deleted)
pair_second(deleted)
triple_first(deleted)
triple_second(deleted)
triple_third(deleted)
minmaxminMax
nowblockchain.now
my_addresscontract.getAddress
get_balance + pair_firstcontract.getOriginalBalance
cur_ltblockchain.logicalTime
block_ltblockchain.currentBlockLogicalTime
cell_hash(c)c.hash()
slice_hash(s)s.hash()
string_hash(s)s.bitsHash()
check_signatureisSignatureValid
check_data_signatureisSliceSignatureValid
compute_data_size(c)c.calculateSizeStrict()
slice_compute_data_size(s)s.calculateSizeStrict()
compute_data_size?(c)c.calculateSize()
slice_compute_data_size?(s)s.calculateSize()
~dumpdebug.print
~strdumpdebug.printString
dump_stackdebug.dumpStack
get_datacontract.getData
set_datacontract.setData
get_c3getTvmRegisterC3
set_c3setTvmRegisterC3
blesstransformSliceToContinuation
accept_messageacceptExternalMessage
set_gas_limitsetGasLimit
buy_gas(deleted)
commitcommitContractDataAndActions
divmoddivMod
moddivmodDiv
muldivmulDivFloor
muldivrmulDivRound
muldivcmulDivCeil
muldivmodmulDivMod
begin_parsebeginParse
end_parse(s)s.assertEnd()
first_bits(s)s.getFirstBits()
skip_last_bits(s)s.removeLastBits()
slice_last(s)s.getLastBits()
cell_depth(c)c.depth()
slice_refs(s)s.remainingRefsCount()
slice_bits(s)s.remainingBitsCount()
slice_bits_refs(s)s.remainingBitsAndRefsCount()
slice_empty?(s)s.isEmpty()
slice_data_empty?(s)s.isEndOfBits()
slice_refs_empty?(s)s.isEndOfRefs()
slice_depth(s)s.depth()
equal_slice_bits(a,b)a.bitsEqual(b)
builder_refs(b)b.refsCount()
builder_bits(b)b.bitsCount()
builder_depth(b)b.depth()
begin_cellbeginCell
end_cellendCell
parse_addr(deleted)
parse_std_addruse address type
parse_var_addr(deleted)
config_paramblockchain.configParam
raw_reservereserveToncoinsOnBalance
raw_reserve_extrareserveExtraCurrenciesOnBalance
send_raw_messageuse createMessage
set_codecontract.setCodePostponed
randomrandom.uint256
randrandom.range
get_seedrandom.getSeed
set_seedrandom.setSeed
randomizerandom.initializeBy
randomize_ltrandom.initialize
dumpdebug.print
strdumpdebug.printString
dump_stkdebug.dumpStack
empty_listcreateEmptyList
conslistPrepend
unconslistSplit
list_nextlistNext
carlistGetHead
cdrlistGetTail
new_dictcreateEmptyMap
dict_empty?(d)m.isEmpty
pfxdict_get?prefixDictGet
pfxdict_set?prefixDictSet
pfxdict_delete?prefixDictDelete
Lisp-style lists require an explicit import; IDEs usually add the import automatically.
import "@stdlib/lisp-lists"

Mutating functions

In FunC, x~method mutates, whereas x.method returns a copy. In Tolk, methods are called with dot . and may mutate the object.
FunCTolk
int n = cs~load_uint(32);var n = cs.loadUint(32);
var (cs2, n) = cs.load_uint(32);var cs2 = cs; var n = cs2.loadUint(32);
  • 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.

Added functions

Tolk provides functions out of the box. The standard library is split into multiple files. Functions from common.tolk are always available, and most FunC analogues are included. Functions from other files must be explicitly imported:
import "@stdlib/gas-payments"

// now `calculateGasFee()` and other symbols are visible