Oraichain
  • ORAICHAIN
    • Introduction
    • System Overview
      • AI Layer 1 for Data Economy & blockchain oracle services
      • Layer 2 Rollups and Subnetworks
      • Verifiable and trustless AI Execution
      • Protocol Messages
      • IBC Integration
    • Use Cases
    • Token Economics
  • DEVELOPER GUIDES
    • General
      • Blockchain details
    • CosmWasm Contracts
      • Compile a Contract
      • Deploy a Contract
      • Query a Contract
      • Send tokens to a Contract
      • Manage Contracts using design patterns
      • End-to-end CosmWasm testing with CW-simulate
    • Local testnet chain
    • Wallet
      • OWallet
    • Price Feed
      • CW Oracle Hub
    • VRF 2.0
      • Introduction to Oraichain VRF 2.0
      • Get a Random Value from API
        • Get VRF Value from different networks
        • Contract Addresses and Pricing
        • Validate a Group Signature
      • Security Remarks
      • API Reference
      • Get support from Oraichain team
    • OraiDEX
      • ORAIX Token
      • OBridge
        • OraiBTC
        • TON Bridge
          • TON Blockchain 101
      • Decentralization
    • Indexers
      • SubQuery
    • OraichainEVM
      • Getting started
      • Smart Contracts
        • Oraichain EVM Precompiled Contracts
        • Address
        • Bank
        • Wasm
        • Authz
      • Guides
        • Metamask
        • Remix
        • Foundry
        • Hardhat
        • Tools
        • Oraichain EVM RPC
  • GOVERNANCE
    • Privacy Policy
  • NODES & VALIDATORS
    • Networks
      • Joining Mainnet
        • Build Linux binary from source and become a Sentry Node Operator
        • Become a Validator
      • Joining Testnet
        • Become Testnet Fullnode From Source
        • StateSync Testnet
        • Faucet Testnet
    • Oraichain Tutorials
      • Migrate one Oraichain node to another
      • Cosmovisor
      • Update validator image
      • Tenderduty
      • Grafana
      • Tracking Unvoted Proposals
      • Tmtop
Powered by GitBook
On this page
  • Common terminology
  • Quickly TON blockchain
  • Consensus algorithm
  • Smart Contracts
  • Development concept
  • Best practices
  • References

Was this helpful?

Edit on GitHub
  1. DEVELOPER GUIDES
  2. OraiDEX
  3. OBridge
  4. TON Bridge

TON Blockchain 101

PreviousTON BridgeNextDecentralization

Last updated 9 months ago

Was this helpful?

🎯 This document attempts to summarize key concepts of TON blockchain. Articulated during process of making TON Bridge by Oraichain Labs developers

Common terminology

Term
Definition

TON actor

Like “smart contract”. Even user wallets are contracts. Actor properties (including but not limited to): Unique address; Code; Data ; Balance

Transaction

A set of steps to modify actor’s properties. Transactions are ordered.

Chain

Sequence of transactions

AccountChain

Sequence of transactions for a single address

Blocks

Batch a set of transactions

ShardChain

A set of blocks including transactions of a set of accounts. Can merge (aggregate) or split ShardChains. Allow up to 2^60 shard chains

Blockchain (called Workchain)

An aggregation of ShardChains with common set of rules. Ton allows many blockchains with diff set of rules (2^32 blockchains)

MasterChain

Chain for multichain state checkpoint. Masterchain blocks - blocks of the masterchain that include shard blocks of different workchains within a logical time (lt) range. A masterchain block does not include all shard blocks of a workchain, but only the highest-seqno shard block in that lt range. Masterchain is also a workchain with wc = -1

Key block

Key block is a masterchain block containing prev, cur, and next validator sets

Quickly TON blockchain

Consensus algorithm

💡 Refer to for detail

  1. Ton uses BFT → each block should have > 2/3 voting power

  2. Split consensus into multiple validation sessions

    1. Each session lasts about 18 hours (config params #15 in base 10)

    2. An election round is created to start a new session

      1. Election process takes around 7 hours (also config params #15)

      2. Send TON using special tx to election contract to participate

      3. After an election, has 2 hours before the session starts (also config params #15) → refund TON if not elected & show list of next validators when querying config & keyblock

  3. Number of validators (config params #16 in base 10)

    1. Has a maximum global number of validators (current is 400 vals)

    2. Has a maximum main number of validators for each session. Current is 100 main vals. Chosen from the pool of max validators (pseudorandom)

    3. Main validators validate masterchain blocks

    4. The rest validate shard blocks

    5. Validators of each block is pseudorandom, but best effort to pick as many as possible.

Smart Contracts

  • Components: <workchain_id (1 byte)><account_id (32 bytes)>

  • Account ID : sha256(compiled_code, initital_state)

  • User friendly version (36 bytes): <flags (1 byte)><workchain_id><account_id><verification (2 bytes)>

    • flag - isBounceable (if cannot send to then “bounce” fund back to sender); isTestnetOnly, isUrlSafe

    • verification - CRC16-CCITT signature from the previous 34 bytes

    • Then we base64(36 bytes) to get friendly address

Development concept

💡 On TON, everything consists of cells, including contract code, stored data, blocks, achieving streamline and robust flexibility in the process.

Cells

  • max = 1023 bits per cell

  • max 4 references to other cells

  • No circular ref with

  • Form DAG

  • 5 types of cells

Bag of Cells (BoC)

  • Serializing cells into bytes arrays

  • Contracts send BoC to others

TL-B (Type Language - Binary)

💡 Serves to describe the type system, constructors and existing functions. E.g TL-B schemes used to build binary structures associated with TON Blockchain

Ton FunC tutorials:

💡 A high-level language FunC is used to program smart contracts on TON: domain-specific, C-like, statically typed language.

  1. FunC standard library

Best practices

References

are entities in Ton for data storage.

is a data format to

Language:

Type:

The TON Blockchain is based on PoS consensus
Cells
Bag of Cells
TL-B
TL-B Types
Learning FunC
Contract Sharding
En:Free TON Wiki | Freeton Wiki | Fandom
Popular TON community libraries
The TON Blockchain is based on PoS consensus.md
TL-B Language
TL-B Types
TON Func Lessons
FunC Standard Libraries
TON Network chain config