contract-debugging Solc – How to Install Old Solc Compiler Versions

contract-debuggingsolcsolcjs

I would like to compile older versions of solc contract source code using a solc compiler on my local machine. Is there a website from which to download old solc compilers?

Google revealed a GitHub of old solcs, but I tried using node to run the .js. files without success (could be using this wrong).

Best Answer

I maintain a Python library called py-solc-x that allows you to install and use multiple versions of solc at the same time. It supports versions >=0.4.11. I've included some code examples below to give an idea of how it works.

Installing a new version of solc:

>>> from solcx import install_solc
>>> install_solc('v0.4.25')

Checking installed versions and versions can be installed:

>>> from solcx import get_installed_solc_versions, get_available_solc_versions
>>> get_installed_solc_versions()
['v0.4.25', 'v0.5.3', 'v0.6.0']
>>> get_available_solc_versions()
['v0.6.0', 'v0.5.15', 'v0.5.14', 'v0.5.13', 'v0.5.12', 'v0.5.11', 'v0.5.10', 'v0.5.9', 'v0.5.8', 'v0.5.7', 'v0.5.6', 'v0.5.5', 'v0.5.4', 'v0.5.3', 'v0.5.2', 'v0.5.1', 'v0.5.0', 'v0.4.25', 'v0.4.24', 'v0.4.23', 'v0.4.22', 'v0.4.21', 'v0.4.20', 'v0.4.19', 'v0.4.18', 'v0.4.17', 'v0.4.16', 'v0.4.15', 'v0.4.14', 'v0.4.13', 'v0.4.12', 'v0.4.11']

Setting the current solc version using a pragma statement:

>>> set_solc_version_pragma('^0.4.20 || >0.5.5 <0.7.0', check_new=True)
Using solc version 0.5.8
Newer compatible solc version exists: 0.6.0
Related Topic