Dwarves
Memo
Type ESC to close search bar

Ton's base concepts

In my previous post, Ton: Blockchain of Blockchains, I talked about some core technologies that make TON strong. However, it was just an overview. To begin developing on TON is not enough. Today, I will introduce some core concepts in TON that you will frequently work with as a TON developer.

Cells and Data Storage

Cells are the atomic unit of data storage in TON. It is a data structure containing:

Currently, TON has 2 types of cells: ordinary and exotic

When serializing cells into byte arrays, it is called Bag of cells. Every data stored on TON including blocks and the state of the network is a bag of cells.

Smart contract

As mentioned in the previous post, everything in TON is a smart contract. That contains:

Message

To communicate between smart contracts aka actors on TON network, we need to send messages. A message is a package of data that contains the following elements:

We have 2 types of messages:

Transaction

On TON, we have the transaction that records the state changes of processing a message. That basically contains:

Not every transaction leads to outgoing messages or updates to the contract’s storage; this depends on the specific actions defined by the contract’s code.

One more important point to note is that unlike Ethereum or most other synchronous blockchains, where each transaction can contain several smart contract calls, in TON, a transaction is executed on a single smart contract, and smart contracts communicate through messages.

Gas

In Solidity, gas concerns are minimal for contract developers. If a user provides insufficient gas, the transaction will be completely reverted (though the gas spent will not be refunded). If sufficient gas is provided, the actual costs will be calculated and deducted from the user’s balance automatically.

In TON, the scenario differs:

TON does not automatically calculate gas. The entire transaction execution, with all its outcomes, can be lengthy, potentially leaving the user with an insufficient toncoin balance by the end. So the developer must take care of gas costs. However, calculating gas is not an easy task. So we often need to set a minimum gas limit for each transaction, then refund the excess gas later. For example:

FYI: Fee formula on TON transaction_fee = storage_fees

+ in_fwd_fees
+ computation_fees
+ action_fees
+ out_fwd_fees

Conclusion

With all the above concepts, we can now begin developing on TON. But these are actually not enough. We will continue diving deep into more complex concepts such as data format, transaction layout, or bounceable addresses when developing something in the next post.