Registry / devops / solc-0.8.1-fixed

solc-0.8.1-fixed

JSON →
library0.8.1jsnpmunverified

JavaScript bindings for the Solidity compiler, enabling Solidity smart contract compilation directly in Node.js or the browser via Emscripten. This version 0.8.1 is a fixed release of the official npm package by the Ethereum Foundation. It provides both a high-level API (uniform `compile` method using Standard JSON I/O) and a low-level API exposing compiler internals. Key differentiators: it wraps the native Solidity compiler, supports imports via callbacks, and the command-line interface (`solcjs`) is not compatible with the native `solc` binary. Major breaking changes include the removal of the old callback-based API since v0.6.0. Regular releases track Solidity compiler versions.

npm install solc-0.8.1-fixed
INSTALL
IMPORT
SIG · SOLC-0.8.1-FIXED
S
solc-0.8.1-fixed
devopsjavascriptv0.8.1
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.

compile
✓ import { compile } from 'solc';
✗ import solc from 'solc';
Default export is not available; use named import. In CommonJS, use const { compile } = require('solc').
solc
✓ import * as solc from 'solc';
✗ import solc from 'solc';
For low-level API access (e.g., solc.compile, solc.semver()), use namespace import. Default import is not supported.
require('solc')
✓ const solc = require('solc');
✗ const { compile } = require('solc');
CommonJS require returns the module with compile, semver, etc. Object destructuring works in Node >= 8.

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

const solc = require('solc'); const input = { language: 'Solidity', sources: { 'test.sol': { content: 'contract C { function f() public { } }' } }, settings: { outputSelection: { '*': { '*': ['*'] } } } }; const output = JSON.parse(solc.compile(JSON.stringify(input))); for (const contractName in output.contracts['test.sol']) { console.log(`${contractName}: ${output.contracts['test.sol'][contractName].evm.bytecode.object}`); }
solcjs --version
Debug
Known issues
breakingThe callback-based API (passing a function as second argument to compile) is removed. Use the object-based interface with `import` callback instead.
fix
Pass an object with `import` and `smtSolver` keys, not a direct function.
affects: >=0.6.0
gotchasolcjs command-line tool is incompatible with the native solc binary and cannot be used with eth.compile.solidity().
fix
Use the native Solidity compiler for RPC-based compilation or switch to solc-js high-level API.
affects: all
gotchaThe `import` callback must be synchronous. Asynchronous filesystem access will cause issues.
fix
Resolve dependencies synchronously or pre-collect them.
affects: all
deprecatedThe `smtSolver` callback may not be supported in future versions.
fix
Avoid relying on SMT solver integration; use external tools.
affects: >=0.6.0
Errors
Common errors & fixes
Error: Requires at least one source file.
solcjs called without specifying a .sol file.
fix
Provide the contract file: solcjs --bin MyContract.sol
Error: solc: TypeError: Cannot read property 'compile' of undefined
Incorrect import: using default import instead of named import in ESM.
fix
Use import { compile } from 'solc'; or const { compile } = require('solc');
Error: Source file requires different compiler version (current compiler is 0.8.1)
Contract pragma does not match installed solc version.
fix
Install the correct solc version matching the pragma, e.g., npm install solc@0.8.1 or pragma solidity ^0.8.0.
Upgrade
Version history
0.8.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
solc-0.8.1-fixed — npm install solc-0.8.1-fixed · libregistry