Using the Compiler — Solidity 0.8.33-develop documentation
Using the Commandline Compiler
Basic Usage
One of the build targets of the Solidity repository is solc, the Solidity commandline compiler. Using solc --help provides you with an explanation of all options. The compiler can produce various outputs, ranging from simple binaries and assembly over an abstract syntax tree (parse tree) to estimations of gas usage.
If you only want to compile a single file, run:
solc --bin sourceFile.solTo get several advanced outputs and write them to files:
solc -o outputDirectory --bin --ast-compact-json --asm sourceFile.solOptimizer Options
Before you deploy your contract, activate the optimizer when compiling using:
By default, the optimizer will optimize the contract assuming it is called 200 times across its lifetime (it assumes each opcode is executed around 200 times).
- To make initial contract deployment cheaper and later executions more expensive, set `--optimize-runs=1`.
- If you expect many transactions and don't care about higher deployment cost and output size, set `--optimize-runs` to a high number.
This parameter affects things such as:
- the size of the binary search in the function dispatch routine
- the way constants like large numbers or strings are stored
### Base Path and Import Remapping
The commandline compiler will automatically read imported files from the filesystem, but it is also possible to provide [path redirects](https://docs.soliditylang.org/en/v0.8.33/path-resolution.html#import-remapping) using `prefix=path` in the following way:
{% code %}
```bash
solc github.com/ethereum/dapp-bin/=/usr/local/lib/dapp-bin/ file.sol