Installing the Solidity Compiler — Solidity 0.8.33-develop documentation

Versioning

Solidity versions follow Semantic Versioningarrow-up-right. In addition, patch-level releases with major release 0 (i.e. 0.x.y) will not contain breaking changes. That means code that compiles with version 0.x.y can be expected to compile with 0.x.z where z > y.

In addition to releases, we provide prereleases and nightly development builds to make it easy for developers to try out upcoming features and provide early feedback. Note that such builds contain bleeding-edge code from the development branch and are not guaranteed to be of the same quality as full releases. Despite our best efforts, they might contain undocumented and/or broken changes that will not become a part of an actual release. They are not meant for production use.

When deploying contracts, you should use the latest released version of Solidity. This is because breaking changes, as well as new features and bug fixes are introduced regularly. We currently use a 0.x version number to indicate this fast pace of changearrow-up-right.

Remix

We recommend Remix for small contracts and for quickly learning Solidity.

Access Remix onlinearrow-up-right, you do not need to install anything. If you want to use it without connection to the Internet, go to https://github.com/ethereum/remix-live/tree/gh-pages#readmearrow-up-right and follow the instructions on that page. Remix is also a convenient option for testing nightly builds without installing multiple Solidity versions.

Further options on this page detail installing command-line Solidity compiler software on your computer. Choose a command-line compiler if you are working on a larger contract or if you require more compilation options.

npm / Node.js

Use npm for a convenient and portable way to install solcjs, a Solidity compiler. The solcjs program has fewer features than the ways to access the compiler described further down this page. The Using the Commandline Compiler documentation assumes you are using the full-featured compiler, solc. The usage of solcjs is documented inside its own repositoryarrow-up-right.

Note: The solc-js project is derived from the C++ solc by using Emscripten, which means that both use the same compiler source code. solc-js can be used in JavaScript projects directly (such as Remix). Please refer to the solc-js repository for instructions.

Install solc (global via npm)
npm install --global solc
circle-info

The command-line executable is named solcjs.

The command-line options of solcjs are not compatible with solc and tools (such as geth) expecting the behavior of solc will not work with solcjs.

Docker

Docker images of Solidity builds are available using the solcarrow-up-right image from the argotorg organization on ghcr.io. Use the stable tag for the latest released version, and nightly for potentially unstable changes in the develop branch.

The Docker image runs the compiler executable so that you can pass all compiler arguments to it. For example, the command below pulls the stable version of the solc image (if you do not have it already), and runs it in a new container, passing the --help argument.

circle-info

Specific compiler versions are supported as the Docker image tag such as ghcr.io/argotorg/solc:0.8.23. We will be passing the stable tag here instead of specific version tag to ensure that users get the latest version by default and avoid the issue of an out-of-date version.

To use the Docker image to compile Solidity files on the host machine, mount a local folder for input and output, and specify the contract to compile. For example:

You can also use the standard JSON interface (which is recommended when using the compiler with tooling). When using this interface, it is not necessary to mount any directories as long as the JSON input is self-contained (i.e. it does not refer to any external files that would have to be loaded by the import callback).

Linux Packages

Binary packages of Solidity are available at solidity/releasesarrow-up-right.

Ubuntu packages for versions up to 0.8.30 are available in the ethereum/ethereum PPAarrow-up-right. However, we have discontinued this distribution method and future versions will not be added there.

Furthermore, some Linux distributions provide their own packages. These packages are not directly maintained by us but usually kept up-to-date by the respective package maintainers.

For example, Arch Linux has packages for the latest development version as AUR packages: solidityarrow-up-right and solidity-binarrow-up-right.

circle-exclamation

There is also a snap packagearrow-up-right, however, it is currently unmaintained. It is installable in all the supported Linux distrosarrow-up-right. To install the latest stable version of solc:

If you want to help testing the latest development version of Solidity with the most recent changes, please use the following:

circle-exclamation

macOS Packages

We distribute the Solidity compiler through Homebrew as a build-from-source version. Pre-built bottles are currently not supported.

To install the most recent 0.4.x / 0.5.x version of Solidity you can also use brew install solidity@4 and brew install solidity@5, respectively.

If you need a specific version of Solidity you can install a Homebrew formula directly from Github.

View solidity.rb commits on GitHubarrow-up-right.

Copy the commit hash of the version you want and check it out on your machine.

Install it using brew:

Static Binaries

We maintain a repository containing static builds of past and current compiler versions for all supported platforms at solc-binarrow-up-right. This is also the location where you can find the nightly builds.

The repository is not only a quick and easy way for end users to get binaries ready to be used out-of-the-box but it is also meant to be friendly to third-party tools:

  • The content is mirrored to https://binaries.soliditylang.orgarrow-up-right where it can be easily downloaded over HTTPS without any authentication, rate limiting or the need to use git.

  • Content is served with correct Content-Type headers and lenient CORS configuration so that it can be directly loaded by tools running in the browser.

  • Binaries do not require installation or unpacking (exception for older Windows builds bundled with necessary DLLs).

  • We strive for a high level of backward-compatibility. Files, once added, are not removed or moved without providing a symlink/redirect at the old location. They are also never modified in place and should always match the original checksum. The only exception would be broken or unusable files with the potential to cause more harm than good if left as is.

  • Files are served over both HTTP and HTTPS. As long as you obtain the file list in a secure way (via git, HTTPS, IPFS or just have it cached locally) and verify hashes of the binaries after downloading them, you do not have to use HTTPS for the binaries themselves.

The same binaries are in most cases available on the Solidity release page on GitHubarrow-up-right. The difference is that we do not generally update old releases on the GitHub release page. This means that we do not rename them if the naming convention changes and we do not add builds for platforms that were not supported at the time of release. This only happens in solc-bin.

The solc-bin repository contains several top-level directories, each representing a single platform. Each one includes a list.json file listing the available binaries. For example in emscripten-wasm32/list.json you will find the following information about version 0.7.4:

This means that:

circle-exclamation
circle-exclamation
circle-exclamation

Building from Source

Prerequisites - All Operating Systems

The following are dependencies for all builds of Solidity:

Software
Notes

CMakearrow-up-right (version 3.21.3+ on Windows, 3.13+ otherwise)

Cross-platform build file generator.

Boostarrow-up-right (version 1.77+ on Windows, 1.83+ otherwise)

C++ libraries.

Command-line tool for retrieving source code.

z3arrow-up-right (version 4.8.16+, Optional)

For use with SMT checker.

circle-info

Solidity versions prior to 0.5.10 can fail to correctly link against Boost versions 1.70+. A possible workaround is to temporarily rename <Boost install path>/lib/cmake/Boost-1.70.0 prior to running the cmake command to configure Solidity.

Starting from 0.5.10 linking against Boost 1.70+ should work without manual intervention.

circle-info

The default build configuration requires a specific Z3 version (the latest one at the time the code was last updated). Changes introduced between Z3 releases often result in slightly different (but still valid) results being returned. Our SMT tests do not account for these differences and will likely fail with a different version than the one they were written for. This does not mean that a build using a different version is faulty. If you pass -DSTRICT_Z3_VERSION=OFF option to CMake, you can build with any version that satisfies the requirement given in the table above. If you do this, however, please remember to pass the --no-smt option to scripts/tests.sh to skip the SMT tests.

circle-info

By default the build is performed in pedantic mode, which enables extra warnings and tells the compiler to treat all warnings as errors. This forces developers to fix warnings as they arise, so they do not accumulate “to be fixed later”. If you are only interested in creating a release build and do not intend to modify the source code to deal with such warnings, you can pass -DPEDANTIC=OFF option to CMake to disable this mode. Doing this is not recommended for general use but may be necessary when using a toolchain we are not testing with or trying to build an older version with newer tools. If you encounter such warnings, please consider reporting themarrow-up-right.

Minimum Compiler Versions

The following C++ compilers and their minimum versions can build the Solidity codebase:

Prerequisites - macOS

For macOS builds, ensure that you have the latest version of Xcode installedarrow-up-right. This contains the Clang C++ compilerarrow-up-right, the Xcode IDEarrow-up-right and other Apple development tools that are required for building C++ applications on OS X. If you are installing Xcode for the first time, or have just installed a new version then you will need to agree to the license before you can do command-line builds:

Our OS X build script uses the Homebrewarrow-up-right package manager for installing external dependencies. Here’s how to uninstall Homebrewarrow-up-right, if you ever want to start again from scratch.

Prerequisites - Windows

You need to install the following dependencies for Windows builds of Solidity:

Software
Notes

C++ compiler and dev environment.

Boostarrow-up-right (version 1.77+)

C++ libraries.

If you already have one IDE and only need the compiler and libraries, you could install Visual Studio 2019 Build Tools.

Visual Studio 2019 provides both IDE and necessary compiler and libraries. So if you have not got an IDE and prefer to develop Solidity, Visual Studio 2019 may be a choice for you to get everything setup easily.

Here is the list of components that should be installed in Visual Studio 2019 Build Tools or Visual Studio 2019:

  • Visual Studio C++ core features

  • VC++ 2019 v141 toolset (x86,x64)

  • Windows Universal CRT SDK

  • Windows 8.1 SDK

  • C++/CLI support

We have a helper script which you can use to install all required external dependencies:

This will install boost and cmake to the deps subdirectory.

Clone the Repository

To clone the source code, execute the following command:

If you want to help develop Solidity, you should fork Solidity and add your personal fork as a second remote:

circle-info

This method will result in a pre-release build leading to e.g. a flag being set in each bytecode produced by such a compiler. If you want to re-build a released Solidity compiler, then please use the source tarball on the GitHub release page:

https://github.com/argotorg/solidity/releases/download/v0.X.Y/solidity_0.X.Y.tar.gzarrow-up-right

(not the “Source code” provided by GitHub).

Command-Line Build

Be sure to install External Dependencies (see above) before build.

Solidity project uses CMake to configure the build. You might want to install ccachearrow-up-right to speed up repeated builds. CMake will pick it up automatically. Building Solidity is quite similar on Linux, macOS and other Unices:

or even easier on Linux and macOS, you can run:

circle-exclamation

And for Windows:

In case you want to use the version of boost installed by scripts\install_deps.ps1, you will additionally need to pass -DBoost_ROOT="deps/boost" -DBoost_INCLUDE_DIR="deps/boost/include" and -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded as arguments to the call to cmake.

This should result in the creation of solidity.sln in that build directory. Double-clicking on that file should result in Visual Studio firing up. We suggest building Release configuration, but all others work.

Alternatively, you can build for Windows on the command-line, like so:

CMake Options

If you are interested what CMake options are available run cmake .. -LH.

SMT Solvers

Solidity can optionally use SMT solvers, namely z3, cvc5 and Eldarica, but their presence is checked only at runtime, they are not needed for the build to succeed.

circle-info

The emscripten builds require Z3 and will statically link against it instead.

The Version String in Detail

The Solidity version string contains four parts:

  • the version number

  • pre-release tag, usually set to develop.YYYY.MM.DD, pre.N or nightly.YYYY.MM.DD

  • commit in the format of commit.GITHASH

  • platform, which has an arbitrary number of items, containing details about the platform and compiler

If there are local modifications, the commit will be postfixed with .mod.

These parts are combined as required by SemVer, where the Solidity pre-release tag equals to the SemVer pre-release and the Solidity commit and platform combined make up the SemVer build metadata.

Examples:

  • release: 0.4.8+commit.60cc1668.Emscripten.clang

  • pre-release: 0.4.9-pre.3+commit.fb60450bc.Emscripten.clang

  • nightly build: 0.4.9-nightly.2017.1.17+commit.6ecb4aa3.Emscripten.clang

Important Information About Versioning

After a release is made, the patch version level is bumped, because we assume that only patch level changes follow. When changes are merged, the version should be bumped according to SemVer and the severity of the change. Finally, a release is always made with the version of the current build, but without the prerelease specifier.

1

Release made

The 0.4.0 release is made.

2

Nightly / prerelease versions

Nightly builds and prereleases have a version of 0.4.1 from now on.

3

Non-breaking changes

Non-breaking changes are introduced –> no change in version.

4

Breaking change

A breaking change is introduced –> version is bumped to 0.5.0.

5

New release

The 0.5.0 release is made.

This behavior works well with the version pragma.