# SDKs (/applications/sdks) There are several ways to interact with TON blockchain: * **HTTP** libraries connect through HTTP JSON APIs to read and write to the blockchain. HTTP servers mostly relay these requests to the ADNL network. * **ADNL** libraries connect to [liteserver](/blockchain-basics/nodes/overview#interacting-with-ton-nodes). Here's a small comparison of these protocols: | | HTTP | ADNL | | ---------------------------------------------------- | --------------- | --------------- | | Standardized | No | Yes | | Can connect from a web page | Yes | No | | Has free third-party servers | Yes | Yes | | Can be self-hosted | Yes | Yes | | Requires trusting third parties | Yes1 | No | | First connection takes time for data synchronization | No | Yes2 | 1 Some HTTP servers do provide proofs, but there is no out‑of‑the‑box library that verifies them.
2 If proofs returned by liteservers are ignored, the first connection skips data synchronization; however, this requires trusting the liteserver. SDKs might also provide some other functionality: * **Core** libraries implement standard TON data structures (cell, slice), formats (address, mnemonic), cryptography, etc. * **Wrappers** provide high-level APIs for interacting with standard contracts (Wallet, Jetton, NFT). * **Emulator** libraries provide an execution environment similar to a real blockchain for testing purposes. | | | HTTP | ADNL | Core | Wrappers | Emulator | Language | | | | | - | ---------------------------------- | ---- | ---- | ---- | -------- | -------- | ---------- | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------- | | ⭐ | `@ton/ton` | ✅ | | | ✅ | | TypeScript | [Code](https://github.com/ton-org/ton) | | [Chat](https://t.me/tondev_eng) | | ⭐ | `@ton/core` | | | ✅ | | | TypeScript | [Code](https://github.com/ton-org/ton-core) | [Docs](https://ton-org.github.io/ton-core/) | | | ⭐ | `@ton/sandbox` | | | | | ✅ | TypeScript | [Code](https://github.com/ton-org/sandbox) | | | | ⭐ | `ton4j` | ✅ | | ✅ | | ✅ | Java | [Code](https://github.com/neodix42/ton4j) | | [Chat](https://t.me/ton4java) | | ⭐ | `tonutils-go` | | ✅ | ✅ | ✅ | | Go | [Code](https://github.com/xssnick/tonutils-go) | | [Chat](https://t.me/tonutils) | | ⭐ | `tonutils` | ✅ | ✅ | ✅ | ✅ | | Python | [Code](https://github.com/nessshon/tonutils) | [Docs](https://tonutils.ness.su/) | [Chat](https://t.me/pythonnton) | | | `adnl` | | ✅ | | | | TypeScript | [Code](https://github.com/tonkite/adnl) | | | | | `tonutils` | | ✅ | | | | TypeScript | [Code](https://github.com/thekiba/tonutils) | | | | | `tonlib-java` | | ✅ | | | | Java | [Code](https://github.com/ton-blockchain/tonlib-java) | | | | | `tonlib` | | ✅ | | | | C++ | [Code](https://github.com/ton-blockchain/ton/tree/master/tonlib) | [Docs](https://github.com/ton-blockchain/ton/tree/master/example/cpp) | | | | `ton-kotlin` | | ✅ | ✅ | | | Kotlin | [Code](https://github.com/ton-community/ton-kotlin) | [Docs](https://github.com/ton-blockchain/ton-kotlin/wiki/TON-Kotlin-documentation) | | | | `pytonlib` | | ✅ | | | | Python | [Code](https://github.com/toncenter/pytonlib) | | | | | `pytoniq` | | ✅ | | | | Python | [Code](https://github.com/yungwine/pytoniq) | [Docs](https://yungwine.gitbook.io/pytoniq-doc/) | [Chat](https://t.me/pythonnton) | | | `pytoniq-core` | | | ✅ | | | Python | [Code](https://github.com/yungwine/pytoniq-core) | [Docs](https://yungwine.gitbook.io/pytoniq-doc/) | [Chat](https://t.me/pythonnton) | | | `mytonlib` | | ✅ | ✅ | | | Python | [Code](https://github.com/igroman787/mytonlib) | | | | | `tonpy` | | | ✅ | | | Python | [Code](https://github.com/disintar/tonpy) | [Docs](https://tonpy.dton.io/) | | | | `tvm_valuetypes` | | | ✅ | | | Python | [Code](https://github.com/toncenter/tvm_valuetypes) | | | | | `pytvm` | | | | | ✅ | Python | [Code](https://github.com/yungwine/pytvm) | | | | | `tongo` | | ✅ | ✅ | ✅ | ✅ | Go | [Code](https://github.com/tonkeeper/tongo) | | | | | `ton` | ✅ | | | | | PHP | [Code](https://github.com/olifanton/ton) | | | | | `interop` | | | ✅ | | | PHP | [Code](https://github.com/olifanton/interop) | | | | | `ton-rs` | | ✅ | ✅ | ✅ | ✅ | Rust | [Code](https://github.com/ston-fi/ton-rs) | | | | | `ton-grpc` | | ✅ | | | | Rust | [Code](https://github.com/getgems-io/ton-grpc) | | | | | `tonsdk.net` | | ✅ | ✅ | | | C# | [Code](https://github.com/continuation-team/TonSdk.NET) | | [Chat](https://t.me/cont_team/104) | | | `tonlib.net` | | ✅ | ✅ | ✅ | | C# | [Code](https://github.com/justdmitry/TonLib.NET) | | | | | `ton` | | | ✅ | | | Elixir | [Code](https://github.com/ayrat555/ton) | | | | | `@tetherto/wdk-wallet-ton` | ✅ | | | ✅ | | JavaScript | [Code](https://github.com/tetherto/wdk-wallet-ton) | [Docs](https://github.com/tetherto/wdk-docs/tree/main/sdk/wallet-modules/wallet-ton) | | | | `@tetherto/wdk-wallet-ton-gasless` | ✅ | | | ✅ | | JavaScript | [Code](https://github.com/tetherto/wdk-wallet-ton-gasless) | [Docs](https://github.com/tetherto/wdk-docs/tree/main/sdk/wallet-modules/wallet-ton-gasless) | | | | ~~`tonlib-go`~~ | | ✅ | | | | Go | [Code](https://github.com/ton-blockchain/tonlib-go) | | | | | ~~`tonweb`~~ | ✅ | | | | | JavaScript | [Code](https://github.com/toncenter/tonweb) | | | | | ~~`node-tonlib`~~ | | ✅ | | | | JavaScript | [Code](https://github.com/labraburn/node-tonlib) | | | | | ~~`tontools`~~ | ✅ | ✅ | | | | Python | [Code](https://github.com/yungwine/TonTools) | | | | | ~~`swiftyton`~~ | | ✅ | | | | Swift | [Code](https://github.com/labraburn/SwiftyTON) | | | | | ~~`tonlib-xcframework`~~ | | ✅ | | | | Swift | [Code](https://github.com/labraburn/tonlib-xcframework) | | | | | ~~`tonlib-rs`~~ | | ✅ | ✅ | ✅ | ✅ | Rust | [Code](https://github.com/ston-fi/ton-rs) | | | See also: * [WDK Core](https://github.com/tetherto/wdk-core), JavaScript - Modular library from Tether, which supports wallet management and various swap, bridge, and lending services for many blockchains at once. # Core concepts (/blockchain-basics/core-concepts) ## TON overview [#ton-overview] *TON* is a [blockchain](https://en.wikipedia.org/wiki/Blockchain). It provides a distributed platform for storing data and code, as well as running computations, all the ingredients to host applications. Roughly speaking, it works as if it were a single server executing all the code. The hosted applications are called *smart contracts*. The platform runs on a set of servers, called [nodes](/blockchain-basics/nodes/overview). Most important type of nodes, *validators*, are owned by individuals or organizations with a large stake in TON and [great interest](/blockchain-basics/nodes/staking/overview) in keeping the platform safe, fair, and operational. Validators have to reach [consensus](https://en.wikipedia.org/wiki/Consensus_\(computer_science\)) on the state of the blockchain. Typically, the process takes 5 seconds to reach [transaction finality](/blockchain-basics/payments/overview#transaction-finality), a time to mint a new block. ## Network communication [#network-communication] The nodes that run the blockchain interact via the [ADNL](/blockchain-basics/whitepapers/ton#3-1-abstract-datagram-network-layer) protocol. User-facing applications usually use [servers](/applications/api/overview) that proxy JSON HTTP requests into the ADNL network. The official version of such a proxy server is provided by the [liteserver](/blockchain-basics/nodes/overview#full-node-modes) software. There are public instances of liteserver, so developers are not required to host one on their own servers. ## Toncoin and fees [#toncoin-and-fees] *Toncoin* is TON's primary [cryptocurrency](https://en.wikipedia.org/wiki/Cryptocurrency). It is used to pay for the execution of smart contracts, the storage of their data, and network traffic. Such payments are called [fees](/blockchain-basics/primitives/fees). ## Mainnet and testnet [#mainnet-and-testnet] There are two instances of TON blockchain: mainnet and testnet. *Mainnet* is the "real" network. It's where actual payments in Toncoin are made. Applications use the mainnet by default. The other network is *testnet*, and it is used by TON developers to check that their applications work correctly before deploying them to mainnet. It uses "test coins" that barely have any value. Usually, when the TON blockchain gets an update, it is first deployed to testnet, and then to mainnet after a brief period of testing, so sometimes they may run different software. Also, their [configuration](/blockchain-basics/primitives/config), availability, and throughput might be different. ## Workchains and shards [#workchains-and-shards] Each network is split into [workchains](/blockchain-basics/primitives/shards) that can freely interact with each other, but their implementations may differ significantly. At the moment, there are two workchains: *basechain* (`workchain_id = 0`) for regular use, and a very similar *masterchain* (`workchain_id = -1`) for TON's [internal](/blockchain-basics/payments/overview#transaction-finality) [bookkeeping](/blockchain-basics/primitives/system). The masterchain follows mostly the same rules, except that using it is more expensive to limit the amount of traffic that interferes with TON's internals. To be freely scalable, each workchain is split into *shards*. The number of shards is [determined dynamically](/blockchain-basics/primitives/shards) based on the current network load. Internally, every shard is implemented as a separate blockchain. Except for increased latency, the effect on the user-facing code is minimal. ## Accounts [#accounts] It's easiest to visualize the blockchain as a set of [accounts](/blockchain-basics/primitives/addresses/overview). Each account has an address and a status. ### Account statuses [#account-statuses] Over its lifetime, an account changes its [status](/blockchain-basics/primitives/status) among four values: * `nonexist`: There wasn't a single operation with the account, or it was removed. It has neither a balance, nor code. * `uninit`: If some Toncoin is transferred to an account, it now exists, but there is still no smart contract code on it. It now has a balance. * `active`: After a deploy message (see below) with code and initial data is sent to an account, it becomes active and can process other messages. It now has a balance, code, and internal state. * `frozen`: If an account is overdue on its [storage fees](/blockchain-basics/primitives/fees#storage-fee), it will be frozen until the fees are paid. If the overdue amount reaches a maximum limit specified by the blockchain, the account goes completely bankrupt, is removed, and ceases to exist. ### Smart contracts [#smart-contracts] The *code* on an active account is a smart contract. The term *contract* is often used for an account that holds the code.
Statuses overview
### Account addresses [#account-addresses] The [internal address](/blockchain-basics/primitives/addresses/overview#internal-addresses) of an account is a pair of two numbers: its workchain ID and a 256-bit number. It may be displayed in the [raw format](/blockchain-basics/primitives/addresses/formats) (e.g., `0:4098805d2272a61b375350c6b2f5faaaf27c8267d8e7521ff2045104fdc7de76`), but is usually shown in a user-friendly format (e.g., `UQBKgXCNLPexWhs2L79kiARR1phGH1LwXxRbNsCFF9doczSI`). ## Messages [#messages] Addresses specify where [messages](/blockchain-basics/primitives/messages/overview) should be delivered. There are three types of messages: * [internal](/blockchain-basics/primitives/messages/internal) messages are sent between accounts; * [incoming external](/blockchain-basics/primitives/messages/external-in) messages are sent from code outside the blockchain to a contract; * [outgoing external](/blockchain-basics/primitives/messages/external-out) messages are broadcast to the external network; somewhat similar to adding them into the globally available list of all outgoing external messages that ever happened. Every internal message should have some Toncoin attached to it so that it can pay for the cost of handling it. External messages cannot have Toncoin attached to them because they spend some of their time outside the blockchain, and only the blockchain can prove the transfer of Toncoin is correct. Incoming external messages come from an external address, and outgoing external messages go to an external address. The *state* of the account changes only when it handles messages. Messages also change the account's balance. Usually, to have a state and a balance, and to handle messages, the account must be `active`. ## `StateInit` [#stateinit] A message might also be a [deploy message](/blockchain-basics/primitives/messages/deploy) if it has a `StateInit` structure attached with its initial code and data. When such a message is sent, the hash of `StateInit` must match the destination address. If it does, the code and data are stored in the account at that address, and the account becomes active. Both the code and data stored in the account may change in the future, but its address will remain the same as when it was originally deployed. ## Transactions [#transactions] Formally, a message is only an intent: it has a destination, possibly some Toncoin, and data. After the message is handled and all the necessary changes are applied to the blockchain, the message is packed, along with a description of those changes, into a single packet of data, called a [transaction](/blockchain-basics/primitives/messages/ordinary-tx). A transaction records the state changes on an account. [Some transactions](/blockchain-basics/primitives/messages/overview#transactions) might happen without any message. ## TON Virtual Machine [#ton-virtual-machine] Internal and incoming external messages execute the account's code. The code is interpreted by [TON Virtual Machine](/blockchain-basics/tvm/overview) (TVM). It is written in *bitcode*, a binary format specific to TVM. In the future, TVM might support multiple binary languages, *codepages*, but at the moment there is only codepage 0 (`CP0`). ### Phases [#phases] When execution [starts](/blockchain-basics/tvm/initialization), the message and current account state are provided to the code. By the end of execution, the account might change its state or code, or send internal or outgoing external messages. The execution follows a process whose steps are called [phases](/blockchain-basics/primitives/phases). [Fees](/blockchain-basics/primitives/fees) are deducted during this process. Fees might be deducted from the account's balance or from the Toncoin the message carries, depending on the [mode](/blockchain-basics/primitives/messages/modes) of the message, or by [explicit choice](/blockchain-basics/primitives/messages/external-in#accepting-message) made in the contract's code. ### Gas [#gas] Execution cost is first measured in *gas* units, then converted to Toncoin. This unit is separate so that if code execution becomes computationally cheaper (or more expensive), validators can vote to change the [price of gas](/blockchain-basics/primitives/config#param-20-and-21:-gas-prices) in Toncoin. ### Exit codes [#exit-codes] If something goes wrong, a non-zero [exit code](/blockchain-basics/tvm/exit-codes) might be returned, no changes to state or code are saved, and no further messages are sent. If the message that resulted in a failed transaction is marked as *bounceable*, a [bounce message](/blockchain-basics/primitives/messages/internal#bounces) is sent back to the sender. Bounce messages are used to inform the sender that handling of their message failed. They can carry either truncated or full body of the original message. ## Traces [#traces] The most common reason a code is executed is when some account has received a message. Internal messages can only be sent by another contract executing some code, and that contract must have received a message from somewhere too. In the end, every message can be considered part of some *trace*: a tree of messages between accounts that starts with an incoming external message, continues with internal messages, and possibly ends with some outgoing external messages. ### Asynchronous execution [#asynchronous-execution] When some interaction with the blockchain involves multiple contracts, their code is not executed in the same block. Contracts have to exchange messages with each other, and two such concurrent traces may interleave their messages. This fact is usually referred to as "*asynchronous* message handling." This feature of TON allows a limit to be placed on the maximum complexity of atomic computation and aids its scalability, but it is important to keep it in mind because it might create [race conditions](/blockchain-basics/contract-dev/techniques/security#race-condition-of-messages). ## Languages [#languages] Most development is done in [Tolk](/blockchain-basics/tolk/overview), a high-level programming language. Its compiler is included in the [Acton](https://ton-blockchain.github.io/acton/docs/welcome) development environment. Originally, [Fift](/blockchain-basics/languages/fift/overview), a Forth-like assembly language, and [FunC](/blockchain-basics/languages/func/overview), a C-like intermediate-level language, were the first languages for TON smart contract development. ## Get methods [#get-methods] If an external service needs to extract data from the blockchain, it can call a [get method](/blockchain-basics/tvm/get-method): an arbitrary function implemented in the code deployed to an account. Every call of a get method spawns a separate instance of TVM. Any changes to the blockchain made during the execution of a get method are not committed to the blockchain. Unlike in [other blockchains](/overview/learn-more/from-ethereum), get methods cannot be called by other contracts. It is intentional for several reasons: * by the time another contract receives the result of such a call, other messages may have been processed and may have changed the result; * get methods are executed completely separately, and changes from the blockchain are not guaranteed to be propagated to the server running the code of a get method. ## Wallets [#wallets] The main user of incoming external messages is a [wallet](/blockchain-basics/standard/wallets/how-it-works). A wallet is an account with a specific kind of smart contract deployed on it, which can handle incoming external messages, specifically *transfer* messages. A transfer message is a request to send an internal message to another account. Thus, a wallet transforms incoming external messages to internal messages. ### Wallet contract types [#wallet-contract-types] There are several [implementations](/blockchain-basics/standard/wallets/comparison) of wallets, with varying extra functionality and protection. [`V5R1`](/blockchain-basics/standard/wallets/v5) is the latest official general-purpose wallet. The text below describes only the functionality common to most wallets. ### How wallets work [#how-wallets-work] A transfer message consists of a destination address and, optionally, an internal message, both serialized and signed with a [private key](https://en.wikipedia.org/wiki/Public-key_cryptography). The wallet stores a public key and uses it to check that a transfer message was signed with the corresponding private key. If the check succeeds, it sends that internal message to the destination address. This ensures only the user (or a service) who knows the private key can use the wallet. Private and public keys are generated in a program or service outside the blockchain. Public key is used in a `StateInit` during the deploy, and determines the address of the wallet account. Keypair is usually derived from a set of 24 random words called a [mnemonic](/blockchain-basics/standard/wallets/mnemonics). Before the code of the wallet can be deployed on an account with an incoming external message, some other account has to transfer Toncoin to the wallet account. As external messages cannot have any Toncoin attached to them, if no funds are in the account when it handles an external message, it cannot pay for the message that deploys a wallet. The transfer of Toncoin to a wallet account usually comes from an exchange or another user. In testnet, there is [a bot](/overview/wallets/wallet-apps/get-coins) that sends test coins to an account for free. Usually, a transfer message is sent without an internal message in its payload and only instructs the wallet to transfer some Toncoin to a destination address. This is the reason this type of smart contract is called a wallet. An internal message might be a request to some other contract or even a deploy message that deploys code on other accounts. In this way, a wallet acts as a proxy between a user (or an external service) and the rest of the blockchain. ### Wallet apps [#wallet-apps] End users usually use [wallet apps](/overview/wallets/wallet-apps/web) to create and use wallets. An exchange will usually create a wallet for a user as well. ## Standard contracts [#standard-contracts] The other [important types](/blockchain-basics/standard/tokens/overview) of contracts are * [Jetton](/blockchain-basics/standard/tokens/jettons/overview) tokens roughly correspond to coins and allow developers to mint their own currency; * [NFT](/blockchain-basics/standard/tokens/nft/overview) tokens are similar to tickets: unique items that can be sold; * [SBT](/blockchain-basics/standard/tokens/nft/sbt) tokens are like medals: unique items that can be given to someone but can never be sold or transferred. Many popular contract types have been standardized in [TON Enhancement Proposals](https://github.com/ton-blockchain/TEPs) (*TEP*), mostly describing expected contract interfaces with TL-B schemas. This allows tooling to be reused between similar contracts. For example, explorers detect TEP-standardized contracts and display their binary messages in a user-friendly format, and provide an interface to call their get methods. ## Explorers [#explorers] An [explorer](/overview/infrastructure/explorers/overview) is a type of web app that displays information about the current state of accounts (including wallets, Jettons, and NFTs) and the history of transactions. ## APIs and SDKs [#apis-and-sdks] To interact with wallets, Jettons, and other contracts, data has to be sent through an ADNL or HTTP API into the network. There are several ways to connect: * directly call the API, or * use [an SDK](/applications/sdks) that simplifies working with an API by wrapping its methods in a more user-friendly interface; the most popular TypeScript SDK for this is `@ton/ton`. ## TON Connect [#ton-connect] When an application has to use a wallet to prove the user's identity, it needs access to the wallet's private key. Giving arbitrary applications access to the private key is insecure, as they could perform arbitrary actions with the wallet. To address this, there is the [TON Connect](/applications/ton-connect/overview) set of SDKs that provide interfaces * for an application to perform an action through the wallet app; * for a wallet app to handle these requests. For example, Telegram apps use TON Connect to access a wallet that is integrated into Telegram. ## Data storage model [#data-storage-model] All data on TON is stored as trees of [cells](/blockchain-basics/primitives/serialization/cells): the state of contracts, their code, and messages. Each cell stores up to 1023 bits of data and can have up to 4 *refs* to other cells. Each cell has a hash computed from its bits and refs. Because the hash of a cell that directly or indirectly references itself would require knowing the same hash, creating cyclic data structures is impossible. Standard serialization of such a data structure into a single binary string is the [bag of cells](/blockchain-basics/primitives/serialization/boc) (*BoC*). Compilers of smart-contract programming languages produce a BoC with code. When there is a need to store cells in a file or send them over the network, they are usually serialized into a BoC. ### Binary representation [#binary-representation] To tell other developers how a certain type of data is stored in cells, a [TL-B](/blockchain-basics/languages/tl-b/overview) schema language is used. Its purpose is similar to that of [protocol buffers](https://en.wikipedia.org/wiki/Protocol_Buffers) or [binary templates](https://en.wikipedia.org/wiki/010_Editor#Binary_Templates), but it provides more features for structuring data at the bit level. [There are libraries](/applications/sdks) for assembling data structures out of cells. For TypeScript, the most popular one is [`@ton/core`](https://github.com/ton-org/ton-core). The TL-B schemas for binary representations of messages, transactions, initial contract state, and most other data structures used by the blockchain can be found in the [`block.tlb`](https://github.com/ton-blockchain/ton/blob/master/crypto/block/block.tlb) file in the [TON monorepo](https://github.com/ton-blockchain/ton). TypeScript functions for serializing and deserializing them are provided by the [`@ton/core`](https://github.com/ton-org/ton-core) and [`@ton/ton`](https://github.com/ton-org/ton) libraries. In general, a library that converts data structures between cells and the format native to a programming language, or allows calling contract methods as native functions of the language, is called a *wrapper* or *binding*. For example, functions that deserialize Jetton-related cell data into TypeScript objects can be found in the [`assets-sdk`](https://github.com/ton-community/assets-sdk/blob/5285cd75a97acbb15999e7dfb3b8e4ec9e98b4ed/src/jetton/types/JettonBurnMessage.ts) library. Some high-level programming languages [can generate](/blockchain-basics/languages/tact) bindings from the contract's source code. The "rule of thumb" is that production-grade code should not include low-level manipulation of binary data, and should instead rely on a library with bindings. This reduces the chance of mistakes and ensures the code has more users. With widely reused code, there are more opportunities to detect mistakes, and they are more likely to be fixed quickly. ### Blockchain interaction [#blockchain-interaction] So, to interact with the blockchain, a couple of libraries are usually used: one that handles the connection to the blockchain and another that works with the specific type of data sent over that connection. Not all computation has to be done *on-chain*, i.e., executed inside TVM and paid for with Toncoin. Computing and storing data on the blockchain is significantly more expensive than doing so on a regular CPU. Instead, much of the work can be done in *off-chain* code, in a regular programming language, before or after sending a request to the blockchain. The recommended development practice is to write a TypeScript library that calls contracts implemented in Tolk. # contribute/style-guide-extended (/contribute/style-guide-extended) # TON documentation style guide [#ton-documentation-style-guide] ## 0. Purpose, scope, and normative terms [#0-purpose-scope-and-normative-terms] Purpose. This guide defines the required writing style for all public, developer-facing TON documentation. Its goal is to maximize reading experience and task success: a developer should be able to land on the right page, follow it once, and succeed. This document is intentionally explicit so both humans and automated tools (including LLM reviewers) can apply it consistently. (Why: a single, explicit house style reduces cognitive load, prevents voice drift, and enables reliable human and automated review.) Scope. These rules **MUST** be followed on all pages in the docs site, including, for example: step-by-step/how‑tos, explanations, and references (CLI, TVM, standard contracts, network, config, serialization). Exceptions **MUST** be documented in Style exceptions with owner and expiry. (Why: consistent coverage avoids fragmented micro-styles; documented exceptions stay accountable and temporary.) Normative terms. The keywords **MUST**, **MUST NOT**, **SHOULD**, **SHOULD NOT**, **MAY**, **RECOMMENDED**, and **OPTIONAL** are to be interpreted as described in RFC 2119/8174. (Why: shared semantics eliminate ambiguity about what is mandatory vs. optional.) Definitions (used throughout). * Page — a single documentation article. * Doc type — one of: Step by step, How‑to guide, Explanation, Reference (see [§3](#3-documentation-framework-content-types)). * Snippet — any code or command block. * Partial snippet — a focused excerpt that **MAY** be non‑runnable by itself and **MUST** be labeled as such (see [§10](#10-code-and-command-examples)). * Placeholder — a value the reader must replace; formatted as ``. * Admonition — a callout such as Note, Tip, Important, Caution, or Warning. * Reference anchor — a deep link to a specific item in a reference page (flag, field, error code, and similar items). Out of scope. Editorial process, CI wiring, analytics/metrics, and governance live outside this guide. (This guide is about writing.) (Why: focusing on writing rules keeps this document stable and avoids process churn.) Living document. This guide evolves with the documentation. Editors **MAY** update rules as the information architecture and best practices change. When the guide changes, all existing documentation **MUST** be re-validated against the new rules and updated as needed to keep the docs consistent. (Why: styles must adapt as the product and the information architecture evolve; re-validation prevents long-term drift.) ### Severity model (release‑blocking) [#severity-model-releaseblocking] Legend. \[HIGH] blocks release; \[MEDIUM] warns (non‑blocking); \[LOW] suggestion. Defaults. Unless marked otherwise: MUST/MUST NOT → \[MEDIUM]; SHOULD/SHOULD NOT → \[LOW]; MAY/OPTIONAL/RECOMMENDED → \[LOW]. Global overrides (always \[HIGH]). Safety callouts ([§11](#11-safety-critical-content-blockchain-specific)) when required; secrets in examples; copy/paste hazards (prompts in commands, mixed command+output, hard‑wrapped commands, undefined placeholders); destructive flags without warnings; broken/missing anchors or linking to superseded pages as normative; non‑HTTPS/tracked/unofficial links when official exists; use of `{}`/`[]` placeholders in commands; silent truncation of IDs/addresses. Annotation scope. To keep the doc clean, inline badges are added only to \[HIGH] items; all other items inherit the defaults above. ## 1. Goals and principles (reader‑first, answer‑first) [#1-goals-and-principles-readerfirst-answerfirst] * Intent. Every page exists to help a developer finish a real task quickly and correctly. * Pages **MUST** optimize for clarity, scannability, accuracy, and trust; * Pages **MUST NOT** contain marketing language in technical sections. \[HIGH] * Pages **SHOULD** be answer‑first (solution before theory) and example‑first (real code before exposition). (Why: task‑focused, plain, and scannable pages help readers complete work on the first try; marketing copy and theory up front slow readers and reduce trust.) Principles. 1. Answer‑first. Open with purpose, outcome, and prerequisites. Then show the steps (or the API signature in reference). Background theory moves to its own Explanation page or a brief end section. (Why: leading with the solution shortens time‑to‑success; moving theory prevents detours for readers who just need to act.) Example (good): Goal: “Send a jetton from a web app.” Prerequisites: JS SDK, funded testnet wallet. Steps: 1–5. Verify: expected output. Troubleshoot: common errors. 2. Example‑first and precise. Provide copy‑pasteable snippets with expected output. Use `` values and define them at first use. Avoid unnecessary narrative around code. (Why: runnable, minimal examples remove guesswork; placeholders prevent users from pasting unsafe, hard‑coded values.) 3. Minimal concepts in task pages. Do not front‑load long explanations in step-by-step/how‑tos. Link to a concept page instead. (Why: keeping theory separate avoids cognitive overload; readers can pull background only if they need it.) 4. Single source of truth. Don’t duplicate reference tables in guides. Summarize only what's needed, then link to the reference anchor. (Why: duplication drifts and conflicts; deep links keep guides brief and ensure details stay correct in one place.) 5. Scannability. Prefer short paragraphs (≤ \~5 sentences) and short sentences (\~15–20 words). Use headings, lists, and tables to chunk information. See [§8](#8-readability-and-scannability) for norms and flexibility. (Why: short, well‑chunked text is faster to scan and reduces rereads and errors.) Anti‑patterns (MUST NOT). Vague claims (“blazingly fast”), filler (“simply”, “just”, “obviously”, “please note”), and long theoretical detours in task pages. (Why: vague or padded text wastes time and hides the action; front‑loaded theory blocks progress for users who came to do a task.) ## 2. Audience and assumptions [#2-audience-and-assumptions] Default audience. The primary reader is new to blockchain but experienced in software development. (Why: sets a clear baseline so pages explain TON concepts without re-teaching general programming.) Pages **MUST NOT** re‑teach generic developer skills (e.g., basic shell, Git, Python/JS syntax) unless a step is unusual for TON. (Why: keeps pages focused and shorter; duplicating generic skills adds noise and goes stale quickly.) Declaring prerequisites. Step by step and how‑to pages **SHOULD** include a Prerequisites block at the top. Reference pages **SHOULD** include a one‑line Summary to orient the reader. (Why: consistent placement improves scanning and lets readers self‑select quickly.) ### 2.1 What belongs in Prerequisites [#21-what-belongs-in-prerequisites] Prerequisites are entry conditions: things the reader must have or have done before starting. Each item **MUST** be concrete and verifiable. (Why: readers should be able to check each prerequisite before starting to avoid wasted effort.) Examples of valid prerequisite categories: * **Software already installed** (not installed during the guide). Specify version and link to download page. * **Accounts or access already obtained**: API keys, RPC endpoints, wallet accounts. * **Artifacts from prior work**: `"A deployed contract from [Deploy a counter](/path/to/guide)"`, `"A funded testnet wallet"`. * **Funds or tokens**: "Testnet TON from the [faucet](https://...)". * **Unusual hardware** (only when relevant): "A machine with at least 16 GiB RAM". ### 2.2 What does not belong in Prerequisites [#22-what-does-not-belong-in-prerequisites] * **Obvious assumptions**. You **MUST NOT** list: internet connection, an operating system, a keyboard, a terminal/shell, a browser, a text editor, or similar universal tools. (Why: obvious items waste space and insult reader intelligence.) \[HIGH] * **Things installed or created during the guide**. If step 1 is "Install the SDK", the SDK is **NOT** a prerequisite — the prerequisite is what is needed to install it (e.g., Node.js). You **MUST NOT** list items that the guide itself provides. (Why: listing in‑guide installations as prerequisites confuses readers about what they need beforehand.) \[HIGH] * **Skills or knowledge**. "Familiarity with TypeScript" or "Understanding of smart contracts" are audience statements, not prerequisites. Use a separate "Audience" note for these (e.g., "Audience: Intermediate. Assumes working knowledge of TypeScript and async/await."). You **MUST NOT** mix skills into the Prerequisites list. (Why: skills cannot be "installed" or verified the same way; separating them clarifies what readers need to do vs. know.) \[HIGH] * **Background reading or concept links**. `"Read the [Account model](/foundations/accounts) page first"` belongs in prose or a "Background" section, not Prerequisites. If understanding a concept is truly required, state it as an audience assumption. You **SHOULD NOT** put learning links in Prerequisites. (Why: prerequisites are for artifacts and tools, not reading assignments.) ### 2.3 Version specifications [#23-version-specifications] * Software prerequisites **MUST** specify at least the version tested in the guide. (Why: unversioned requirements cause "works on my machine" failures.) \[HIGH] * Software prerequisites **SHOULD** specify a supported range when known (e.g., "Node.js 20 or later LTS", "Python 3.10+"). (Why: ranges tell readers whether their existing installation works.) * You **MUST NOT** use vague terms like "latest" or "recent version". (Why: "latest" changes over time and provides no actionable information.) \[HIGH] ### 2.4 Links in Prerequisites [#24-links-in-prerequisites] * Each software prerequisite **MUST** link to an official download or installation page, not to the project homepage or documentation root. (Why: readers need to act, not browse; download pages are actionable.) \[HIGH] * For tools with OS‑specific installers, you **MAY** link to a general downloads page that offers all variants. * For TON‑ecosystem tools documented in these docs, link to the internal installation guide if one exists. ### 2.5 Prerequisite examples [#25-prerequisite-examples] Good: ```text Prerequisites: - [Node.js](https://nodejs.org/en/download/) 20 or later LTS - A funded testnet wallet (get testnet TON from the [faucet](https://t.me/testgiver_ton_bot)) - An RPC endpoint — use a public endpoint or get one from [TON Center](https://toncenter.com/) ``` Bad: ```text Prerequisites: - A computer with internet access ← obvious - Node.js ← no version, no link - Install the TON SDK ← installed in the guide, not a prerequisite - Familiarity with JavaScript ← skill, not a prerequisite - Read the [wallets overview](/wallets) ← background reading, not a prerequisite ``` ### 2.6 Audience and skill assumptions [#26-audience-and-skill-assumptions] Pages with advanced requirements **MUST** state them at the top in a separate Audience note, not in Prerequisites. (Why: separating "what you need to have" from "what you need to know" helps readers self‑select.) Example: ```text Audience: Advanced. Assumes understanding of TVM exit codes and TL‑B schemas. See: [TVM exit codes](/blockchain-basics/tvm/exit-codes), [TL‑B overview](/data-formats/tlb). ``` Inclusive/global readers. Use plain, international English; avoid idioms and culture‑specific references. Prefer neutral, inclusive terms (e.g., allowlist/denylist). (Why: idioms and local metaphors confuse non‑native readers; inclusive terms are more precise and avoid unintended exclusion.) ## 3. Documentation framework (content types) [#3-documentation-framework-content-types] Rule. Each page **MUST** be one of the following: Step by step, How‑to guide, Explanation, or Reference. Types **MUST NOT** be mixed on a single page. The chosen type **MUST** be clear from the title and content. (Why: single‑purpose pages are easier to find and follow; mixing types blurs intent and causes duplication.) Small, clearly marked asides (e.g., a 1–2‑step “Verify” box in an Explanation) **MAY** appear when they aid comprehension; the page’s primary type remains unchanged. (Why: tiny, labeled asides help understanding without turning a concept page into a task page.) ### 3.1 What each type means (and looks like) [#31-what-each-type-means-and-looks-like] * Step by step (first success). Single happy path for newcomers. Hand‑holding is **RECOMMENDED**. (Why: one clear path gets novices to a working result quickly; branching early increases drop‑off.) Title style: “Deploy a counter contract on testnet”. (Why: action‑oriented titles set expectations and help search/TOC scanning.) Sections (suggested): Objective → Prerequisites → Steps → Verify → Troubleshoot → Next steps. Keep Next steps minimal (1–3 essential links) or omit when the path is linear. **SHOULD** avoid theory beyond two short bullets; link to an Explanation page. (Why: predictable structure reduces cognitive load; keeping theory brief prevents blocking progress.) * How‑to guide (goal‑oriented procedure). A recipe to achieve a specific outcome. **MUST** be procedural and concise. (Why: readers come for a recipe; extra narrative slows execution and invites errors.) Title style: “How to mint a jetton with the CLI”. (Why: the “How to …” pattern matches search intent and signals page type while staying specific.) Rule: **MUST NOT** embed long background; link to concepts as needed. (Why: avoids duplication and keeps the guide focused; background stays current in one canonical place.) * Explanation (concepts/why). Background, architecture, trade‑offs. **SHOULD** avoid step lists and commands. (Why: separating “why” from “how” improves comprehension and prevents pages from doing two jobs badly.) Title style: “Account model and messages in TON”. (Why: noun‑based titles signal conceptual content and improve browseability.) * Reference (complete, factual). Exhaustive specs for APIs/CLI/SDK/types/errors. Non‑narrative tables and exact semantics. (Why: factual, uniform entries are scannable and machine‑linkable; narrative slows lookups.) Title style: “`tvm.runvm` — interface and exit codes”. (Why: placing the exact identifier in the title improves search and deep linking.) Rule: **MUST** be precise, consistent, and anchor‑linkable. (Why: deep anchors let guides link directly; precision prevents support churn and conflicting copies.) ## 4. Voice and tone [#4-voice-and-tone] Objective. Sound like a helpful expert: professional, precise, and approachable. Use the same voice across all pages. (Why: a consistent, expert tone builds trust and reduces cognitive load; readers know what to expect across the site.) Rules (binding). * Use present tense, active voice, and the imperative mood. Write steps as commands (e.g., “Run the validator.”), not future tense or passive voice. Avoid addressing the reader with “you”. (Why: imperative, active phrasing makes the action clear without personal address and reduces ambiguity in steps.) * Be neutral and inclusive. Avoid slang, idioms, culture‑specific jokes, or hype. (Why: neutral language is easier for non‑native readers and translators, and avoids alienating parts of the audience.) * **MUST NOT** use filler or patronizing words: simply, just, obviously, clearly, please note. Replace with exact instructions (Why: filler wastes time and can sound condescending; precise verbs tell the reader exactly what to do.) * Emojis in prose and headings **MUST NOT** appear. Use clear text or an `