PolySol-JS

raw JSON →
1.0.1 verified Fri May 01 auth: no javascript

PolySol-JS is a modular transpiler that converts JavaScript/TypeScript source code into an intermediate JSON representation (IR) and then into Solidity smart contracts. Version 1.0.1 is the current stable release. The project is in early stages with no public npm release, only installation via git clone. Its key differentiators are a standardized IR decoupling parsing from code generation, enabling extensibility to other source languages and target blockchains, and an educational focus on transpiler internals. Alternatives like Sol2Ink compile Solidity to Rust, while PolySol-JS targets Solidity from JS/TS.

error Cannot find module 'polysol-js-core'
cause Package not published to npm; installed via git clone.
fix
Install locally: npm install /path/to/polysol-js
error require() of ES Module not supported
cause Package is ESM-only, CommonJS require() fails.
fix
Use import syntax or set type: 'module' and use import().
error Module 'polysol-js-core' has no exported member 'IRSchema'
cause Importing from main entry instead of subpath 'polysol-js-core/ir'.
fix
Use import { IRSchema } from 'polysol-js-core/ir'
error SyntaxError: Unexpected token 'export'
cause Running as CommonJS without ESM support.
fix
Add "type": "module" to package.json or use .mjs extension.
breaking ESM-only: Package does not support CommonJS require().
fix Use import syntax or configure Node.js for ESM (type: 'module' in package.json).
gotcha Subpath exports: Core symbols are not re-exported from the main entry.
fix Import directly from subpaths like 'polysol-js-core/parser', 'polysol-js-core/generator'.
deprecated No public npm registry: Install via git clone only.
fix Run: git clone https://github.com/your-username/polysol-js.git
gotcha Requires Node.js v14+; older versions will throw syntax errors.
fix Upgrade Node.js to v14 or higher.
gotcha Parser and generator prototypes; actual transpilation is not yet implemented.
fix Check repository roadmap; currently using the IR schema only.
deprecated npm start command may not work due to missing build step.
fix Run 'npm run build' first, then 'npm start' (if scripts are configured).
npm install polysol-js-core
yarn add polysol-js-core
pnpm add polysol-js-core

Shows how to transpile a JS file to Solidity using the modular parser and generator.

import { parseJavaScript } from 'polysol-js-core/parser';
import { generateSolidity } from 'polysol-js-core/generator';
import { readFileSync } from 'fs';

const sourceCode = readFileSync('contract.js', 'utf8');
const ir = parseJavaScript(sourceCode); // returns IR object
const solidityCode = generateSolidity(ir);
console.log(solidityCode);