Recently, the TON ecosystem has become very popular, and various mini-games on TON have emerged one after another. I wonder if you have played them. As an L1 chain, how is TON different from other chains? What are its advantages? What can ordinary people do on TON?

TON’s official slogan

Introduction to TON

TON (The Open Network) is a decentralized blockchain network that was created to serve Telegram's high-concurrency interaction needs with hundreds of millions of users. Well-known chains such as BTC produce a block every ten minutes, and the number of transactions in a block is capped, which obviously cannot meet Telegram's requirements, so TON came into being. TON can currently process millions of transactions per second.

TON has a huge user base of Telegram and the mini-program framework launched by Telegram, which gives TON a huge imagination space and attracts countless gold diggers. Compared with the previous use of WEB3 to expand the user base of WEB2, TON seems to be on another path by using Telegram as a medium to let users contact WEB3 in the way of WEB2.

Technical Features of TON

The biggest technical features of TON are high concurrency, high efficiency, and scalability. Of course, this seems to be the standard for every new chain, so how does TON do it?

Let's take ETH as an example. After the block-producing node completes the packaging of blocks and sorts the transactions, it is input into the EVM for processing. The whole process is a serial process. The advantage of this is that the result is certain. When processing a transaction, no other transactions will change the status, which can ensure consistency. However, the disadvantage is also obvious. The TPS will be relatively low.

TON abandons the serial execution process and adopts a completely parallel architecture. Here we need to solve two key problems: how to parallelize and how to ensure the consistency of the state.

Actor-based parallel environment

The basic unit in TON is Actor, which you can think of as a smart contract in ETH. Actor is the basis for TON to execute completely in parallel. There is no concept of distinguishing between accounts and smart contracts in TON. All objects are Actors, and your account is also a contract. Actors have certain logic execution capabilities and data storage capabilities. During a transaction, Actors will perform the following steps:

  • Event trigger (generally, external messages are received, such as transfers)

  • The method of executing the contract handles this event

  • Update the state of the contract

  • Send a message (optional)

  • Enter silent state and wait for the next event to occur

You can see that after this processing, each transaction is processed in parallel and independently, and each transaction can send messages asynchronously to interact with other actors. Each actor will maintain its own state independently, so you will find that your Jetton (Token) on TON will have an independent address, because the state of the number of Jettons is not maintained in the same Actor as your TON number.

To make it easier to understand and in line with everyone's previous cognition, Actor can be understood as a wallet or a contract, and the transmission of messages can be the interaction of contracts. Everyone only needs to know the original meaning.

Sharding

Sharding is a key mechanism in TON, which ensures the scalability of TON. In simple terms, the sharding mechanism is to "dynamically" adjust the amount of transactions processed by a node. For example, if there are too many transactions at a certain time, these transactions will be divided into several "subsets" and assigned to different nodes for parallel processing. Conversely, the "subsets" with smaller transaction volumes will be merged into one shard.

Quoting a picture from the official website, the sharding process is explained:

The blocks are divided according to the black dotted lines, where 101, 102, and 103 are on the same shard chain in one block, and 80 is on another shard chain. They are all obtained by "sharding" from node 100. In block 30, nodes 63 and 105 have a small transaction volume, so they are merged into one in block 31, namely 106.

The above knowledge generally introduces the overall process. The following introduces the specific meaning of each element in the figure.

1. AccountChain

In TON, a series of transactions corresponding to an account form a chain in a certain order, which is called an account chain. In the blockchain, if the execution logic and transaction order remain unchanged, the final state will be consistent. Different account chains can be processed in parallel.

The account chain is not shown in the above figure.

2. ShardChain

The shard chain corresponds to the digital node in the figure above. The shard chain is composed of multiple account chains. There is no special requirement for selecting which account chains to combine. Generally, the first few digits of the account are consistent as the merging standard. Multiple shard chains in one block can be processed in parallel by different nodes. The shard chain is the execution unit of the TON sharding mechanism, and the sharding operations are mainly performed on the shard chain.

To sum up: account chains form shard chains, and shard chains are combined into a block.

3. WorkChain

Shard chains need to work on the work chain, which is the blue line in the figure above. The work chain is a group of blockchains with their own rules. Everyone can deploy a chain with their own rules on the work chain, as long as 2/3 of the validators agree. TON allows the creation of up to "2 ^ 32" work chains, and each work chain can be subdivided into up to "2 ^ 60" shards.

Currently, there are only two chains on TON, "Basechain" and "Masterchain". The work chain is somewhat similar to the concept of L2. There are reports that there will be a new work chain to support EVM, which is also a manifestation of TON's scalability.

4. MasterChain

TON can have multiple working chains, but only one main chain. The main function of the main chain is to synchronize information from different working chains and reach a consensus on the status. The way to reach consensus is still through message transmission, but the message transmission fee between the main chain and the working chain is high, so only the key information of the block will be synchronized.

In the above picture, this is the part described by the black line.

Error rollback

In a serial scenario, if an error occurs, the transaction status will be rolled back. In a parallel scenario, the rollback is performed by internal message bounce. Smart contract interactions in TON are transmitted through messages, so such messages (internal messages) need to be set to bounce. When an error occurs, the original message will bounce back, carrying the remaining TON information and setting the flag to " bounced ". After receiving the bounce message, the Actor performs error handling.

Summarize

TON uses the Actor model to allow each state to be processed independently without relying on other states, thus achieving full parallelism. Through the sharding mechanism, TON can dynamically adjust to adapt to changes in the number of transactions on the chain. This set of TON mechanisms is complex but efficient. There are some technical details such as logical time and message passing, which will not be introduced in detail.

Some details when experiencing TON

If you have only experienced BTC or ETH before, there will be some differences when experiencing TON.

1. TON’s Account Model

As mentioned in the previous content, TON does not use the UTXO model of BTC, nor the wallet model in ETH. Your wallet is also a "contract". We know that deploying a contract requires paying Gas fees, but when we create a new wallet, there is no money in it, so how do we pay for this Gas?

In fact, when you create a TON wallet, your wallet is not completely created. Only when you have a transaction (someone transfers TON to you), your wallet will be initialized and a part of TON will be deducted as the fee for contract deployment. This is why you will find that you have transferred 10 TON but only received 9.99 TON.

2. TON’s Jetton transaction

According to the above introduction about Actor, each Actor maintains an independent state, which does not depend on external state. Therefore, Jetton on TON is not stored in your TON wallet, but an independent address linked to your TON wallet.

For example, Jetton in the picture below has its own address " Jetton wallet " on TON, but it will be linked to the TON wallet " Holder address ".

3. TON’s Gas Fee Calculation

Like most other chains, TON requires gas fees when trading, deploying contracts, and interacting with contracts. However, in practice, TON's transaction fees are still relatively expensive. For example, a Jetton transaction on a DEX may cost 0.05 TON, which is not an advantage compared to some chains.

In addition, TON also needs to pay storage fees, so if your wallet has not traded for a long time, the Gas fee for your next transaction may be much higher.

The specific Gas fee details can be viewed in Transaction Fee.

4. TON wallet categories

TON wallets also have multiple addresses, which is a bit like BTC. Different addresses of TON represent different versions of wallets, and different versions of wallets implement different functions. The most commonly used wallet is "V4 R 2", and the "W 5" wallet was recently launched, which can support the use of other tokens to pay for gas fees.

What can we do on TON?

A large part of the current popularity of TON comes from the robots on Telegram and the mini-programs on top of the robots. In particular, the recent explosion of some game mini-programs has brought huge traffic to some WEB3 projects.

Mini Programs on Telegram

With the mini-programs available on Telegram, it feels like we are back to the time when WeChat mini-programs were booming. However, the mini-programs on TG are mainly small games, and the quality varies. The only motivation for people to play them is to expect the project owner to issue an airdrop in the end. The project owner can use this vague expectation to attract a large number of users in a short period of time.

In addition to achieving fission by attracting users by completing tasks in the game, there are also some tool-type mini-programs that can provide the ability to attract users, such as a red envelope application on TG, which advertises by sending red envelopes to attract users.

Creating a TON website

You may have heard of domain name resolution. In ETH, you can buy a domain name to replace the long and complicated address. This is the domain name resolution of WEB3. In TON, in addition to purchasing a TON domain name to replace your address, you can actually use this domain name to build a website for others to visit, realizing the original function of the domain name.

A domain name is actually an NFT. You can trade your domain name just like trading NFT. The price of a domain name is related to the length of the domain name. The cheapest domain name costs 1 TON. Specific information can be found on TON's official domain name website.

robot

Robots have little to do with TON, but they are closely related to Telegram, so I would like to mention them here. There are a large number of robots on TG, which are used for transaction viewing, monitoring, fast transactions, etc. A handling fee of about 1% will be charged for each interaction. The number of transactions initiated on TG every day is huge, and there are robots for various chains, including SOL, ETH, and TON.

However, the competition in this field is quite fierce now, and it is always a bit unsafe to hand over the private key to a robot whose code is not public.

This article was written by Yeezo (X account @GaoYeezo 75065) of ZAN Team (X account @zan_team).