A Guide to the TON Blockchain

The TON blockchain is becoming increasingly popular among businesses looking to create decentralized applications (dApps) across various industries.

Serokell has hands-on expertise with the platform. In 2019, we won the first prize at the TON competition for smart contract development, where we designed multi-signature wallets and synchronous and asynchronous two-party payment channels.

In this post, we provide an overview of the TON architecture and its technical aspects to equip you with the essential knowledge needed to decide whether the TON blockchain is what you are looking for.

What is TON?

TON (The Open Network) is a blockchain designed to facilitate fast transactions and help build a wide range of decentralized applications (dApps). This community-driven project was initiated by the creators and owners of Telegram.

TON_Blockchain

The network comprises several components, such as the TON Blockchain, TON DNS, TON Storage, and TON Sites.

  • TON DNS: Simplifies user interactions by assigning human-readable names to accounts and dApps.
  • TON Storage: Offers decentralized file storage, optimizing data retrieval and
  • TON Sites: Allows users to launch a web server with their website and make it available on the TON network.
  • TON Proxy: Enables connection to TON Sites.
  • TON Payments: Facilitates instant payments without the need to wait for block confirmation or pay transaction fees.
  • TON Space: Integrates with Telegram, providing a user-friendly environment with easy access to wallets within the messaging platform.
  • TON DHT: Functions as a decentralized storage system where each member of the network can store information about themselves or other data.

TON is not just a blockchain; it is an entire ecosystem comprising key players such as users, who possess assets; validators, who uphold the core consensus to ensure the blockchain’s integrity; and app developers, who build and develop services on the TON platform.

Telegram’s extensive user community, which has direct access to The Open Network, boosts its adoption potential.

TON design principles

The TON blockchain’s architecture is designed to provide a scalable platform for decentralized applications. By isolating contracts, supporting asynchronous operations, and using a sharded proof-of-stake consensus, TON ensures flexibility, scalability, security, and efficiency in working with decentralized apps.

TON operates as a ledger of state transitions. It records changes in the state of arbitrary accounts, each of which is a smart contract with its own storage and unique address. These accounts hold TON coin balances and program code, allowing developers to design the logic of smart contracts that are executed on the TON Virtual Machine (TVM).

The most important design principles of TON include:

Asynchronous operations

TON operates asynchronously, meaning a contract cannot immediately read another contract’s state. Instead, it sends a message and waits for a response. This design is similar to how independent computers on the internet communicate, maintaining their own data and state while sending and receiving messages asynchronously. It ensures that no single entity needs to see the entire global state of the blockchain at any time.

Flexibility and isolation

TON contracts offer great flexibility to developers, who can modify data, update contract code, send messages with coins and data to other contracts. Each contract is self-contained and isolated, preventing direct access to other contracts’ states, which allows the TON blockchain to scale infinitely. Contracts process incoming information, update their state, and send outgoing messages independently.

Guarantees and consensus

The TON blockchain ensures developers can verify the address of any message sender. Similarly, messages sent to an address come with cryptographic assurances regarding the receiving code. The network guarantees message delivery, although the time frame can vary across shards and blocks.

TON utilizes a proof-of-stake model to prevent double-spending and maintain consensus within the network. In this model, validators are chosen based on their stake, or the amount of cryptocurrency they hold. Validators are responsible for verifying transactions and are incentivized to act honestly because their stake is at risk of fines for fake verification. With many validators confirming each transaction, fraudulent actions are easy to detect and reject. This helps maintain the integrity of the TON network by deterring malicious actors from manipulating transactions.

Validators can be divided into groups to manage increased loads, allowing the system to scale horizontally. For example, one group might handle even account numbers, and another group might handle odd accounts.

Transaction processing latency

It takes about 5 to 6 seconds for a transaction to be committed to the basechain and another 5 to 6 seconds for the masterchain. In this way, the network needs around 10 to 12 seconds to display updated data. More complex transactions involving multiple messages may take longer, but most transactions are straightforward, with predictable subsequent actions once the initial transaction is confirmed.

Independent contracts

Each contract in TON operates as an independent account with its own data and code. They communicate by sending messages. Validator consensus ensures message delivery and prevents replay attacks and double-spending. While operations often involve multiple transactions across various contracts, initial transaction confirmation only takes a few seconds.

To learn more about TON technical aspects, watch this video course:

TON architecture

The TON blockchain is structured with a masterchain and up to 2^32 workchains, each with its own set of rules. These workchains can further divide into 2^60 shardchains. Currently, only the basechain is operational.

TON_architecture
  • Masterchain: This primary chain stores network configuration, the final state of all workchains, protocol information, active validators, and block hashes, ensuring network consensus.
  • Workchain: Customized blockchains for specific transactions or use cases, running parallel within the TON network. Each workchain has its own rules, consensus mechanisms, and tokenomics but syncs with the masterchain for validation and interoperability.
  • Shardchain: Sub-chains of workchains, identified by a 60-bit shard prefix that indicates specific accounts. Shardchains can split or merge dynamically to balance the workload.

Dynamic sharding

TON’s dynamic sharding allows it to distribute transactions across multiple workchains and shardchains, eliminating bottlenecks. Shardchains report their state to the masterchain and use Hypercube routing for intershard communication, ensuring efficient transaction processing across the ecosystem.

Sharding

Validators

Validators maintain the network’s integrity, security, and operation by providing computing power and staking Toncoin. They validate new blocks, confirm transactions, and participate in the consensus mechanism. Validators are essential to the entire ecosystem, from the masterchain to individual shardchains. They are periodically reshuffled to prevent collusion. This hierarchical, sharded architecture ensures that TON can support various use cases and extremely high transaction volumes.

What are TON accounts and contracts?

In the TON blockchain, the terms “account” and “smart contract,” or just “contract” are interchangeable. They consist of the following components:

  • Code: Defines the contract’s logic.
  • Data: Stores the contract’s internal state.
  • Coin balance: Holds the contract’s TON coins.
  • Address: A cryptographic hash of the contract’s initial data and code, ensuring it remains unchanged as the contract evolves.
TON_accounts

What is contract functionality?

Contracts can perform the following operations:

  • Internal messages handling: Receive and process incoming messages from other smart contracts.
  • External message handling: Receive and process incoming messages sent from outside the blockchain.
  • Updating the state: Change the data in the contract storage and the contract code.
  • Sending messages: Send messages with attached coins and data to other contracts.

Usually, complex systems consist of several smart contracts, and interactions with such systems involve calling an entry point contract, which then sends messages to other contracts that perform intermediate computations and update their state accordingly.

Contract costs and fees

In many blockchain systems, the initiator of the contract pays fees for the first operation. However, ongoing costs for maintaining the infrastructure that stores transaction historical data are typically covered by the blockchain development platform. The TON chain utilizes a different approach.

The fees for the operations are deducted from the contract’s current balance. These fees cover various costs like storing a smart contract on the blockchain, execution, message routing, and more. The most important ones include:

  • Gas costs: Incurred for executing code on a contract. Each instruction has a gas unit cost, and the total gas cost is deducted from the contract’s balance.
  • Rent: Payment for storage, deducted from the contract’s balance. Calculated between transactions, leading to higher initial transaction fees after long periods of inactivity.
  • Message fees: Charges for creating outgoing messages and processing incoming ones. These fees can be paid by the contract or deducted from incoming funds.

If a contract runs out of funds, it may freeze, and its data is replaced by a cryptographic hash of its last state. To unfreeze it, users must provide a matching data snapshot. Developers must ensure the contract has enough balance to cover rent throughout its lifetime.

How is TON different from other blockchains?

The main benefit of TON is its scalability and speed of operation. Due to its multi-blockchain architecture, consisting of multiple layers, TON can process millions of transactions per second and is often referred to as the blockchain of the future. To better understand why, let’s take a brief look at the history of blockchain and the specific features of each generation of this technology.

Bitcoin: Limited flexibility

Bitcoin is the first cryptocurrency and blockchain created nearly 14 years ago. While simple, it lacks flexibility. Its scripting language allows for basic smart contracts, but it has limited storage and state management capabilities. Bitcoin’s main problem is the finite number of blocks, which were set initially and are now close to running out. Therefore, this blockchain has no potential for development.

Ethereum: Scalability issues

Ethereum, the second generation of blockchain, expands on Bitcoin’s foundation, offering more flexibility. This model supports complex smart contracts but suffers from scalability issues, as every node must store the entire blockchain state and process transactions sequentially.

TON: Flexibility and scalability

As a third-generation blockchain, TON combines Ethereum’s flexibility with the scalability needed for large-scale applications. Each account maintains its own state and communicates asynchronously with other contracts, allowing for efficient message routing without accessing the entire blockchain state. Transactions in TON can be processed in any order due to the asynchronous and parallel nature of smart contract calls. TON utilizes sharding, dividing contracts into smaller pieces that communicate across the network.

The system guarantees a conflict-free outcome, regardless of the execution order, and uses logical time to track the order of actions.

What apps and services does TON support?

TON supports a wide range of applications and services, which can be broadly categorized into custodial and non-custodial services.

  • Custodial services are managed by entities responsible for safeguarding deposited funds. Online exchanges typically fall into this category, as they hold coins or tokens in their own wallets to guarantee trade settlements. However, this setup has risks associated with it, as exchanges can be hacked, resulting in potentially irrecoverable losses.

  • Non-custodial services do not hold users’ funds. Instead, users maintain direct control over their assets, which enhances security by reducing the risk of hacking. Blockchain smart contracts facilitate this by offering strong security guarantees through decentralized mechanisms.

What are the potential TON use cases?

Now that we have studied TON’s technical side, let’s explore potential use cases, including payment infrastructure, gaming, decentralized finance, supply chain management, and IoT.

Payment infrastructure

TON facilitates fast and cost-effective global financial transactions, redefining remittances, payroll, and e-commerce. Its speed and scalability promote financial inclusivity by enabling microtransactions for the unbanked population, democratizing access to the digital economy.

Gaming

TON’s architecture allows game developers to create customized workchains with minimal fees, supporting in-game economies that match the real world. This enables complex game designs and economic models, offering players smooth gameplay without overloading the network.

Decentralized exchanges (DEXs) and DeFi

TON’s transaction speed can revolutionize decentralized trading, enabling high-frequency trading and reducing slippage. This ensures market stability and fosters an equitable trading environment accessible to all.

Supply chain management

TON’s infrastructure can enhance supply chains by providing real-time tracking and immediate transaction settlement. This reduces operational costs, prevents fraud, and ensures product authenticity, especially in industries with complex logistics like pharmaceuticals.

IoT networks

TON supports IoT networks by enabling smooth, reliable machine-to-machine communication. This can lead to smarter cities, more responsive energy grids, and enhanced interaction between digital services and the physical world.

Conclusion

TON is a robust platform built to support a decentralized internet. Its unique features and scalable architecture enable a broad range of applications and serve an expanding user base. TON’s approach to smart contract economics, asynchronous communication, and adaptable wallet structure positions it as a leading blockchain network for the future. If you are considering innovating your business with decentralized applications, this platform may be the solution you need.

Banner that links to Serokell Shop. You can buy stylish FP T-shirts there!
More from Serokell
Word2Vec: what it is and how it worksWord2Vec: what it is and how it works
Physics, History and Haskell. Interview with Rinat StryungisPhysics, History and Haskell. Interview with Rinat Stryungis
louis interview thumbnaillouis interview thumbnail