# Fift language overview (https://docs-i0yym09dy-ton-core-docs.vercel.app/llms/languages/fift/overview/content.md)



<Callout type="note">
  The official smart contract language of TON Blockchain is [Tolk](/llms/tolk/overview/content.md). Fift is now a **legacy** language, with its compiler no longer maintained.
</Callout>

Fift is a [stack-based](https://en.wikipedia.org/wiki/Stack-oriented_programming) general-purpose [tacit](https://en.wikipedia.org/wiki/Tacit_programming) 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](/llms/tolk/overview/content.md) and [FunC](/llms/languages/func/overview/content.md), as well as a common textual bitcode representation of smart contracts. For more examples of the latter, see [various blockchain explorers](/llms/ecosystem/explorers/overview/content.md) and disassembled smart contracts.

## Installation [#installation]

### Interpreter and libraries [#interpreter-and-libraries]

Fift interpreter binaries for Windows, macOS (Intel or Arm64), and Ubuntu can be downloaded from the [latest GitHub release](https://github.com/ton-blockchain/ton/releases/latest).

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:

<Steps>
  <Step>
    #### Download the latest Fift binary [#download-the-latest-fift-binary]

    <Tabs items="[&#x22;Windows&#x22;, &#x22;Linux&#x22;, &#x22;macOS&#x22;]">
      <Tab value="Windows">
        Go to the [latest GitHub release](https://github.com/ton-blockchain/ton/releases/latest), 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.
      </Tab>

      <Tab value="Linux">
        Go to the [latest GitHub release](https://github.com/ton-blockchain/ton/releases/latest), download `fift-linux-x86_64` (64-bit, x86 arch) or `fift-linux-arm64` (64-bit, Arm arch), and place it somewhere on your `$PATH` as `fift`. To see the current state of the `$PATH` variable, run `echo $PATH | tr ':' '\n'` in the terminal.
      </Tab>

      <Tab value="macOS">
        Go to the [latest GitHub release](https://github.com/ton-blockchain/ton/releases/latest), download `fift-mac-x86-64` (64-bit, Intel) or `fift-mac-arm64` (64-bit, Apple Silicon), and place it somewhere on your `$PATH` as `fift`. To see the current state of the `$PATH` variable, run `echo $PATH | tr ':' '\n'` in the terminal.
      </Tab>
    </Tabs>
  </Step>

  <Step>
    #### Download Fift's standard libraries [#download-fifts-standard-libraries]

    * Download `smartcont_lib.zip` from the [latest GitHub release](https://github.com/ton-blockchain/ton/releases/latest).
    * 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`
  </Step>

  <Step>
    #### Run Fift [#run-fift]

    To invoke the Fift binary, you'll need to pass it the standard libraries as such:

    ```shell
    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":

    ```fift
    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.
  </Step>
</Steps>

<Callout type="tip">
  For Linux and macOS, it might be convenient to make an alias as such:

  ```shell
  # Within .bash_aliases or .zsh_aliases
  alias fift="/path/to/fift -I /path/to/extracted/lib -i Asm.fif"
  ```
</Callout>

### Additional tooling [#additional-tooling]

#### Extensions and plugins [#extensions-and-plugins]

* [VS Code extension](https://marketplace.visualstudio.com/items?itemName=ton-core.vscode-ton) - powerful and feature-rich extension for Visual Studio Code (VSCode) and VSCode-based editors like VSCodium, Cursor, Windsurf, and others.
  * Get it on the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=ton-core.vscode-ton).
  * Get it on the [Open VSX Registry](https://open-vsx.org/extension/ton-core/vscode-ton).
  * Or install from the [`.vsix` files in nightly releases](https://github.com/ton-blockchain/ton-language-server/releases).
* [JetBrains IDEs plugin](https://plugins.jetbrains.com/plugin/23382-ton) - provides syntax highlighting, code navigation, and more.
* [Language Server (LSP Server)](https://github.com/ton-blockchain/ton-language-server) - supports Sublime Text, (Neo)Vim, Helix, and other editors with LSP support.

#### Online utilities [#online-utilities]

* [TxTracer: Assembly playground](https://txtracer.ton.org/play/)
* [TxTracer: Code explorer with assembly output](https://txtracer.ton.org/code-explorer/)
* [TxTracer: TVM instruction table](https://txtracer.ton.org/spec/)

## Getting started [#getting-started]

Here is a simple `Hello, World!` example written in Fift:

```fift
."Hello, World!"
```

When [executed with `fift` binary](#installation), it produces the following output:

```txt
Hello, World! ok
```

There, `ok` means successful end of execution of the given code snippet.

<Callout type="caution">
  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"](https://en.wikipedia.org/wiki/Debugging#printf_debugging) approach with the `.s` word — it dumps current stack contents to the console without modifying the stack.

  ```fift
  "Hello, " .s
  // "Hello, "

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

  $+
  // "Hello, World!"

  type
  // Hello, World! ok
  // Now, the stack is clear.
  ```
</Callout>

To continue learning Fift, see the [educational materials](#educational-materials) section, or move to the follow-up references.

<Columns cols="2">
  <Card title="Types" href="/languages/fift/types" />

  <Card title="Basic values" href="/languages/fift/basic-values" />

  <Card title="Words, constants, and variables" href="/languages/fift/variables" />

  <Card title="Control flow" href="/languages/fift/control" />

  <Card title="Assembler" href="/languages/fift/fift-assembler" />

  <Card title="Fift and TVM assembly" href="/languages/fift/fift-and-tvm-assembly" />

  <Card title="Deep dive into Fift" href="/languages/fift/deep-dive" />

  <Card title="Simple multi-signature wallet" href="/languages/fift/multisig" />

  <Card title="Changing TON config params" href="/languages/fift/ton-config" />

  <Card title="Whitepapers (see below)" href="#whitepapers" />
</Columns>

## Educational materials [#educational-materials]

### Whitepapers [#whitepapers]

<Callout>
  While most of the information described there holds some truth, the `fiftbase.pdf` whitepaper is still considered legacy due to a lack of updates and gradual integration of its contents into actual documentation pages.

  However, it is the most exhaustive reference manual on Fift to date, so you can still use it to learn a lot about Fift.
</Callout>

<Columns cols="2">
  <Card title="Fift language specification, web version" href="/languages/fift/whitepaper">
    Tacit stack-based programming language with a deep connection to TVM.
  </Card>

  <Card title="Fift language specification, PDF" href="/pdfs/fiftbase.pdf">
    Original documentation written by Dr. Nikolai Durov, a comprehensive whitepaper.
  </Card>
</Columns>

### Articles [#articles]

<Columns cols="2">
  <Card title="Introduction to Fift" arrow="true" href="https://blog.ton.org/introduction-to-fift" />
</Columns>

### Videos and playlists [#videos-and-playlists]

<Columns cols="2">
  <Card title="«His majesty Fift»" arrow="true" href="https://www.youtube.com/@WikiMar/videos" cta="In Russian" />
</Columns>

### Examples [#examples]

<Columns cols="2">
  <Card title="Simple multi-signature wallet" href="/languages/fift/multisig" />

  <Card title="Multi-signature wallet v2" arrow="true" href="https://github.com/ton-blockchain/multisig-contract-v2" />
</Columns>

## See also [#see-also]

* [Multisignature wallet v2](https://github.com/ton-blockchain/multisig-contract-v2)
* [Forth language](https://en.wikipedia.org/wiki/Forth_\(programming_language\))
* [Factor language](https://en.wikipedia.org/wiki/Factor_\(programming_language\))
* [Uiua language](https://www.uiua.org/)
* [Concatenative languages](https://www.concatenative.org/wiki/view/Concatenative%20language)
