Overview
FunC is a high-level language 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);
}
The compiler converts FunC programs into Fift assembler code, generating the corresponding bytecode for the TON Virtual Machine.
Developers and engineers can use its bytecode, which is structured as a tree of cells like all data in the TON Blockchain, to create smart contracts or run it on a local instance of the TVM.
FunC cookbook
FunC documentation
Compiler
Compile with JS
Using the Blueprint framework is the most convenient and quickest way to begin developing and compiling smart contracts. Read more in the Blueprint section.
npm create ton@latest
Compile with original binaries
If you want to use the native FunC language locally, you need to set up the TON compiler 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 compiler's source code for FunC. Read how to compile it from sources.
TON Blockchain course
The TON Blockchain course includes Module 4, which covers FunC and smart contract development.
Check TON Blockchain course
CHN
RU
Tutorials
The best place to start developing with FunC is the Introduction section.
Below, you can find additional materials shared by community experts:
- 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
- Func & Blueprint - @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 - @romanovichim, using a blueprint
- 10 FunC lessons (RU) - @romanovichim, using a blueprint
- FunC quiz - Vadim. It is good for self-checking and will take 10–15 minutes. The questions are mainly about FunС, with a few general questions about TON.
- FunC quiz (RU) - Vadim
Contests
Joining contests is a great way to learn FunC. You can also review past competitions to learn more.
Contests legacy
Contest | Tasks | Solutions |
---|---|---|
TSC #5 (Dec 2023) | Tasks | |
TSC #4 (Sep 2023) | Tasks | Solutions |
TSC #3 (Dec 2022) | Tasks | Solutions |
TSC #2 (Jul 2022) | Tasks | Solutions |
TSC #1 (Mar 2022) | Tasks | Solutions |
Smart contract examples
Follow this link to find various standard smart contracts, such as wallets, electors that manage validation on TON, multi-signature wallets, etc. These can serve as helpful learning references.