{"id":26490,"library":"ton-compiler","title":"ton-compiler","description":"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.","status":"active","version":"2.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/ton-core/ton-compiler","tags":["javascript"],"install":[{"cmd":"npm install ton-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add ton-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add ton-compiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"For interacting with compiled contracts (e.g., creating Contract instances, parsing BOC)","package":"@ton/core","optional":true}],"imports":[{"note":"ESM is the default since v2.0.0; CJS require may work but not recommended for Node >= 16.","wrong":"const { compile } = require('ton-compiler')","symbol":"compile","correct":"import { compile } from 'ton-compiler'"},{"note":"Type import for configuring compiler options; optional, can be inferred.","symbol":"CompilerConfig","correct":"import { CompilerConfig } from 'ton-compiler'"},{"note":"Function renamed in v2.0.0 from compileFunc to compileWithFunc; old import will fail.","wrong":"import { compileFunc } from 'ton-compiler'","symbol":"compileWithFunc","correct":"import { compileWithFunc } from 'ton-compiler'"}],"quickstart":{"code":"import { compile } from 'ton-compiler';\nimport { Cell } from '@ton/core';\n\nasync function main() {\n  const sourceCode = `\n#include \"imports/stdlib.fc\";\n() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {\n  ;; do nothing\n}\n`;\n  const result = await compile({\n    targets: ['func'],\n    sources: { 'main.fc': sourceCode },\n    sourcesConfig: { root: 'main.fc' },\n  });\n  const boc = Cell.fromBoc(result.output)[0];\n  console.log('Compiled contract code hash:', boc.hash().toString('hex'));\n}\nmain().catch(console.error);","lang":"typescript","description":"Compiles a minimal FunC contract to BOC and prints its hash."},"warnings":[{"fix":"Use compile instead of compileFunc; pass an object with targets and sources.","message":"v2.0.0 renamed compileFunc to compileWithFunc and changed config shape","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set HTTP_PROXY/HTTPS_PROXY environment variables, or manually download and place binary in node_modules/ton-compiler/bin/.","message":"Binary download may fail behind a proxy","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run npx ton-compiler postinstall or npm rebuild ton-compiler. If still fails, check platform support (linux-x64, darwin-arm64, etc.).","message":"compiler binary not found on install","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Node.js to version 18 or later.","message":"v3.0.0 drops support for Node.js < 18","severity":"breaking","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install: npm install ton-compiler","cause":"Missing dependency or wrong import path","error":"Error: Cannot find module 'ton-compiler'"},{"fix":"Run: npx ton-compiler postinstall. If unsupported, manually add binary or use Docker.","cause":"Platform binary not downloaded or unsupported platform","error":"Error: ENOENT: no such file or directory, stat '/path/to/node_modules/ton-compiler/bin/linux-x64/func'"},{"fix":"Use named import: import { compile } from 'ton-compiler'","cause":"Wrong import (e.g., default import used incorrectly)","error":"TypeError: compile is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}