Registry / devops / remix-solidity

remix-solidity

JSON →
library0.3.31jsnpmunverified

Tool to load and run the Solidity compiler. Version 0.3.31 integrates with Remix IDE to compile smart contracts. It provides the Compiler class and CompilerInput helper for building compiler input JSON. Supports loading compiler versions via web worker or script tag, handling imports, and returning compilation results including ABI, bytecode, and source maps. Part of the Remix project, it is maintained with regular releases.

npm install remix-solidity
INSTALL
IMPORT
SIG · REMIX-SOLIDITY
R
remix-solidity
devopsjavascriptv0.3.31
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 'remix-solidity'
const Compiler = require('remix-solidity').Compiler
ESM import preferred. Default export is an object with Compiler and CompilerInput.
CompilerInput
import { CompilerInput } from 'remix-solidity'
import CompilerInput from 'remix-solidity'
Not a default export; must use named import.
CompilerInput
import { CompilerInput } from 'remix-solidity'
const CompilerInput = require('remix-solidity').CompilerInput
CommonJS require is possible but discouraged; use ESM.

Shows how to instantiate Compiler with a custom import handler, define a Solidity source, listen for compilation events, and compile.

import { Compiler, CompilerInput } from 'remix-solidity'; // Create a custom import handler const handleImportCall = (fileurl: string, cb: (error: Error | null, content?: string) => void) => { if (fileurl === 'imported.sol') { cb(null, 'contract Imported {}'); } else { cb(new Error('File not found')); } }; // Instantiate the compiler const compiler = new Compiler(handleImportCall); // Define source files const sources = { 'MyContract.sol': { content: ` pragma solidity ^0.8.0; contract MyContract { uint256 public value; constructor() { value = 42; } }` } }; // Listen for compilation events compiler.event.register('compilationFinished', (success: boolean, data: any, source: any) => { if (success) { console.log('Compilation success:', data.contracts['MyContract.sol'].MyContract); } else { console.error('Compilation error:', data); } }); // Compile compiler.compile(sources, 'MyContract.sol');
Debug
Known issues
gotchaCompiler class requires a valid import handler callback; otherwise compilation will fail silently or throw.
fix
Always provide a proper handleImportCall function that calls cb with content or error.
affects: >=0.1.0
deprecatedSome older versions (pre-0.2.0) used a different API; check changelog for breaking changes.
fix
Upgrade to latest version and follow current API.
affects: <0.2.0
gotchaCompilerInput helper expects specific types; incorrect options may produce invalid compiler input.
fix
Use TypeScript to leverage type definitions or carefully match the expected interface.
affects: >=0.1.0
gotchaThe event system uses internal EventManager; methods like onCompilerLoaded may not fire in all scenarios.
fix
Register event listeners before calling compile or loadVersion.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: compiler.compile is not a function
Compiler not instantiated correctly or import mistake.
fix
Ensure you use `new Compiler(handleImportCall)` and import as `import { Compiler } from 'remix-solidity'`.
Error: File not found
Import handler callback not invoked with content for imported file.
fix
Implement handleImportCall to return content for all imported URLs, or ignore imports if not needed.
Cannot find module 'solc'
The package does not include solc itself; it expects solc to be available in the environment.
fix
Install solc separately: `npm install solc` or load it via CDN in browser.
Upgrade
Version history
0.3.31latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
remix-solidity — npm install remix-solidity · libregistry