Installing the Solidity Compiler¶
Smart contracts in CPChain are based on solidity 0.4.25, commit 59dbf8f1. Either older or newer version can incur unexpected failure when compiling smart contract.
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.
Building from Source¶
Clone the Repository¶
To clone the source code, execute the following command:
git clone --recursive https://github.com/ethereum/solidity.git git checkout 59dbf8f1 cd solidity
Commit 59dbf8f1 refers to the corresponding version compiling smart contracts for CPChain.
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.