Skip to main content
The Tolk type system is designed with the specifics of TON in mind. Since on-chain data and communication rely entirely on cells, the system focuses on binary serialization and clear data relationships. Programs run on a stack-based virtual machine (TVM), which imposes specific rules on how values are represented at runtime. This section describes all the types in Tolk language:
  • numbers — int, int32, uint64, coins, etc.
  • boolean — true/false and logical operators
  • address — internal, external, and none addresses
  • cells — and also slices, builders, and raw bits
  • strings — not a native type, emulated using slices
  • structures — group several fields into one entity
  • type aliases — similar to TypeScript and Rust
  • generics — any struct can be generic <T>
  • enums — a distinct type containing integer variants
  • nullable types — with null safety and smart casts
  • union types — a variable holds one of possible values
  • tensors — multiple values placed sequentially on the stack
  • tuples — multiple values stored in a single TVM tuple
  • maps — key-value dictionaries
  • callables — first-class functions
  • void and never — both mean “absence of a value”

An article “Type checks and casts” describes casting types with unsafe as operator. For a summary of how types are represented on a TVM stack, follow Overall: TVM stack representation. For a summary of how types are serialized and their relation to TL/B, follow Overall: serialization.