Stay in Tact with TON
Tags: web3, blockchain, cryptocurrency, programming
Published: 2023-07-26 07:21:20


## Table of Contents

1.  [FunC development is not fun at all!!](#orgfd121a9)
2.  [Tact - the savior of all FunC developers](#org11b9121)
3.  [Awesome tools for Tact development](#org8085ddc)
4.  [Getting to the code](#orgf982e4b)
5.  [Special thanks](#orgbb2496b)

<a id="org4eda193"></a>

This article is a script of a talk we gave at TON Korea meetup telling the community about the newest tools for development on [TON](https://ton.org/)

First, what's so special about TON compared to other blockchains? There are a couple of cool features:

-   Easy integration with Telegram
-   Everything on-chain is a smart contract(even accounts and wallets)
-   Calls between contracts are asynchronous
-   Contract sharding is the main consensus

These provides infinite scaling, predictable gas prices and cheap execution. But my personal favorite is that **there is no need for a proxy, you can make your contracts mutable to fix mistakes and easily update them**. However, there's on big problem with TON.


<a id="orgfd121a9"></a>

## [FunC](https://docs.ton.org/develop/func/overview) development is not fun at all!!

FunC is a very low-level language: you need to deal with TL-B schemas, TVM opcodes, and lots of hashing algorithms and ideally understand all of them. Furthermore, it has its own variable types: Cells and slices with which you have to deal regularly. Then it has the authentic syntax: functions and methods declaration vary significantly from the ones we are used to see, there are lots of syntax sugars. And my personal pain is the fact that there is only one method to deal with all the incoming messages.

That makes contracts very messy. All this sets a very high entry threshold for devs. But recently a way to loosen the burden appeared.


<a id="org11b9121"></a>

## [Tact](https://tact-lang.org/) - the savior of all FunC developers

A team of devs from TonWhales, Tonkeeper and Ton core teams created a new programming language: Tact. The first version was released in March and is regularly updated. TACT is expected to become the main language for TON smart contract development The main features are these:

-   it introduces Object-oriented programming elements giving the opportunity to recycle code structures
-   resembles Kotlin, Rust, Typescript, and Solidity in a way
-   has built-in methods like initializer
-   you don't have to deal with cells and slices
-   has ABI support, so you don’t need to use the client to access smart contracts

**TACT is all about real necessities for devs**


<a id="org8085ddc"></a>

## Awesome tools for Tact development

I use it toghether with the [blueprint framework](https://github.com/ton-org/blueprint), which provides easy creation, compilation, and deployment for smart contracts. The blueprint framework has a testing suite - [Sandbox](https://github.com/ton-org/sandbox), which makes testing comfortable and smooth. Another cool tool is [Ton connect](https://github.com/ton-connect) which supports wallets like Tonkeeper, OpenMask, TonHub, etc., and makes payment processing a piece of cake.


<a id="orgf982e4b"></a>

## Getting to the code

[_We also recorded a video walkthrough of the code_
](https://youtu.be/TqX8qgwoDl8)

To quickly get started let's use the blueprint framework, it'll scaffold the project with npm.
`npm create ton@latest`
After this command it'll prompt you to specify your project name, first contract name, and a template - choose "An empty contract (TACT)" here.

![Command line screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4ww2lq2byc2mour5jm6l.png)

In the project directory, under `contracts/imports` is our first smart contract - `balance.tact`. Let's write some code now

    import "@stdlib/deploy";
    import "@stdlib/ownable";
    
    message Withdraw{
        amount : Int as coins;
    }
    
    contract Balance with Deployable, Ownable {
    
        balance: Int as uint256 = 0;
        owner: Address;
    
        init() {
            // sender() is a built-in function which reads the sender of the message
            self.owner = sender();
        }
    
        // Deposit TON to our smart contract
        receive("Deposit"){
            // context() returns data of the incoming message: sender, value, type(bounced, not bounced) and its raw representation
            self.balance = self.balance + context().value;
        }
    
        receive(msg: Withdraw){
            // A built-in method to check that the message is sent by the owner of the contract
            self.requireOwner();
            require(msg.amount < self.balance , "Too much!");
            self.balance = self.balance - msg.amount;
            send(SendParameters{
                to: sender(),
                value: msg.amount,
                mode: SendIgnoreErrors,
                body: "Get your tokens!".asComment()
            });
        }
    
        get fun balance(): Int{
            return self.balance;
        }
    }

Build your smart contract with this command `npx blueprint build`. 

You should see a couple of files appear under `build/Balance` directory. **The most interesting being the compiled FunC code** - `tact_Balance.code.fc`. 

Looking at it further, you might noticed that it's not that Gas efficient. In other words, if you were to write the same thing in FunC you'd probably save 20% on gas costs, but because Gas is so cheap on TON, it's not an issue.

Also, Tact plans to compile code straight to [fift](https://docs.ton.org/develop/fift/overview) - an exteremely low-level langauge for the TON Virtual Machine and TON Blockchain. This might lead to Tact being on par, if not more gas-efficient than FunC. **Exciting times are ahead for Tact**


<a id="orgbb2496b"></a>

## Special thanks

Thanks to the lead Blockchain Developer at MiKi Digital - [Vladislav Lenskiy](https://www.linkedin.com/in/vladislav-lenskii-393697237/) for preparing this awesome talk.
Thanks to [Lucy Kang](https://www.linkedin.com/in/hyunjoo-kang/) for hosting the event, and helping drive the adoption of TON in Korea.
And a very warm thank you to the team behind Tact language - Steve Korshakov, Tal Kol, Oleg Andreev, Kirill Emelyanenko, Kirill Maev, and others from Tonkeeper, TON Whales, TON core, etc.

P.S. If you need any web3 help feel free to [reach out to us at at our website](https://www.miki.digital/contact) or [book a call](https://calendly.com/miki-digital/15min)