Skip to main content
The official language of TON Blockchain is Tolk, and all other languages are deemed legacy. That said, you can still use them and contribute to the surrounding tooling or documentation.
Fift is a stack-based general-purpose tacit programming language optimized for creating, debugging, and managing smart contracts on TON Blockchain. It has been specifically designed to interact with TON Virtual Machine (TVM) and TON Blockchain. In particular, it offers native support for 257-bit integer arithmetic and cell manipulation, as well as an interface to the Ed25519-based cryptography employed by TON. Fift also includes a macro assembler for TVM code, which is a common intermediate target of higher-level languages such as Tolk, FunC, and Tact, as well as a common textual bitcode representation of smart contracts. For more examples of the latter, see various blockchain explorers and disassembled smart contracts.

Installation

Interpreter and libraries

Fift interpreter binaries for Windows, macOS (Intel or Arm64), and Ubuntu can be downloaded from the latest GitHub release. Make sure to also download the necessary libraries — download and unpack the smartcont_lib.zip. The lib/ folder inside contains standard libraries of Fift, which must be exposed to it when running the interpreter. Consider the following example installation steps:
1

Download the latest Fift binary

  • Windows
  • Linux
  • MacOS
Go to the latest GitHub release, download fift.exe and place it somewhere on your PATH. To see the current state of the PATH variable, run echo $env:PATH in the PowerShell.
2

Download Fift's standard libraries

  • Download smartcont_lib.zip from the latest GitHub release.
  • Unzip it and extract the contents.
  • Move the extracted lib/ folder somewhere convenient. You can also place it under a different name.
    • For example, for Linux and macOS it can be moved to ~/.local/lib/fiftlib
    • For Windows, to ~/.fiftlib
3

Run Fift

To invoke Fift binary you’ll need to pass it the standard libraries as such:
fift -I /path/to/extracted/lib -i Asm.fif
If you see errors or red-colored output lines, double-check the placement of the Fift binary and related libraries from previous steps.Otherwise, write the following and press “Enter”:
2 2 + .s
If you see “4 ok”, then Fift has been successfully installed on your machine!To learn about other launch options, add the -h flag by the end of the prior Fift invocation command.
For Linux and macOS, it might be convenient to make an alias as such:
# Within .bash_aliases or .zsh_aliases
alias fift="/path/to/fift -I /path/to/extracted/lib -i Asm.fif"

Additional tooling

Extensions and plugins

Online utilities

Getting started

Here is a simple Hello, World! example written in Fift:
."Hello, World!"
When executed with fift binary, it produces the following output:
Hello, World! ok
There, ok means successful end of execution of the given code snippet.
When things go awry, there may still be an ok by the end, albeit prefixed with several red lines of cryptic-looking stack traces. Those are how Fift reports errors and this is one of the major reasons why Fift is considered a legacy language.Any errors encountered during execution clear the stack!Hence, to actually know what happened, one needs to preemptively check stack contents. For that, use the “printf debugging” approach with the .s word — it dumps current stack contents to the console without modifying the stack.
"Hello, " .s
// "Hello, "

"World!" .s
// "Hello, " "World!"

$+
// "Hello, World!"

type
// Hello, World! ok
// Now, the stack is clear.
To continue learning Fift, see the educational materials section, or move to the follow-up references.

Educational materials

Whitepapers

While most of the information described there holds some truth, the fiftbase.pdf whitepaper is still considered legacy due to lack of updates and gradual integration of their contents into actual documentation pages.However, it is the most exhaustive reference manual on Fift to this date, so you can still use it to learn a lot about Fift.

Articles

Videos and playlists

Examples

See also

I