Forrest logo
tool overview
On this page you find all important commands for the CLI tool solcjs. If the command you are looking for is missing please ask our AI.

solcjs

Solcjs is a command-line tool used to compile Solidity smart contracts. It is part of the Solidity compiler suite. The primary purpose of solcjs is to compile Solidity source code files (.sol) into Ethereum Virtual Machine (EVM) bytecode. It can be used to compile both individual contracts and entire contract libraries.

Solcjs supports various versions of the Solidity language, allowing developers to specify the version they want to compile against. This ensures compatibility and allows taking advantage of new language features.

The compiled output of solcjs is bytecode that can be deployed on an Ethereum network. It also generates an Application Binary Interface (ABI) JSON file, which serves as an interface to interact with the compiled contracts.

Solcjs provides various options to optimize the compilation process and reduce gas costs. It supports dead code elimination, literal deduplication, and other optimization techniques. These options can be adjusted based on project requirements.

The tool offers a watch mode that automatically recompiles contracts whenever changes are detected in the source files. This is convenient during development, as it eliminates the need to manually trigger compilation after each code modification.

It is possible to run solcjs within a development environment such as Truffle or Hardhat to seamlessly integrate contract compilation into the project's build process.

Solcjs is an open-source tool that is actively maintained by the Ethereum community. It undergoes regular updates to ensure compatibility with new Solidity versions and to fix any reported issues or vulnerabilities.

By leveraging solcjs, developers can rapidly compile their Solidity contracts, validate their syntax and semantic correctness, and deploy them on Ethereum networks with ease. It is an essential tool for Solidity developers looking to interact with the blockchain.

List of commands for solcjs:

  • solcjs:tldr:2f503 solcjs: Compile a specific contract to hex.
    $ solcjs --bin ${filename-sol}
    try on your machine
    explain this command
  • solcjs:tldr:830a8 solcjs: Specify a base path to resolve imports from.
    $ solcjs --bin --base-path ${path-to-directory} ${filename-sol}
    try on your machine
    explain this command
  • solcjs:tldr:98a25 solcjs: Specify one or more paths to include containing external code.
    $ solcjs --bin --include-path ${path-to-directory} ${filename-sol}
    try on your machine
    explain this command
  • solcjs:tldr:c6c07 solcjs: Compile the ABI of a specific contract.
    $ solcjs --abi ${filename-sol}
    try on your machine
    explain this command
  • solcjs:tldr:f95e7 solcjs: Optimise the generated bytecode.
    $ solcjs --bin --optimize ${filename-sol}
    try on your machine
    explain this command
tool overview