Skip to content

Installing Solidity on OSX

Ben Hauser edited this page Jul 24, 2020 · 2 revisions

Installing Solidity on OSX

The Solidity team does not provide binaries for use with macOS/Darwin. For this reason, py-solc-x attempts to install Solidity on OSX by building it from the source code.

Sometimes older versions of Solidity fail to build due to incompatible versions of one or more dependencies. When this happens you have two options:

1. Building via Homebrew

py-solc-x will make use of any Solidity versions installed using brew:

brew update
brew upgrade
brew tap ethereum/ethereum
brew install solidity

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.

To install an older version, you can use a Homebrew formula directly from Github:

  1. Find the commit in ethereum/homebrew-ethereum which references the version you wish to install.
  2. Navigate the repository until you have the raw file link for solidity.rb at that commit. Make sure the link begins with https://raw.githubusercontent.com/ - get it from the "Raw" button in the upper right, immediately above the source code.
  3. Install it using brew:
brew unlink solidity
# e.g. to install v0.5.6
brew install https://raw.githubusercontent.com/ethereum/homebrew-ethereum/1ecf6c60875740133ee51f6167aef9a4f05986e7/solidity.rb

2. Installing Third-Party Binaries

The web3j team provides compiled OSX binaries for many versions of Solidity. To use a third-party binary with py-solc-x:

  1. Download the desired version from web3j/solidity-darwin-binaries
  2. Rename the file to solc-v0.x.y where x and y correspond to the minor and patch version.
  3. Move the file to the ~/.solcx directory on your system. It will now be available for use in py-solc-x.