There are four major ways to install the Solidity compiler:
- Install Solidity Compiler via npm
- Install Solidity Compiler via Docker on Ubuntu
- Install Solidity Compiler via Source Code Compilation
- Install Solidity Compiler via Static Binary and Linux Packages
In this tutorial, we’ll have a quick look at each of them and give you a link to a more detailed resource so you can set up your Solidity compiler as quickly and efficiently as possible.
โถ๏ธ Video: For your convenience, I embedded the video tutorial provided by our Solidity expert Matija so you don’t even need to leave this page.
Without further ado, let’s get started! ๐
Method 1: Install Solidity Compiler via npm
As you watch the video or go through this tutorial, feel free to download the following slides as well — for your convenience:
๐ Full Tutorial: How to Install the Solidity Compiler via npm?
Method 2: Install Solidity Compiler via Docker on Ubuntu
Before we go into details about the Docker installation of solc
, letโs first get introduced to what Docker is.
๐ก Docker is an open platform for developing, shipping, and running applicationsโฆ Docker provides the ability to package and run an application in a loosely isolated environment called a container… Containers are lightweight and contain everything needed to run the application, so you do not need to rely on what is currently installed on the host.
Source: https://docs.docker.com/get-started/overview/
There are some parts of the description Iโve deliberately left out (separated by the symbol โฆ) because theyโre not essential to our understanding of the technology.
๐ Full Tutorial: How to Install the Solidity Compiler via Docker on Ubuntu?
Method 3: Install Solidity Compiler via Source Code Compilation
โก This is a very complex way to install the Solidity compiler and I wouldn’t recommend it for most people. Due to the complexity, I’ll only give a quick overview of the associated article (tutorial).
Feel free to dive into it after scanning through these three contributions:
- First, we listed and explained the software prerequisites needed for compiling a Solidity compiler. In some cases, we reached a complete explanation, and in others, we just gave a brief introductory explanation and announced an entire topic, such as in the case of the Satisfiability Modulo Theorem, SMT.
- Second, we installed the prerequisites by following the first part of a step-by-step tutorial. All the examples have been checked and validated at the time of writing the article, so I expect that we’ll be able to follow them without issues. We also concluded that a compilation process can in some cases take a substantial amount of time; it took almost 40 minutes to compile the z3 SMT solver on my machine.
- Third, we compiled a Solidity compiler following a step-by-step tutorial. I explained for each command example to broaden our learning process even outside of the strict scope of Solidity, to Linux (as far as we needed to go). Finally, when the compilation ended, we confirmed that our home-compiled Solidity compiler works at least as charming as the ones we’ve simply downloaded or installed in a precompiled state.
๐ Full Tutorial: How to Install the Solidity Compiler via Source Code Compilation?
Method 4: Install Solidity Compiler via Static Binary and Linux Packages
You’ll just download the compilerโs static binary, or in short, binary, and simply run it, without any additional prerequisites or preparations required.
First, downloading the file solc-static-linux
and giving it an executable privilege:
$ cd ~ && wget https://github.com/ethereum/solidity/releases/download/v0.8.16/solc-static-linux $ chmod +x ~/solc-static-linux
Second, running solc
:
$ ~/solc-static-linux 1_Storage.sol -o output --abi --bin Compiler run successful. Artifact(s) can be found in directory "output".
When checking our solidity_src
directory, weโll discover a new directory output, created by the Solidity compiler, containing both .abi
and .bin
files.
๐ Full Tutorial: How to Install the Solidity Compiler via Static Binary and Linux Packages?
What’s Next?
This tutorial is part of our extended Solidity documentation with videos and more accessible examples and explanations. You can navigate the series here (all links open in a new tab):
Learn Solidity Course
Solidity is the programming language of the future.
It gives you the rare and sought-after superpower to program against the “Internet Computer”, i.e., against decentralized Blockchains such as Ethereum, Binance Smart Chain, Ethereum Classic, Tron, and Avalanche – to mention just a few Blockchain infrastructures that support Solidity.
In particular, Solidity allows you to create smart contracts, i.e., pieces of code that automatically execute on specific conditions in a completely decentralized environment. For example, smart contracts empower you to create your own decentralized autonomous organizations (DAOs) that run on Blockchains without being subject to centralized control.
NFTs, DeFi, DAOs, and Blockchain-based games are all based on smart contracts.
This course is a simple, low-friction introduction to creating your first smart contract using the Remix IDE on the Ethereum testnet – without fluff, significant upfront costs to purchase ETH, or unnecessary complexity.