Registry / serialization / transpiler-solidity

transpiler-solidity

JSON →
library1.1.2jsnpmunverified

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.

npm install transpiler-solidity
INSTALL
IMPORT
SIG · TRANSPILER-SOLIDIT
T
transpiler-solidity
serializationjavascriptv1.1.2
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.

transpilerSolidity
import transpilerSolidity from 'transpiler-solidity'
const transpiler = require('transpiler-solidity')
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.
pointer
// Used in .sol files with #define TRANSPILE, not a JS import
import { pointer } from 'transpiler-solidity'
pointer is a macro that expands in Solidity assembly. It is not a JavaScript export. The package is a CLI transpiler, not a library.
#define TRANSPILE
Place #define TRANSPILE at top of .sol file to enable macro processing
// forgetting to add #define TRANSPILE causes no expansion
Requires the literal #define TRANSPILE marker in source code. Without it, the transpiler passes the file unchanged.

Shows installation, writing a source file with #define TRANSPILE and a pointer_attr macro, and running the transpiler to produce expanded Solidity assembly.

npm install -g transpiler-solidity # Create a Solidity file with GCC-style macros echo 'pragma solidity 0.5.7; #define TRANSPILE contract Ex { struct Item { uint64 a; uint64 b; } Item item; function foo() public { assembly { let b_ptr := pointer_attr(Item, item_slot, b) let b := sload(b_ptr) sstore(b_ptr, add(b, 1)) } } }' > example.sol transpiler-solidity example.sol > output.sol # output.sol contains expanded assembly
Debug
Known issues
gotchaMissing #define TRANSPILE: If the source file does not contain #define TRANSPILE, the transpiler outputs the input unchanged without any macro expansion.
fix
Add #define TRANSPILE at the top of your .sol file before any contract definitions.
affects: all
gotchapragma 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.
fix
Use pragma solidity 0.5.7; or adjust the output to match your compiler version.
affects: all
deprecatedPackage 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.
fix
Consider whether this tool is still maintained; alternatives may involve hand-optimizing assembly or using other transpilers.
affects: >=1.0.0
gotchaRequires gcc: The transpiler calls gcc for preprocessing; missing gcc will cause errors on certain macros.
fix
Install gcc (e.g., apt-get install gcc on Ubuntu, brew install gcc on macOS).
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'transpiler-solidity'
Package not installed globally or locally.
fix
Run `npm install -g transpiler-solidity` or `npm install transpiler-solidity` in your project.
gcc: command not found
gcc is not installed or not in PATH.
fix
Install gcc (e.g., `apt install gcc` on Debian/Ubuntu, `xcode-select --install` on macOS).
SyntaxError: Unexpected token '#'
The .sol file contains #define TRANSPILE but the transpiler hasn't been run; Solidity compiler doesn't accept #-preprocessor directives.
fix
Run `transpiler-solidity input.sol > output.sol` and compile output.sol instead.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
gccrequiredRuntime requirement: gcc is needed for preprocessing macros (notably #define).
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
transpiler-solidity — npm install transpiler-solidity · libregistry