In this tutorial we show how to install the Solidity compiler on MacOS, check the installed version, get help to learn about available options and compile a smart contract written in Solidity.
Install Solidity on MacOS
To install Solidity on MacOS we can use Homebrew. This provides us with build-from-source macOS packages and we just have to follow the installation process.
brew tap ethereum/ethereum
brew install solidity
After the execution finished we can check that Solidity is successfully installed by querying for the version.
and receive the installed Solidity version as response. If the installation wasn't successful the command above will not execute.
solc, the solidity compiler commandline interface
Install specific Solidity version
It is also possible to install a specific Solidity version by selecting the hash on the homebrew-ethereum depository on github and then pasting it into the following code:
git clone https://github.com/ethereum/homebrew-ethereum.git
git checkout [INSERT_HASH_HERE]
and then running the installation:
brew unlink solidity
brew install solidity.rb
check version of Solidity
To check for the version of the installed Solidity compiler we can always run the following command in the command-line interface.
and the installed version is returned:
solc, the solidity compiler command-line interface
To get help and learn about the available options in solc, we can use the help:
compile a contract
To compile a contract we can run:
and to specify a specifc EVM-version to compile for we can set the version:
solc --evm-version [EVM-VERSION] contract.sol