Registry / devops / solidity-compiler

solidity-compiler

JSON →
library7.0.1jsnpmunverified

Solidity compiler wrapper and artifactor that provides smart recompilation, project-wide compilation, per-file Solidity version management, and configurable artifact output. Current stable version: 7.0.1. Release cadence: irregular, part of 0x monorepo. Key differentiators: intelligent caching (only recompiles changed contracts), automatic version resolution from pragma statements, and standard input description support for flexible artifacts. Ships TypeScript types. Requires Node >=6.12. Suitable for both CLI and programmatic use.

npm install solidity-compiler
INSTALL
IMPORT
SIG · SOLIDITY-COMPILER
S
solidity-compiler
devopsjavascriptv7.0.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.

Compiler
✓ import { Compiler } from '@0x/sol-compiler'
✗ const Compiler = require('@0x/sol-compiler')
Named ESM import; default import not supported.
Compiler
✓ const { Compiler } = require('@0x/sol-compiler')
✗ const Compiler = require('@0x/sol-compiler').default
CJS destructured import.
CompilerOptions
✓ import { CompilerOptions } from '@0x/sol-compiler'
TypeScript type import, available in 7.x.

Shows basic programmatic usage: instantiate Compiler with paths and options, then call compile().

import { Compiler } from '@0x/sol-compiler'; async function compile(): Promise<void> { const compiler = new Compiler({ contractsDir: './contracts', artifactsDir: './artifacts', compilerSettings: { outputSelection: { '*': { '*': ['abi', 'evm.bytecode.object'], }, }, }, solcVersion: '^0.8.0', solcVersions: ['0.8.0', '0.8.1'], useDockerisedSolc: false, isOfflineMode: false, shouldCompileIndividually: true, shouldSaveStandardInput: true, standardInput: { language: 'Solidity', sources: {}, settings: {} }, }); await compiler.compile(); console.log('Compilation succeeded'); } compile().catch(console.error);
solidity-compiler --version
Debug
Known issues
deprecateduseDockerisedSolc option is deprecated; use solcVersion and solcVersions instead.
fix
Remove useDockerisedSolc and specify solcVersion/solcVersions.
affects: >=6.0.0
breakingCompilerOptions interface changed in v7; artifactsDir no longer defaults to a relative path.
fix
Explicitly provide artifactsDir in options.
affects: >=7.0.0
gotchaCompiling with solcVersion that contains a caret (^) may fail if the exact version is not installed locally.
fix
Use exact version or define solcVersions array.
affects: *
gotchaTypeRoots configuration required for TypeScript projects using tsconfig.json.
fix
Add "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"] to tsconfig.json.
affects: *
breakingDefault export removed in v5; use named import { Compiler }.
fix
Switch to named import { Compiler } from '@0x/sol-compiler'.
affects: >=5.0.0 <6.0.0
Errors
Common errors & fixes
Cannot find module '@0x/typescript-typings/types'
Missing typeRoots configuration or package not installed.
fix
Add "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"] to tsconfig.json, or install @0x/typescript-typings.
Error: solc version '0.8.0' not found
Specified solcVersion is not locally installed or available.
fix
Either install the version via npm (npm install solc@0.8.0) or add it to the solcVersions array.
TypeError: Compiler is not a constructor
Importing as default instead of named import.
fix
Use import { Compiler } from '@0x/sol-compiler' or const { Compiler } = require('@0x/sol-compiler').
Upgrade
Version history
7.0.1latest on npm
Audit
Dependencies
@0x/typescript-typingsoptionalTypeScript typeRoots needed for type resolution
Agent activity
5 hits · last 30 days
node
4
Resources
solidity-compiler — npm install solidity-compiler · libregistry