FunC is an intermediate-level language used to write smart contracts on TON. It is a domain-specific, statically typed language with C-like syntax. Example of a FunC method for sending funds:Documentation Index
Fetch the complete documentation index at: https://companyname-a7d5b98e-closes-allow-word-breaks-in-tables.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
address to send the money to,
and the amount to send. It does not return a value, indicated by () to the left of the method name send_money.
The method uses the impure and inline specifiers, which are flags that tell the compiler to process
the method in specific ways.
The method first creates the message to send msg by using a cell builder, since the message is encoded as a cell. The procedure is:
- Create a new cell builder with
begin_cell. - Set message flags at the line with the single-line comment
;; It sets the message to be non-bounceable.. - Store the receiving address with
store_slice. - Store the amount to send using
store_coins. - Finalize the cell with a call to the
end_cellfunction.
send_raw_message sends the message, where the parameter 64 describes a sending mode.
Compiler
The compiler converts FunC programs into Fift assembler code. The Fift assembler code is then compiled down to bitcode for the TON Virtual Machine using the Fift compiler. Developers can use the compiled bitcode, structured as a bag of cells like all data in the TON blockchain, to test smart contracts, send messages, or execute it in a local TVM instance.Compile using tooling
To compile FunC files to bitcode, install thefunc-js npm package in your project folder.
It runs in any environment with Node.js v22 or later installed.
The func-js package integrates the FunC and Fift compilers
to produce bitcode directly from FunC source code, without manual Fift invocation.
To install func-js, run the following command in your project root:
contract.fc is the FunC source file in your project root, and output.boc is the compiled bitcode output.
You can also use Blueprint to start a project.
See the Blueprint section for setup instructions.
Compile manually using the binaries
Prebuilt FunC compiler binaries for Windows, macOS (Intel or Arm64), and Ubuntu are available on GitHub. 1. Download the corresponding binary for your operating system:- Linux:
func-linux-x86_64(Intel/AMD) andfunc-linux-arm64(Arm64) - Mac:
func-mac-x86-64(Intel/AMD) andfunc-mac-arm64(Arm64) - Windows:
func.exe
func, for easier use in the command line, and add it to your system’s PATH.
2. Download the FunC standard library.
Get the smartcont_lib.zip from the same GitHub, extract it, and copy stdlib.fc to your project root.
3. Compile a FunC file to Fift assembler code.
Run the following command in your project root:
contract.fc is the FunC file to compile, and output.fif is the generated Fift output.
If you need to compile the generated Fift file output.fif further down to TVM bitcode, use the Fift compiler.
See the Fift for download and usage instructions.
Tutorials
- Challenge 1: Simple NFT deploy
- Challenge 2: Chatbot contract
- Challenge 3: Jetton vending machine
- Challenge 4: Lottery/raffle
- Challenge 5: Create UI to interact with the contract in 5 minutes
- Challenge 6: Analyzing NFT sales on the Getgems marketplace
- TON hello world Part 2: guide for writing your first smart contract
- TON hello world Part 4: guide for testing your first smart contract
- 10 lessons for developing contracts in FunC — Russian version
- FunC quiz — a short Telegram quiz focused on FunC, with a few general TON questions.