ton-tact
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill is based on Tact (TON) v1.6.13, generated 2026-02-25.
Tact is a statically typed smart contract language for the TON blockchain. Contracts use message-based communication (receive/send), structs and messages for data, and traits for reuse. This skill focuses on agent-oriented usage: type system, contracts and receivers, sending/receiving messages, cells and serialization, standard libraries, and security practices.
本Skill基于Tact (TON) v1.6.13版本生成,生成时间为2026-02-25。
Tact是TON区块链的静态类型智能合约语言。合约采用基于消息的通信(接收/发送),使用结构体和消息处理数据,通过Trait实现复用。本Skill聚焦于面向Agent的使用场景:类型系统、合约与接收器、消息收发、Cell与序列化、标准库及安全实践。
Core references
核心参考内容
| Topic | Description | Reference |
|---|---|---|
| Type system | Primitives, optionals, maps, structs, messages, contracts, traits | core-types |
| Contracts and traits | init, parameters, receivers, getters, interfaces, BaseTrait | core-contracts |
| Structs and messages | Definition, instantiation, toCell/fromCell, TL-B layout | core-structs-messages |
| Receiving messages | receive(), text/binary/slice receivers, order, external/bounced | core-receive |
| Sending messages | send(), SendParameters, reply, forward, notify, cashback, deploy, emit | core-send |
| Cells, Builders, Slices | Cell/Builder/Slice, beginCell, store/load, Struct/Message helpers | core-cells |
| Message mode | Base modes and optional flags (SendRemainingValue, SendIgnoreErrors, etc.) | core-message-mode |
| Gas and fees | getStorageFee, getComputeFee, getForwardFee, setGasLimit, acceptMessage | core-gas |
| Context and state | sender, context, myAddress, myBalance, now, inMsg, setData, commit, getConfigParam, nativeReserve | core-context-state |
| Addresses | newAddress, contractAddress, forceBasechain, parseStdAddress, BasechainAddress | core-addresses |
| Cryptography | checkSignature, sha256, keccak256, SignedBundle | core-crypto |
| Strings | StringBuilder, beginString, beginComment, String extensions, Int toFloatString | core-strings |
| Math | min, max, abs, sign, sqrt, log, log2, pow, pow2, divc, muldivc | core-math |
| Exit codes | TVM/Tact exit codes, compute/action phases, developer range 256–65535 | core-exit-codes |
| Random | random, randomInt, getSeed, setSeed, nativeRandomize, nativeRandomizeLt | core-random |
| Debug and throw | require, dump, throw, throwIf, throwUnless | core-debug |
| Compile-time | address(), cell(), slice(), rawSlice(), ascii(), crc32(), ton() | core-comptime |
| Message lifecycle | Receive phase, compute phase, action phase (no revert) | core-lifecycle |
| 主题 | 描述 | 参考链接 |
|---|---|---|
| 类型系统 | 基本类型、可选类型、映射、结构体、消息、合约、Trait | core-types |
| 合约与Trait | 初始化、参数、接收器、获取器、接口、BaseTrait | core-contracts |
| 结构体与消息 | 定义、实例化、toCell/fromCell、TL-B布局 | core-structs-messages |
| 接收消息 | receive()、文本/二进制/Slice接收器、执行顺序、外部/退回消息 | core-receive |
| 发送消息 | send()、SendParameters、回复、转发、通知、现金返还、部署、触发 | core-send |
| Cell、Builder、Slice | Cell/Builder/Slice、beginCell、存储/加载、结构体/消息辅助方法 | core-cells |
| 消息模式 | 基础模式与可选标志(SendRemainingValue、SendIgnoreErrors等) | core-message-mode |
| Gas与费用 | getStorageFee、getComputeFee、getForwardFee、setGasLimit、acceptMessage | core-gas |
| 上下文与状态 | sender、context、myAddress、myBalance、now、inMsg、setData、commit、getConfigParam、nativeReserve | core-context-state |
| 地址 | newAddress、contractAddress、forceBasechain、parseStdAddress、BasechainAddress | core-addresses |
| 密码学 | checkSignature、sha256、keccak256、SignedBundle | core-crypto |
| 字符串 | StringBuilder、beginString、beginComment、字符串扩展、Int转FloatString | core-strings |
| 数学运算 | min、max、abs、sign、sqrt、log、log2、pow、pow2、divc、muldivc | core-math |
| 退出码 | TVM/Tact退出码、计算/执行阶段、开发者自定义范围256–65535 | core-exit-codes |
| 随机数 | random、randomInt、getSeed、setSeed、nativeRandomize、nativeRandomizeLt | core-random |
| 调试与抛出 | require、dump、throw、throwIf、throwUnless | core-debug |
| 编译期特性 | address()、cell()、slice()、rawSlice()、ascii()、crc32()、ton() | core-comptime |
| 消息生命周期 | 接收阶段、计算阶段、执行阶段(不可回滚) | core-lifecycle |
Features
功能特性
| Topic | Description | Reference |
|---|---|---|
| Optionals | T?, null, !!, constraints (no optional keys, no nested optionals) | features-optionals |
| Maps | map<K,V>, emptyMap(), get/set, allowed types, serialization | features-maps |
| initOf and deploy | initOf, contractAddress, StateInit, send/deploy deployment | features-initof-deploy |
| Standard libraries | @stdlib/config, content, deploy, dns, ownable, stoppable | features-stdlib |
| Configuration | tact.config.json — projects, options (debug, external, safety, mode) | features-config |
| External messages | external(), acceptMessage, no sender/context, config external | features-external |
| Constants | const, virtual/abstract/override in traits | features-constants |
| 主题 | 描述 | 参考链接 |
|---|---|---|
| 可选类型 | T?、null、!!、约束条件(无可选键、无嵌套可选类型) | features-optionals |
| 映射 | map<K,V>、emptyMap()、获取/设置、允许的类型、序列化 | features-maps |
| initOf与部署 | initOf、contractAddress、StateInit、发送/部署操作 | features-initof-deploy |
| 标准库 | @stdlib/config、content、deploy、dns、ownable、stoppable | features-stdlib |
| 配置 | tact.config.json — 项目、选项(debug、external、safety、mode) | features-config |
| 外部消息 | external()、acceptMessage、无发送者/上下文、配置外部消息 | features-external |
| 常量 | const、Trait中的virtual/abstract/override | features-constants |
Best practices
最佳实践
| Topic | Description | Reference |
|---|---|---|
| Security | Sensitive data, signed ints, exit codes, random, auth, replay, bounce, excess gas | best-practices-security |
| Gas | Contract params, binary receivers, message/cashback/deploy, sender(), throwUnless, SignedBundle | best-practices-gas |
| 主题 | 描述 | 参考链接 |
|---|---|---|
| 安全 | 敏感数据、有符号整数、退出码、随机数、身份验证、重放攻击、退回消息、多余Gas | best-practices-security |
| Gas优化 | 合约参数、二进制接收器、消息/现金返还/部署、sender()、throwUnless、SignedBundle | best-practices-gas |
Advanced
进阶内容
| Topic | Description | Reference |
|---|---|---|
| Bounced messages | bounced<T>, 224-bit limit, fallback Slice receiver, unrecognized bounces | advanced-bounced |
| 主题 | 描述 | 参考链接 |
|---|---|---|
| 退回消息 | bounced<T>、224位限制、回退Slice接收器、无法识别的退回消息 | advanced-bounced |