{"id":29861019,"url":"https://github.com/ton-blockchain/tasm","last_synced_at":"2025-07-30T04:10:10.163Z","repository":{"id":306250293,"uuid":"1025511783","full_name":"ton-blockchain/tasm","owner":"ton-blockchain","description":"Assembler and disassembler implementation for TVM bitcode in pure TypeScript","archived":false,"fork":false,"pushed_at":"2025-07-24T15:25:44.000Z","size":437,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-24T16:12:53.217Z","etag":null,"topics":["assembler","bitcode","bytecode","disassembler","fift","ton"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ton-blockchain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-24T11:14:43.000Z","updated_at":"2025-07-24T13:08:08.000Z","dependencies_parsed_at":"2025-07-24T16:14:47.812Z","dependency_job_id":"4457520d-f70c-498c-9978-dde3e12c7882","html_url":"https://github.com/ton-blockchain/tasm","commit_stats":null,"previous_names":["ton-blockchain/tasm"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ton-blockchain/tasm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-blockchain%2Ftasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-blockchain%2Ftasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-blockchain%2Ftasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-blockchain%2Ftasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ton-blockchain","download_url":"https://codeload.github.com/ton-blockchain/tasm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ton-blockchain%2Ftasm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267808215,"owners_count":24147388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembler","bitcode","bytecode","disassembler","fift","ton"],"created_at":"2025-07-30T04:10:08.394Z","updated_at":"2025-07-30T04:10:10.135Z","avatar_url":"https://github.com/ton-blockchain.png","language":"TypeScript","readme":"# TON Assembly\n\nThis repository contains an assembler and disassembler implementation for TVM bitcode.\n\nThis implementation provides a complete cycle\n`Text -\u003e Internal representation -\u003e Cells -\u003e BoC -\u003e Cells -\u003e Internal representation -\u003e Text`, this means that the same\ntext assembly can be obtained from a text assembly, going through all the compilation and decompilation steps.\n\nThe assembler correctly handles cases where the code does not fit into a single cell and automatically\ncreates a separate reference for the remaining code.\nCurrent implementation optimizes cases where the reference can be folded into more efficient instructions\n(e.g. `IF` into `IFREF`), thereby optimizing gas consumption.\n\nDuring compilation, the assembler collects additional mappings that can be used to convert the TVM log into a full trace\nthat will refer to specific instructions in the decompiled version of the contract.\n\nThis mapping looks like this:\n\n```\ncell-hash + offset -\u003e instruction\n```\n\nThis implementation is able to generate a coverage report for the contract by BoC and logs\nfrom [Sandbox](https://github.com/ton-org/sandbox).\nThe proof of concept can be found in the [`./src/coverage`](./src/coverage) folder.\n\n`instructionNameForOpcode()` function can be used to get the name of the instruction for a given opcode, which is useful\nfor runtime debugging with TVM since TVM itself provides only integer opcodes.\n\n## CLI Tools\n\nThis package includes two command-line utilities for working with TON Assembly:\n\n### Assembler\n\nCompile TVM Assembly files to BOC format:\n\n```bash\n# Install globally\nnpm install -g ton-assembly\n\n# Use the assembler\ntasm contract.tasm -o contract.boc\n\n# Or via yarn scripts\nyarn assembler contract.tasm -o contract.boc\n```\n\n### Disassembler\n\nDisassemble BOC files back to TVM Assembly:\n\n```bash\n# Use the disassembler\ntdisasm contract.boc -o contract.tasm\n\n# Or via yarn scripts\nyarn disassembler contract.boc -o contract.tasm\n```\n\nBoth tools support multiple output formats (binary, hex, base64) and provide verbose output options.\n\n#### Example Usage\n\n```bash\n# Compile assembly to BOC\ntasm contract.tasm -o contract.boc --verbose\n\n# Disassemble BOC back to assembly\ntdisasm contract.boc -o decompiled.tasm --verbose\n\n# Full round-trip test\ntasm decompiled.tasm -o recompiled.boc\n# contract.boc and recompiled.boc should be identical!\n\n# Work with different formats\ntasm contract.tasm -f hex \u003e contract.hex\ntdisasm contract.hex -f hex -o contract.tasm\n\n# Assemble from string directly\ntasm -s \"PUSHINT_4 1\" -f hex\n\n# Disassemble from hex/base64 strings directly\ntdisasm -s \"b5ee9c72410102010027000114ff008e83f4a413ed43d901002fa64ce73b5134348034c7f487f4fffd0115501b05485b1460ec17065c\" -f hex -o contract.tasm\ntdisasm -s \"te6cckEBAgEAJwABFP8AjoP0pBPtQ9kBAC+mTOc7UTQ0gDTH9If0//0BFVAbBUhbFGDsFwZc\" -f base64\n```\n\nSee [CLI documentation](./src/cli/README.md) for detailed usage instructions.\n\n## Library Usage\n\nIn addition to the CLI tools, this package can be used as a library for programmatic compilation, decompilation, and log\ntracing.\n\nFor detailed information, see the [**API Documentation**](API.md).\n\n## Validity\n\nThe assembler was tested on 106k contracts from the blockchain\nwhere it successfully decompiled and compiled all contracts into equivalent **Cells**.\n\n## License\n\nThis project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.\n\nMIT © [TON Studio](https://tonstudio.io).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fton-blockchain%2Ftasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fton-blockchain%2Ftasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fton-blockchain%2Ftasm/lists"}