{"id":26501,"library":"transpiler-solidity","title":"transpiler-solidity","description":"A Node.js-based transpiler that adds GCC-like macro and helper functions to Solidity assembly code, enabling cleaner pointer arithmetic, struct attribute access, byte offsets, and data packing/unpacking directly in inline assembly blocks. Current stable version is 1.1.2. Development appears low-activity, with no recent releases after v1.1.0. It differentiates by providing C-style macros (#define TRANSPILE) that expand to optimized Solidity assembly, reducing manual storage slot calculations. Requires gcc and Node.js. Not widely adopted, and likely only useful for advanced Ethereum developers working with low-level storage optimizations.","status":"active","version":"1.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/sambacha/transpiler-solidity","tags":["javascript","transpiler","solidity","assmbly","ethereum"],"install":[{"cmd":"npm install transpiler-solidity","lang":"bash","label":"npm"},{"cmd":"yarn add transpiler-solidity","lang":"bash","label":"yarn"},{"cmd":"pnpm add transpiler-solidity","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime requirement: gcc is needed for preprocessing macros (notably #define).","package":"gcc","optional":false}],"imports":[{"note":"The package does not export a default module; it is a CLI tool. The import examples are illustrative for hypothetical programmatic use; actually, it's invoked via command line.","wrong":"const transpiler = require('transpiler-solidity')","symbol":"transpilerSolidity","correct":"import transpilerSolidity from 'transpiler-solidity'"},{"note":"pointer is a macro that expands in Solidity assembly. It is not a JavaScript export. The package is a CLI transpiler, not a library.","wrong":"import { pointer } from 'transpiler-solidity'","symbol":"pointer","correct":"// Used in .sol files with #define TRANSPILE, not a JS import"},{"note":"Requires the literal #define TRANSPILE marker in source code. Without it, the transpiler passes the file unchanged.","wrong":"// forgetting to add #define TRANSPILE causes no expansion","symbol":"#define TRANSPILE","correct":"Place #define TRANSPILE at top of .sol file to enable macro processing"}],"quickstart":{"code":"npm install -g transpiler-solidity\n# Create a Solidity file with GCC-style macros\necho 'pragma solidity 0.5.7;\n#define TRANSPILE\ncontract Ex {\n  struct Item { uint64 a; uint64 b; }\n  Item item;\n  function foo() public {\n    assembly {\n      let b_ptr := pointer_attr(Item, item_slot, b)\n      let b := sload(b_ptr)\n      sstore(b_ptr, add(b, 1))\n    }\n  }\n}' > example.sol\ntranspiler-solidity example.sol > output.sol\n# output.sol contains expanded assembly","lang":"javascript","description":"Shows installation, writing a source file with #define TRANSPILE and a pointer_attr macro, and running the transpiler to produce expanded Solidity assembly."},"warnings":[{"fix":"Add #define TRANSPILE at the top of your .sol file before any contract definitions.","message":"Missing #define TRANSPILE: If the source file does not contain #define TRANSPILE, the transpiler outputs the input unchanged without any macro expansion.","severity":"gotcha","affected_versions":"all"},{"fix":"Use pragma solidity 0.5.7; or adjust the output to match your compiler version.","message":"pragma solidity version must be 0.5.7 or compatible: The documentation and examples use version 0.5.7; newer Solidity versions may have incompatible assembly syntax.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider whether this tool is still maintained; alternatives may involve hand-optimizing assembly or using other transpilers.","message":"Package has low activity: Last release was v1.1.0 and there have been no recent updates. May not work with latest Node.js or Solidity versions.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Install gcc (e.g., apt-get install gcc on Ubuntu, brew install gcc on macOS).","message":"Requires gcc: The transpiler calls gcc for preprocessing; missing gcc will cause errors on certain macros.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `npm install -g transpiler-solidity` or `npm install transpiler-solidity` in your project.","cause":"Package not installed globally or locally.","error":"Error: Cannot find module 'transpiler-solidity'"},{"fix":"Install gcc (e.g., `apt install gcc` on Debian/Ubuntu, `xcode-select --install` on macOS).","cause":"gcc is not installed or not in PATH.","error":"gcc: command not found"},{"fix":"Run `transpiler-solidity input.sol > output.sol` and compile output.sol instead.","cause":"The .sol file contains #define TRANSPILE but the transpiler hasn't been run; Solidity compiler doesn't accept #-preprocessor directives.","error":"SyntaxError: Unexpected token '#'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}