Registry / devops / ton-compiler

ton-compiler

JSON →
library2.3.0jsnpmunverified

Provides pre-built binaries for compiling TON FunC and Tact smart contracts to Fift and BOC (Bag of Cells) output. Version 2.3.0 supports FunC 0.4.4+ and Tact 1.3.0. Distributed as a npm package wrapping native binaries for major platforms (Linux, macOS, Windows). Updated quarterly alongside TON compiler releases. Key differentiator: eliminates need to manually download or build TON compilers; integrates seamlessly with JavaScript/TypeScript tooling like Blueprint or Tact boilerplate.

npm install ton-compiler
INSTALL
IMPORT
SIG · TON-COMPILER
T
ton-compiler
devopsjavascriptv2.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
import { compile } from 'ton-compiler'
const { compile } = require('ton-compiler')
ESM is the default since v2.0.0; CJS require may work but not recommended for Node >= 16.
CompilerConfig
import { CompilerConfig } from 'ton-compiler'
Type import for configuring compiler options; optional, can be inferred.
compileWithFunc
import { compileWithFunc } from 'ton-compiler'
import { compileFunc } from 'ton-compiler'
Function renamed in v2.0.0 from compileFunc to compileWithFunc; old import will fail.

Compiles a minimal FunC contract to BOC and prints its hash.

import { compile } from 'ton-compiler'; import { Cell } from '@ton/core'; async function main() { const sourceCode = ` #include "imports/stdlib.fc"; () recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure { ;; do nothing } `; const result = await compile({ targets: ['func'], sources: { 'main.fc': sourceCode }, sourcesConfig: { root: 'main.fc' }, }); const boc = Cell.fromBoc(result.output)[0]; console.log('Compiled contract code hash:', boc.hash().toString('hex')); } main().catch(console.error);
Debug
Known issues
breakingv2.0.0 renamed compileFunc to compileWithFunc and changed config shape
fix
Use compile instead of compileFunc; pass an object with targets and sources.
affects: >=2.0.0
gotchaBinary download may fail behind a proxy
fix
Set HTTP_PROXY/HTTPS_PROXY environment variables, or manually download and place binary in node_modules/ton-compiler/bin/.
affects: >=1.0.0
gotchacompiler binary not found on install
fix
Run npx ton-compiler postinstall or npm rebuild ton-compiler. If still fails, check platform support (linux-x64, darwin-arm64, etc.).
affects: >=1.0.0
breakingv3.0.0 drops support for Node.js < 18
fix
Upgrade Node.js to version 18 or later.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'ton-compiler'
Missing dependency or wrong import path
fix
Install: npm install ton-compiler
Error: ENOENT: no such file or directory, stat '/path/to/node_modules/ton-compiler/bin/linux-x64/func'
Platform binary not downloaded or unsupported platform
fix
Run: npx ton-compiler postinstall. If unsupported, manually add binary or use Docker.
TypeError: compile is not a function
Wrong import (e.g., default import used incorrectly)
fix
Use named import: import { compile } from 'ton-compiler'
Upgrade
Version history
2.3.0latest on npm
Audit
Dependencies
@ton/coreoptionalFor interacting with compiled contracts (e.g., creating Contract instances, parsing BOC)
Agent activity
4 hits · last 30 days
node
4
Resources
ton-compiler — npm install ton-compiler · libregistry