{"id":26367,"library":"scol","title":"solc-js","description":"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.","status":"active","version":"0.8.28","language":"javascript","source_language":"en","source_url":"https://github.com/ethereum/solc-js","tags":["javascript","ethereum","solidity","compiler"],"install":[{"cmd":"npm install scol","lang":"bash","label":"npm"},{"cmd":"yarn add scol","lang":"bash","label":"yarn"},{"cmd":"pnpm add scol","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The package does not provide ES module exports by default; use CommonJS require or configure your bundler to handle CJS.","wrong":"import solc from 'solc';","symbol":"solc","correct":"const solc = require('solc');"},{"note":"The compile function expects a JSON string, not an object. You must stringify the input.","wrong":"solc.compile(input)","symbol":"compile","correct":"solc.compile(JSON.stringify(input))"},{"note":"compileStandardWrapper is the recommended high-level API for versions >=0.6.0. It handles JSON parsing and stringification.","wrong":"const output = solc.compile(input);","symbol":"compileStandardWrapper","correct":"const output = solc.compileStandardWrapper(JSON.stringify(input));"}],"quickstart":{"code":"const solc = require('solc');\nconst input = {\n  language: 'Solidity',\n  sources: {\n    'test.sol': {\n      content: '// SPDX-License-Identifier: MIT\\npragma solidity ^0.8.0;\\ncontract Test { }'\n    }\n  },\n  settings: {\n    outputSelection: {\n      '*': {\n        '*': ['evm.bytecode.object']\n      }\n    }\n  }\n};\nconst output = JSON.parse(solc.compile(JSON.stringify(input)));\nconsole.log(output.contracts['test.sol'].Test.evm.bytecode.object);","lang":"javascript","description":"Compiles a simple Solidity contract using the high-level API and prints the bytecode."},"warnings":[{"fix":"Pass an object with import and/or smtSolver properties instead of separate function arguments.","message":"Since version 0.6.0, compile() only accepts an object for callbacks, not individual callback functions.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Use solcjs for standalone compilation; for Ethereum client integration, install the native solc binary.","message":"The command-line tool solcjs is not compatible with solc from the Solidity package; it cannot be used with eth.compile.solidity() RPC method.","severity":"gotcha","affected_versions":"ALL"},{"fix":"Use synchronous file reads (e.g., fs.readFileSync) or preload all dependencies before compiling.","message":"Import callback must be synchronous; async file reads will not work.","severity":"gotcha","affected_versions":"ALL"},{"fix":"Use solc.compile(JSON.stringify(input), { import: ... }) instead.","message":"compileStandardWrapper is deprecated in favor of compile() with an object callback (since 0.6.0).","severity":"deprecated","affected_versions":">=0.6.0"}],"env_vars":null,"search_vec":"'0.8.28':12 'access':14 'addit':81 'api':60 'bin':28 'binari':24,74 'bind':5 'command':65 'command-lin':64 'compil':9,17,23,47,70,86 'depend':82 'differenti':37 'emscripten':22 'emscripten-compil':21 'entir':77 'ethereum':84 'frequent':32 'high':51 'high-level':50 'i/o':55 'javascript':4,83 'js':3,42 'json':54 'key':36 'level':52,59 'line':66 'low':58 'low-level':57 'nativ':73 'node.js':19,79 'offici':41 'provid':13,62 'releas':31,35 'run':76 'solc':2,10,27 'solc-bin':26 'solc-j':1 'solcj':68 'solid':8,16,34,46,85 'standard':53 'support':48 'tool':67 'track':33 'unlik':71 'use':20 'version':11 'via':18 'without':80 'wrapper':43","created_at":"2026-05-01T13:49:37.079370+00:00","updated_at":"2026-05-01T13:49:37.079370+00:00","problems":[{"fix":"Update the pragma in your .sol file or install a compatible version of solc.","cause":"The Solidity source specifies a different pragma version than the compiler version installed.","error":"Error: CompileError: Source file requires different compiler version (current compiler is 0.8.28+commit.8e4c6f11.Emscripten.clang)"},{"fix":"Run 'npm install solc' in your project directory.","cause":"The package is not installed or path is incorrect.","error":"Error: Cannot find module 'solc'"},{"fix":"Use 'const solc = require('solc');' and ensure you have the latest version installed.","cause":"Using ESM import ('import solc from 'solc'') instead of CommonJS require or incorrect version.","error":"TypeError: solc.compile is not a function"}],"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":"https://docs.soliditylang.org","github":"https://github.com/ethereum/solc-js","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/scol","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"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}}