LinuxCommandLibrary

solcjs

JavaScript-based Solidity compiler

TLDR

Compile contract

$ solcjs [contract.sol]
copy
Output binary
$ solcjs --bin [contract.sol]
copy
Output ABI
$ solcjs --abi [contract.sol]
copy
Both binary and ABI
$ solcjs --bin --abi [contract.sol]
copy
Custom output directory
$ solcjs --bin -o [build] [contract.sol]
copy
Optimize code
$ solcjs --bin --optimize [contract.sol]
copy

SYNOPSIS

solcjs [--bin] [--abi] [--optimize] [-o dir] files

DESCRIPTION

solcjs is a JavaScript/WebAssembly implementation of the Solidity compiler, installable via npm. It compiles Solidity smart contracts into EVM bytecode and ABI (Application Binary Interface) definitions needed for deploying and interacting with contracts on Ethereum and compatible blockchains.
The compiler produces bytecode (--bin) for deployment and ABI JSON (--abi) that describes the contract's functions and events for client interaction. The optimizer reduces bytecode size and gas costs when enabled.
solcjs provides the same core compilation functionality as the native solc compiler but runs in Node.js environments, making it easy to integrate into JavaScript-based development workflows and build tools like Truffle and Hardhat. It is somewhat slower than the native compiler and may lack some advanced features.

PARAMETERS

--bin

Output bytecode.
--abi
Output ABI JSON.
--optimize
Enable optimizer.
-o DIR
Output directory.
--base-path DIR
Base path for imports.
--include-path DIR
Include path.

CAVEATS

Slower than native solc. JavaScript implementation. Some features missing.

HISTORY

solcjs is a JavaScript/WebAssembly port of solc, the Solidity compiler for Ethereum smart contracts.

SEE ALSO

solc(1), truffle(1), hardhat(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community