{"id":26411,"library":"solc-0.8.1-fixed","title":"solc-js","description":"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.","status":"active","version":"0.8.1","language":"javascript","source_language":"en","source_url":"https://github.com/ethereum/solc-js","tags":["javascript","ethereum","solidity","compiler"],"install":[{"cmd":"npm install solc-0.8.1-fixed","lang":"bash","label":"npm"},{"cmd":"yarn add solc-0.8.1-fixed","lang":"bash","label":"yarn"},{"cmd":"pnpm add solc-0.8.1-fixed","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default export is not available; use named import. In CommonJS, use const { compile } = require('solc').","wrong":"import solc from 'solc';","symbol":"compile","correct":"import { compile } from 'solc';"},{"note":"For low-level API access (e.g., solc.compile, solc.semver()), use namespace import. Default import is not supported.","wrong":"import solc from 'solc';","symbol":"solc","correct":"import * as solc from 'solc';"},{"note":"CommonJS require returns the module with compile, semver, etc. Object destructuring works in Node >= 8.","wrong":"const { compile } = require('solc');","symbol":"require('solc')","correct":"const solc = require('solc');"}],"quickstart":{"code":"const solc = require('solc');\nconst input = {\n  language: 'Solidity',\n  sources: {\n    'test.sol': { content: 'contract C { function f() public { } }' }\n  },\n  settings: { outputSelection: { '*': { '*': ['*'] } } }\n};\nconst output = JSON.parse(solc.compile(JSON.stringify(input)));\nfor (const contractName in output.contracts['test.sol']) {\n  console.log(`${contractName}: ${output.contracts['test.sol'][contractName].evm.bytecode.object}`);\n}","lang":"javascript","description":"Compiles a minimal Solidity contract using the high-level API and prints the bytecode."},"warnings":[{"fix":"Pass an object with `import` and `smtSolver` keys, not a direct function.","message":"The callback-based API (passing a function as second argument to compile) is removed. Use the object-based interface with `import` callback instead.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Use the native Solidity compiler for RPC-based compilation or switch to solc-js high-level API.","message":"solcjs command-line tool is incompatible with the native solc binary and cannot be used with eth.compile.solidity().","severity":"gotcha","affected_versions":"all"},{"fix":"Resolve dependencies synchronously or pre-collect them.","message":"The `import` callback must be synchronous. Asynchronous filesystem access will cause issues.","severity":"gotcha","affected_versions":"all"},{"fix":"Avoid relying on SMT solver integration; use external tools.","message":"The `smtSolver` callback may not be supported in future versions.","severity":"deprecated","affected_versions":">=0.6.0"}],"env_vars":null,"search_vec":"'0.8.1':25 'api':46,59,102 'base':101 'binari':89 'bind':5 'break':91 'browser':20 'callback':74,100 'callback-bas':99 'chang':92 'command':78 'command-lin':77 'compat':84 'compil':9,14,48,61,70,109,114 'contract':13 'differenti':64 'direct':15 'emscripten':22 'enabl':10 'ethereum':37,112 'expos':60 'fix':28 'foundat':38 'high':44 'high-level':43 'i/o':53 'import':72 'includ':93 'interfac':80 'intern':62 'javascript':4,111 'js':3 'json':52 'key':63 'level':45,58 'line':79 'low':57 'low-level':56 'major':90 'method':49 'nativ':68,87 'node.js':17 'npm':33 'offici':32 'old':98 'packag':34 'provid':40 'regular':105 'releas':29,106 'remov':95 'sinc':103 'smart':12 'solc':2,88 'solc-j':1 'solcj':81 'solid':8,11,69,108,113 'standard':51 'support':71 'track':107 'uniform':47 'use':50 'v0.6.0':104 'version':24,110 'via':21,73 'wrap':66","created_at":"2026-05-01T13:49:50.126575+00:00","updated_at":"2026-05-01T13:49:50.126575+00:00","problems":[{"fix":"Provide the contract file: solcjs --bin MyContract.sol","cause":"solcjs called without specifying a .sol file.","error":"Error: Requires at least one source file."},{"fix":"Use import { compile } from 'solc'; or const { compile } = require('solc');","cause":"Incorrect import: using default import instead of named import in ESM.","error":"Error: solc: TypeError: Cannot read property 'compile' of undefined"},{"fix":"Install the correct solc version matching the pragma, e.g., npm install solc@0.8.1 or pragma solidity ^0.8.0.","cause":"Contract pragma does not match installed solc version.","error":"Error: Source file requires different compiler version (current compiler is 0.8.1)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"solcjs","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/ethereum/solc-js","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/solc-0.8.1-fixed","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-05-01","next_check":"2026-07-30","install_tag":null}}