Overview
FunC, a high-level language, is used to program smart contracts on TON.
FunC is a domain-specific, C-like, statically typed language. Here is a simple example of a method for sending money written in FunC:
() send_money(slice address, int amount) impure inline {
var msg = begin_cell()
.store_uint(0x10, 6) ;; nobounce
.store_slice(address)
.store_coins(amount)
.end_cell();
send_raw_message(msg, 64);
}
FunC programs are compiled into Fift assembler code, which generates the corresponding bytecode for the TON Virtual Machine.
his bytecode (essentially a tree of cells, like any other data in the TON Blockchain) can then be used to create smart contracts on the blockchain or can be run on a local instance of the TVM.
FunC Cookbook
FunC Documentation
Compiler
Compile with JS
The most convenient and quickest way to begin developing and compiling smart contracts is by using the Blueprint framework. Read more in the Blueprint section.
npm create ton@latest
Compile with original binaries
If you want to use the native TON compiler, FunC, locally, you need to set up the binaries on your machine. FunC compiler binaries for Windows, macOS (Intel/M1), and Ubuntu can be downloaded from:
Alternatively, you can create binaries from source code, such as the FunC compiler source code (read how to compile a FunC compiler from sources).
TON Course: FunC
The TON Blockchain Course is a comprehensive guide to TON Blockchain development.
Module 4 completely covers FunC language and smart contracts development.
Check TON Blockchain Course
CHN
RU
Tutorials
The best place to start to develop using FunC: INTRODUCTION
Additional materials graciously provided by experts from the community:
- Func & Blueprint by @MarcoDaTr0p0je
- TON Hello World: Step-by-step guide for writing your first smart contract
- TON Hello World: Step by step guide for testing your first smart contract
- 10 FunC Lessons by @romanovichim, using blueprint
- 10 FunC lessons (RU) by @romanovichim, using blueprint
- FunC Quiz by Vadim—Good for selfcheck. It will take 10–15 minutes. The questions are mainly about FunС with a few general questions about TON
- FunC Quiz (RU) by Vadim—FunC Quiz in Russian
Contests
Participating in contests is a great way to learn FunC.
You can also study previous competitions for learning purposes.
Contests Legacy
Contest Descr | Tasks | Solutions |
---|---|---|
TSC #5 (December, 2023) | Tasks | |
TSC #4 (September, 2023) | Tasks | Solutions |
TSC #3 (December, 2022) | Tasks | Solutions |
TSC #2 (July, 2022) | Tasks | Solutions |
TSC #1 (March, 2022) | Tasks | Solutions |
Smart contract examples
Standard basic smart contracts, like wallets, electors (which manage validation on TON), multi-signature wallets, etc., can serve as references when studying.