Installing the Solidity Compiler¶
Solidity versions follow semantic versioning and in addition to releases, nightly development builds are also made available. The nightly builds are not guaranteed to be working and despite best efforts they might contain undocumented and/or broken changes. We recommend using the latest release. Package installers below will use the latest release.
We recommend Remix for small contracts and for quickly learning Solidity.
Access Remix online, you don’t need to install anything. If you want to use it without connection to the Internet, go to https://github.com/ethereum/browser-solidity/tree/gh-pages and download the .ZIP file as explained on that page.
Further options on this page detail installing commandline Solidity compiler software on your computer. Choose a commandline 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 all options further down this page. Our Using the Commandline Compiler documentation assumes you are using the full-featured compiler, solc. So if you install solcjs from npm then you will stop reading the documentation here and then continue to solc-js.
npm install -g solc
The commandline is named solcjs.
The comandline options of solcjs are not compatible with solc and tools (such as geth) expecting the behaviour of solc will not work with solcjs.
We provide up to date docker builds for the compiler. The
repository contains released versions while the
repository contains potentially unstable changes in the develop branch.
docker run ethereum/solc:stable solc --version
Currently, the docker image only contains the compiler executable, so you have to do some additional work to link in the source and output directories.
Binary packages of Solidity are available at solidity/releases.
We also have PPAs for Ubuntu. For the latest stable version.
sudo add-apt-repository ppa:ethereum/ethereum sudo apt-get update sudo apt-get install solc
If you want to use the cutting edge developer version:
sudo add-apt-repository ppa:ethereum/ethereum sudo add-apt-repository ppa:ethereum/ethereum-dev sudo apt-get update sudo apt-get install solc
sudo snap install solc
Or if you want to help testing the unstable solc with the most recent changes from the development branch:
sudo snap install solc --edge
Arch Linux also has packages, albeit limited to the latest development version:
pacman -S solidity
Homebrew is missing pre-built bottles at the time of writing, following a Jenkins to TravisCI migration, but Homebrew should still work just fine as a means to build-from-source. We will re-add the pre-built bottles soon.
brew update brew upgrade brew tap ethereum/ethereum brew install solidity
If you need a specific version of Solidity you can install a Homebrew formula directly from Github.
Follow the history links until you have a raw file link of a
specific commit of
Install it using
brew unlink solidity # Install 0.4.8 brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/77cce03da9f289e5a3ffe579840d3c5dc0a62717/solidity.rb
Gentoo Linux also provides a solidity package that can be installed using
Building from Source¶
Clone the Repository¶
To clone the source code, execute the following command:
git clone --recursive https://github.com/ethereum/solidity.git cd solidity
If you want to help developing Solidity, you should fork Solidity and add your personal fork as a second remote:
cd solidity git remote add personal email@example.com:[username]/solidity.git
Solidity has git submodules. Ensure they are properly loaded:
git submodule update --init --recursive
Prerequisites - macOS¶
For macOS, ensure that you have the latest version of Xcode installed. This contains the Clang C++ compiler, the Xcode IDE and other Apple development tools which 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:
sudo xcodebuild -license accept
Prerequisites - Windows¶
You will need to install the following dependencies for Windows builds of Solidity:
|Git for Windows||Command-line tool for retrieving source from Github.|
|CMake||Cross-platform build file generator.|
|Visual Studio 2017 Build Tools||C++ compiler|
|Visual Studio 2017 (Optional)||C++ compiler and dev environment.|
If you’ve already had one IDE and only need compiler and libraries, you could install Visual Studio 2017 Build Tools.
Visual Studio 2017 provides both IDE and necessary compiler and libraries. So if you have not got an IDE and prefer to develop solidity, Visual Studio 2017 may be an choice for you to get everything setup easily.
Here is the list of components that should be installed in Visual Studio 2017 Build Tools or Visual Studio 2017:
- Visual Studio C++ core features
- VC++ 2017 v141 toolset (x86,x64)
- Windows Universal CRT SDK
- Windows 8.1 SDK
- C++/CLI support
We now have a “one button” script which installs all required external dependencies on macOS, Windows and on numerous Linux distros. This used to be a multi-step manual process, but is now a one-liner:
Or, on Windows:
Be sure to install External Dependencies (see above) before build.
Solidity project uses CMake to configure the build. Building Solidity is quite similar on Linux, macOS and other Unices:
mkdir build cd build cmake .. && make
or even easier:
#note: this will install binaries solc and soltest at usr/local/bin ./scripts/build.sh
And even for Windows:
mkdir build cd build cmake -G "Visual Studio 15 2017 Win64" ..
This latter set of instructions 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 RelWithDebugInfo configuration, but all others work.
Alternatively, you can build for Windows on the command-line, like so:
cmake --build . --config RelWithDebInfo
If you are interested what CMake options are available run
cmake .. -LH.
The version string in detail¶
The Solidity version string contains four parts:
- the version number
- pre-release tag, usually set to
- commit in the format of
- platform has arbitrary number of items, containing details about the platform and compiler
If there are local modifications, the commit will be postfixed with
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.
A release example:
A pre-release example:
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 nightly build, but without the
- the 0.4.0 release is made
- nightly build has a version of 0.4.1 from now on
- non-breaking changes are introduced - no change in version
- a breaking change is introduced - version is bumped to 0.5.0
- the 0.5.0 release is made
This behaviour works well with the version pragma.