npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ton-assembly-test-dev

v0.0.19

Published

TON assembler and disassembler

Readme

TON Assembly

This repository contains an assembler and disassembler implementation for TVM bitcode.

This implementation provides a complete cycle Text -> Internal representation -> Cells -> BoC -> Cells -> Internal representation -> Text, this means that the same text assembly can be obtained from a text assembly, going through all the compilation and decompilation steps.

The assembler correctly handles cases where the code does not fit into a single cell and automatically creates a separate reference for the remaining code. Current implementation optimizes cases where the reference can be folded into more efficient instructions (e.g. IF into IFREF), thereby optimizing gas consumption.

During compilation, the assembler collects additional mappings that can be used to convert the TVM log into a full trace that will refer to specific instructions in the decompiled version of the contract.

This mapping looks like this:

cell-hash + offset -> instruction

This implementation is able to generate a coverage report for the contract by BoC and logs from Sandbox. The proof of concept can be found in the ./src/coverage folder.

instructionNameForOpcode() function can be used to get the name of the instruction for a given opcode, which is useful for runtime debugging with TVM since TVM itself provides only integer opcodes.

CLI Tools

This package includes two command-line utilities for working with TON Assembly:

Assembler

Compile TVM Assembly files to BOC format:

# Install globally
npm install -g ton-assembly

# Use the assembler
tasm contract.tasm -o contract.boc

# Or via yarn scripts
yarn assembler contract.tasm -o contract.boc

Disassembler

Disassemble BOC files back to TVM Assembly:

# Use the disassembler
tdisasm contract.boc -o contract.tasm

# Or via yarn scripts
yarn disassembler contract.boc -o contract.tasm

Both tools support multiple output formats (binary, hex, base64) and provide verbose output options.

Example Usage

# Compile assembly to BOC
tasm contract.tasm -o contract.boc --verbose

# Disassemble BOC back to assembly
tdisasm contract.boc -o decompiled.tasm --verbose

# Full round-trip test
tasm decompiled.tasm -o recompiled.boc
# contract.boc and recompiled.boc should be identical!

# Work with different formats
tasm contract.tasm -f hex > contract.hex
tdisasm contract.hex -f hex -o contract.tasm

# Assemble from string directly
tasm -s "PUSHINT_4 1" -f hex

# Disassemble from hex/base64 strings directly
tdisasm -s "b5ee9c72410102010027000114ff008e83f4a413ed43d901002fa64ce73b5134348034c7f487f4fffd0115501b05485b1460ec17065c" -f hex -o contract.tasm
tdisasm -s "te6cckEBAgEAJwABFP8AjoP0pBPtQ9kBAC+mTOc7UTQ0gDTH9If0//0BFVAbBUhbFGDsFwZc" -f base64

See CLI documentation for detailed usage instructions.

Library Usage

In addition to the CLI tools, this package can be used as a library for programmatic compilation, decompilation, and log tracing.

For detailed information, see the API Documentation.

Validity

The assembler was tested on 106k contracts from the blockchain where it successfully decompiled and compiled all contracts into equivalent Cells.

License

This project is licensed under the MIT License — see the LICENSE file for details.

MIT © TON Studio.