Registry / devops / scol
library0.8.28jsnpmunverified

JavaScript bindings for the Solidity compiler (solc). Version 0.8.28 provides access to Solidity compilation via Node.js, using Emscripten-compiled binaries from solc-bin. It is released frequently, tracking Solidity releases. Key differentiators: it is the official JS wrapper for the Solidity compiler, supports both high-level (Standard JSON I/O) and low-level APIs, and provides a command-line tool (solcjs) for compilation. Unlike the native binary, it runs entirely in Node.js without additional dependencies.

npm install scol
INSTALL
IMPORT
SIG · SCOL
S
scol
devopsjavascriptv0.8.28
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.

solc
const solc = require('solc');
import solc from 'solc';
The package does not provide ES module exports by default; use CommonJS require or configure your bundler to handle CJS.
compile
solc.compile(JSON.stringify(input))
solc.compile(input)
The compile function expects a JSON string, not an object. You must stringify the input.
compileStandardWrapper
const output = solc.compileStandardWrapper(JSON.stringify(input));
const output = solc.compile(input);
compileStandardWrapper is the recommended high-level API for versions >=0.6.0. It handles JSON parsing and stringification.

Compiles a simple Solidity contract using the high-level API and prints the bytecode.

const solc = require('solc'); const input = { language: 'Solidity', sources: { 'test.sol': { content: '// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\ncontract Test { }' } }, settings: { outputSelection: { '*': { '*': ['evm.bytecode.object'] } } } }; const output = JSON.parse(solc.compile(JSON.stringify(input))); console.log(output.contracts['test.sol'].Test.evm.bytecode.object);
solcjs --version
Debug
Known issues
breakingSince version 0.6.0, compile() only accepts an object for callbacks, not individual callback functions.
fix
Pass an object with import and/or smtSolver properties instead of separate function arguments.
affects: >=0.6.0
gotchaThe command-line tool solcjs is not compatible with solc from the Solidity package; it cannot be used with eth.compile.solidity() RPC method.
fix
Use solcjs for standalone compilation; for Ethereum client integration, install the native solc binary.
affects: ALL
gotchaImport callback must be synchronous; async file reads will not work.
fix
Use synchronous file reads (e.g., fs.readFileSync) or preload all dependencies before compiling.
affects: ALL
deprecatedcompileStandardWrapper is deprecated in favor of compile() with an object callback (since 0.6.0).
fix
Use solc.compile(JSON.stringify(input), { import: ... }) instead.
affects: >=0.6.0
Errors
Common errors & fixes
Error: CompileError: Source file requires different compiler version (current compiler is 0.8.28+commit.8e4c6f11.Emscripten.clang)
The Solidity source specifies a different pragma version than the compiler version installed.
fix
Update the pragma in your .sol file or install a compatible version of solc.
Error: Cannot find module 'solc'
The package is not installed or path is incorrect.
fix
Run 'npm install solc' in your project directory.
TypeError: solc.compile is not a function
Using ESM import ('import solc from 'solc'') instead of CommonJS require or incorrect version.
fix
Use 'const solc = require('solc');' and ensure you have the latest version installed.
Upgrade
Version history
0.8.28latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
scol — npm install scol · libregistry