Asset processing overview
This page provides a short overview of how TON transfers work, the digital asset types on TON, and how to interact with the TON Blockchain using your programming language. Read and understand the information below before proceeding to the next pages.
Overview of messages and transactions
Embodying a fully asynchronous approach, the TON Blockchain involves a few concepts that are uncommon to traditional blockchains. In particular, each interaction of any actor with the blockchain consists of a graph of asynchronously transferred messages between smart contracts and/or the external world. Each transaction consists of one incoming message and up to 255 outgoing messages.
There are three types of messages, which are fully described here:
- External message: from outside the blockchain to a smart contract inside the blockchain.
- Internal message: between blockchain entities; can carry some amount of digital assets and an arbitrary portion of data.
- Log message: from a blockchain entity to the outside world.
The common path of any interaction starts with an external message sent to a wallet smart contract, which authenticates the message sender using public-key cryptography, takes charge of fee payment, and sends internal blockchain messages. These message queues form a directed acyclic graph (DAG).
For example:
- Alice uses, e.g., Tonkeeper to send an external message to her wallet.
- The external message is the input to wallet A v4 with an empty source (external message).
- The outgoing message is the output of wallet A v4 and the input to wallet B v4, with wallet A v4 as the source and wallet B v4 as the destination.
As a result, there are two transactions, each with its set of input and output messages.
A transaction occurs when a contract takes a message as input, processes it, and optionally generates outgoing messages. Read more about transactions here.
Transactions can span a prolonged period of time. Technically, transactions and their message queues are aggregated into blocks processed by validators. Because of asynchrony, you cannot know a transaction’s hash or logical time (LT) at the moment you send a message.
A transaction accepted into a block is final and cannot be modified.
TON transactions are irreversible after just one confirmation. For the best user experience, it is suggested to avoid waiting on additional blocks once transactions are finalized on the TON Blockchain. Read more in the Catchain.pdf.
Smart contracts pay several types of fees for transactions (usually from the balance of an incoming message; behavior depends on message mode). The amount of fees depends on network configuration, with higher fees on the masterchain and substantially lower fees on the basechain.
Digital asset types on TON
TON has three types of digital assets.
- Toncoin, the main token of the network. It is used for all basic operations on the blockchain, for example, paying gas fees or staking for validation.
- Contract assets, such as jettons and NFTs, are analogous to the ERC‑20/ERC‑721 standards and are managed by arbitrary contracts, which can require custom processing rules. You can find more info on their processing in the NFT processing and Jetton processing articles.
- TON supports up to 2^32 extra currencies; accounts and messages support them, but no extra currency has been created on the TON Blockchain yet—the minter system contract for their creation has not been deployed. See Extra currencies for more details.
Interaction with the TON Blockchain
Basic operations on the TON Blockchain can be carried out via TonLib. TonLib is a shared library that can be compiled along with a TON node and exposes APIs for interacting with the blockchain via lite servers (servers for lite clients). TonLib follows a trustless approach by checking proofs for all incoming data; thus, there is no need for a trusted data provider. Methods available in TonLib are listed in the TL scheme. You can use TonLib directly as a shared library or via language wrappers (see SDKs).
Read next
After reading this article you can check:
- Payments processing — learn how to work with Toncoin.
- Jetton processing — learn how to work with jettons (sometimes called “tokens”).
- NFT processing — learn how to work with NFTs.