Cell
) back into human-readable pseudocode resembling Func/Fift, greatly simplifying contract auditing, verification, and comprehension.
Features
- Decompiles TVM bytecode into structured pseudocode
- Supports complex constructs: dictionaries, global variables, built-in functions, hashes, signatures, and more
- Recovers procedures and methods by their hashes (
?fun_ref_xxx
) - Integrates with
@ton/core
,@ton-community/func-js
, and@scaleton/func-debug-symbols
- End-to-end testing via Vitest with round-trip compilation/decompilation validation
- Generates code hashes for verification (used in Tact contract tests)
Testing and verification
The tool is extensively tested against a wide range of contracts:- Tact contracts: Jetton, NFT, Vesting, Lottery, SkatePassport, and more
- Func contracts:
jetton-minter.fc
,nft-collection.fc
,wallet v3/v4
,stdlib.fc
,mathlib.fc
- Supports contracts compiled via Func, Tact, and Fift
- Correctness of decompilation output
- Re-compilability via Fift
- Hash stability (
exports[...] = "..."
in test snapshots)
Architecture
Core modules
disasm
— TVM instruction disassemblerAssemblyWriter
— generates readable assembly with configurable options:- Instruction aliases (e.g.,
SWAP
instead ofs0 s1 XCHG
) - Inline hex comments (e.g.,
// 0xD0
) - Resolution of procedure and method names
- Instruction aliases (e.g.,
utils/known-methods
— registry of known method IDs and debug symbolse2e/utils
— utilities for compilation and result comparison
Supported TVM instructions
- Arithmetic (
DIVMOD
,LSHIFT
,MULRSHIFTR#
, and more) - Dictionary operations (
DICTGET
,DICTSETB
,DICTDEL
,DICTUREMMIN
, and more) - Stack manipulation (
XCHG
,PUXC
,BLKSWAP
) - Control flow (
IFELSE
,WHILE
,CALLREF
,INLINECALLDICT
) - Cell and slice handling (
CTOS
,STREF
,LDREF
,STSLICECONST
)
Installation and usage
Example usage
For developers
- Tests: Run with
vitest
; cover hundreds of real-world contracts - Specification generation:
npm run gen-spec
- Linting:
eslint
with modern rules - Compatibility: Integrates with
@tact-lang/compiler
andtact-template
License
This project is licensed under the MIT License — free to use, modify, and distribute.Why use it?
- Security auditing: Analyze third-party contracts without source code
- Reverse engineering: Understand the logic of closed-source contracts
- Education: Learn TVM internals and low-level TON contract behavior
- IDE integration: Enable decompilation features in development tools
Note: Decompiled code may not exactly match the original source — variable names and high-level structure can differ — but semantic equivalence is preserved.