Installing cardano-node and cardano-cli from source | Cardano Developer Portal (2024)

info

This document's current version is relevant for cardano-node release version 8.0.0 (May-2023)

Overview

This guide will show you how to compile and install the cardano-node and cardano-cli into your operating system of choice, directly from the source-code. It will enable you to interact with the Cardano blockchain, including but not limited to sending/receiving transactions, creating NFTs, posting transaction metadata into the blockchain, minting/burning native tokens, creating a stake pool, executing smart contracts, and so much more!

note

If you want to avoid compiling the binaries yourself, you can download the latest Linux, Mac, Windows versions of cardano-node and cardano-cli from the official IOHK release page.

The components can be built and run on Windows and MacOS, but we recommend that stake pool operators use Linux in production to take advantage of the associated performance advantages.

Prerequisites

To set up the components, you will need:

  • Windows, MacOS, or Linux for your operating system
  • An Intel or AMD x86 processor with two or more cores, at 1.6GHz or faster (2GHz or faster for a stake pool or relay)
  • 24GB of RAM and at least 150GB of free disk space (250GB recommended for future growth)

note

If intending to connect to Mainnet instance, the requirements for RAM and storage would increase beyond baselines above.

Choose your Platform

  • Linux
  • MacOS
  • Windows

Linux

In this section, we will walk you through the process of downloading, compiling, and installing cardano-node and cardano-cli into your Linux-based operating system.

Installing Operating System dependencies

To download the source code and build it, you need the following packages and tools on your Linux system:

  • the version control system git,
  • the gcc C-compiler,
  • C++ support for gcc,
  • developer libraries for the arbitrary precision library gmp,
  • developer libraries for the compression library zlib,
  • developer libraries for systemd,
  • developer libraries for ncurses,
  • ncurses compatibility libraries,
  • the Haskell build tool cabal,
  • the GHC Haskell compiler (version 8.10.7 or above).

In Redhat, Fedora, and Centos:

sudo yum update -y
sudo yum install git gcc gcc-c++ tmux gmp-devel make tar xz wget zlib-devel libtool autoconf jq -y
sudo yum install systemd-devel ncurses-devel ncurses-compat-libs -y

For Debian/Ubuntu, use the following instead:

sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt-get install automake build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ tmux git jq wget libncursesw5 libtool autoconf -y

If you are using a different flavor of Linux, you will need to use the correct package manager for your platform instead of yum or apt-get, and the names of the packages you need to install might differ.

Installing GHC and Cabal

The fastest way to install GHC (Glasgow Haskell Compiler) and Cabal (Common Architecture for Building Applications and Libraries) is to use ghcup.

Use the following command to install ghcup

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

Please follow the instructions and provide the necessary input to the installer.

Do you want ghcup to automatically add the required PATH variable to "/home/ubuntu/.bashrc"? - (P or enter)

Do you want to install haskell-language-server (HLS)? - (N or enter)

Do you want to install stack? - (N or enter)

Press ENTER to proceed or ctrl-c to abort. (enter)

Once complete, you should have ghc and cabal installed to your system.

note

ghcup will try to detect your shell and ask you to add it to the environment variables. Please restart your shell/terminal after installing ghcup

You can check if ghcup has been installed correctly by typing ghcup --version into the terminal. You should see something similar to the following:

The GHCup Haskell installer, version 0.1.19.2

ghcup will install the latest stable version of ghc. However, as of the time of writing this, Input-Output recommends using ghc 8.10.7. So, we will use ghcup to install and switch to the required version.

ghcup install ghc 8.10.7
ghcup set ghc 8.10.7

ghcup will install the latest stable version of cabal. However, as of the time of writing this, Input-Output recommends using cabal 3.6.2.0. So, we will use ghcup to install and switch to the required version.

ghcup install cabal 3.6.2.0
ghcup set cabal 3.6.2.0

Finally, we check if we have the correct ghc and cabal versions installed.

Check ghc version:

ghc --version

You should see something like this:

The Glorious Glasgow Haskell Compilation System, version 8.10.7

Check cabal version:

cabal --version

You should see something like this:

info

Please confirm that the versions you have installed match the recommended versions above. If not, check if you have missed any of the previous steps.

Downloading & Compiling

Let's create a working directory to store the source-code and builds for the components.

mkdir -p $HOME/cardano-src
cd $HOME/cardano-src

Next, we will download, compile and install libsodium.

git clone https://github.com/IntersectMBO/libsodium
cd libsodium
git checkout dbb48cc
./autogen.sh
./configure
make
sudo make install

Then we will add the following environment variables to your shell profile. E.G $HOME/.zshrc or $HOME/.bashrc depending on what shell application you are using. Add the following to the bottom of your shell profile/config file so that the compiler can be aware that libsodium is installed on your system.

export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

Once saved, we will then reload your shell profile to use the new variables. We can do that by typing source $HOME/.bashrc or source $HOME/.zshrc (depending on the shell application you use).

We need to install secp256k1 which is required from cardano-node version 1.35.0 onward:

Download and install libsecp256k1:

cd $HOME/cardano-src
git clone https://github.com/bitcoin-core/secp256k1
cd secp256k1
git checkout ac83be33
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install
sudo ldconfig

Now we are ready to download, compile and install cardano-node and cardano-cli. But first, we have to make sure we are back at the root of our working directory:

cd $HOME/cardano-src

Download the cardano-node repository:

git clone https://github.com/IntersectMBO/cardano-node.git
cd cardano-node
git fetch --all --recurse-submodules --tags

Switch the repository to the latest tagged commit:

git checkout $(curl -s https://api.github.com/repos/IntersectMBO/cardano-node/releases/latest | jq -r .tag_name)

info

If upgrading an existing node, please ensure that you have read the release notes on GitHub for any changes.

Configuring the build options

We explicitly use the ghc version that we installed earlier. This avoids defaulting to a system version of ghc that might be newer or older than the one you have installed.

cabal configure --with-compiler=ghc-8.10.7

note

For some installations you might encounter the following warning:
Warning: The package list for 'cardano-haskell-packages' does not exist. Run 'cabal update' to download it.

Running cabal update will fix this problem, as well as other problems resulting from changes to the package list... so it is generally recommended for each installation even if you don't get this error.

If you are running non x86/x64 platform (eg. ARM) please install and configure LLVM with:

sudo apt install llvm-9
sudo apt install clang-9 libnuma-dev
sudo ln -s /usr/bin/llvm-config-9 /usr/bin/llvm-config
sudo ln -s /usr/bin/opt-9 /usr/bin/opt
sudo ln -s /usr/bin/llc-9 /usr/bin/llc
sudo ln -s /usr/bin/clang-9 /usr/bin/clang

Building and installing the node

We can now build the Haskell-based cardano-node to produce executable binaries.

cabal update
cabal build all

Install the newly built node and CLI commands to the $HOME/.local/bin directory:

mkdir -p $HOME/.local/bin
cp -p "$(./scripts/bin-path.sh cardano-node)" $HOME/.local/bin/
cp -p "$(./scripts/bin-path.sh cardano-cli)" $HOME/.local/bin/

We have to add this line below our shell profile so that the shell/terminal can recognize that cardano-node and cardano-cli are global commands. ($HOME/.zshrc or $HOME/.bashrc depending on the shell application you use)

export PATH="$HOME/.local/bin/:$PATH"

Once saved, reload your shell profile by typing source $HOME/.zshrc or source $HOME/.bashrc (depending on the shell application you use).

Check the version that has been installed:

cardano-cli --version
cardano-node --version

Congratulations, you have successfully installed Cardano components into your Linux system! 🎉🎉🎉

Next, we will talk about how to run cardano-node.

MacOS

In this section, we will walk you through the process of downloading, compiling, and installing cardano-node and cardano-cli into your MacOS-based operating system.

Installing Operating System dependencies

To download the source code and build it, you need the following packages and tools on your MacOS system:

  • Xcode - The Apple Development IDE and SDK/Tools
  • Xcode Command Line Tools, you can install it by typing xcode-select --install in the terminal.
  • Homebrew - The Missing Package Manager for MacOS (or Linux)

Installing Homebrew packages

For the cardano-node and cardano-cli components to compile properly, we will need to install some libraries via brew:

brew install jq
brew install libtool
brew install autoconf
brew install automake
brew install pkg-config
brew install openssl

You will need to install llvm in case you are using M1

brew install llvm@13

Installing GHC and Cabal

The fastest way to install GHC (Glassglow Haskell Compiler) and Cabal (Common Architecture for Building Applications and Libraries) is to use ghcup.

Use the following command to install ghcup

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

Please follow the instructions and provide the necessary input to the installer.

Do you want ghcup to automatically add the required PATH variable to "/home/ubuntu/.bashrc"? - (P or enter)

Do you want to install haskell-language-server (HLS)? - (N or enter)

Do you want to install stack? - (N or enter)

Press ENTER to proceed or ctrl-c to abort. (enter)

Once complete, you should have ghc and cabal installed to your system.

note

ghcup will try to detect your shell and will ask you to add it to the environment variables. Please restart your shell/terminal after installing ghcup

You can check if ghcup has been installed properly by typing ghcup --version into the terminal. You should see something similar to the following:

The GHCup Haskell installer, version v0.1.17.4

ghcup will install the latest stable version of ghc. However, as of the time writing this, Input-Output recommends using ghc 8.10.7. So, we will use ghcup to install and switch to the required version.

ghcup install ghc 8.10.7
ghcup set ghc 8.10.7

ghcup will install the latest stable version of cabal. However, as of the time of writing this, Input-Output recommends using cabal 3.6.2.0. So, we will use ghcup to install and switch to the required version.

ghcup install cabal 3.6.2.0
ghcup set cabal 3.6.2.0

Finally, we check if we have the correct ghc and cabal versions installed.

Check ghc version:

ghc --version

You should see something like this:

The Glorious Glasgow Haskell Compilation System, version 8.10.7

Check cabal version:

cabal --version

You should see something like this:

cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library

info

Please confirm that the versions you have installed matches the recommended versions above. If not, check if you have missed any of the previous steps.

Downloading & Compiling

Let's create a working directory to store the source-code and builds for the components.

mkdir -p $HOME/cardano-src
cd $HOME/cardano-src

Next, we will download, compile and install libsodium.

git clone https://github.com/IntersectMBO/libsodium
cd libsodium
git checkout dbb48cc
./autogen.sh
./configure
make
sudo make install

Then we will add the following environment variables to your shell profile. E.G $HOME/.zshrc or $HOME/.bashrc depending on what shell application you are using. Add the following to the bottom of your shell profile/config file so the compiler can be aware that libsodium is installed on your system.

export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

If you installed llvm for M1, then you will need to add this too, assuming that your exact llvm version is 13.0.1_2:

export PATH="/opt/homebrew/Cellar/llvm@13/13.0.1_2/bin:$PATH"

note

llvm installation path might differs based on your installation, if you used default installation, it should be ok. Please check screen after you installed llvm to see this info, if you forgot or lost it, you can just reinstall llvm and then you will see them again.

Once saved, we will then reload your shell profile to use the new variables. We can do that by typing source $HOME/.bashrc or source $HOME/.zshrc (depending on the shell application you use).

We need to install Secp256k1 which is required from 1.35.0 cardano-node version onward:

Download and install libsecp256k1:

cd $HOME/cardano-src
git clone https://github.com/bitcoin-core/secp256k1
cd secp256k1
git checkout ac83be33
./autogen.sh
./configure --enable-module-schnorrsig --enable-experimental
make
make check
sudo make install

Now we are ready to download, compile and install cardano-node and cardano-cli. But first, we have to make sure we are back at the root of our working directory:

cd $HOME/cardano-src

Download the cardano-node repository:

git clone https://github.com/IntersectMBO/cardano-node.git
cd cardano-node
git fetch --all --recurse-submodules --tags

Switch the repository to the latest tagged commit:

git checkout $(curl -s https://api.github.com/repos/IntersectMBO/cardano-node/releases/latest | jq -r .tag_name)

info

If upgrading an existing node, please ensure that you have read the release notes on GitHub for any changes.

Configuring the build options

We explicitly use the ghc version that we installed earlier. This avoids defaulting to a system version of ghc that might be newer or older than the one you have installed.

cabal configure --with-compiler=ghc-8.10.7

note

For some installations you might encounter the following warning: Warning: The package list for 'cardano-haskell-packages' does not exist. Run 'cabal update' to download it.. The warning is self-explanatory and you will need to run cabal update before moving on.

You will need to run following commands on M1, those commands will set some cabal related options before building

echo "package trace-dispatcher" >> cabal.project.local
echo " ghc-options: -Wwarn" >> cabal.project.local
echo "" >> cabal.project.local

echo "package HsOpenSSL" >> cabal.project.local
echo " flags: -homebrew-openssl" >> cabal.project.local
echo "" >> cabal.project.local

Building and installing the node

cabal update
cabal build all

caution

More recent versions of MacOS seems to install openssl in a different location than expected by default. If you have installed openssl via homebrew and encounter the following build error:

Failed to build HsOpenSSL-0.11.7.2. The failure occurred during the configure
step.
[1 of 1] Compiling Main (...)
Linking .../dist-newstyle/tmp/src-75805/HsOpenSSL-0.11.7.2/dist/setup/setup ...
Configuring HsOpenSSL-0.11.7.2...
setup: Can’t find OpenSSL library

You'll most likely need to add relevant symlinks as follows:

sudo mkdir -p /usr/local/opt/openssl
sudo ln -s /opt/homebrew/opt/openssl@3/lib /usr/local/opt/openssl/lib
sudo ln -s /opt/homebrew/opt/openssl@3/include /usr/local/opt/openssl/include

This is a wart of the HsOpenSSL library wrapper, and using classic methods such as setting LDFLAGS & CPPFLAGS, or using --extra-include-dirs and --extra-lib-dirs won't work properly.

Install the newly built node and CLI to the $HOME/.local/bin directory:

mkdir -p $HOME/.local/bin
cp -p "$(./scripts/bin-path.sh cardano-node)" $HOME/.local/bin/
cp -p "$(./scripts/bin-path.sh cardano-cli)" $HOME/.local/bin/

We have to add this line below our shell profile so that the shell/terminal can recognize that cardano-node and cardano-cli are global commands. ($HOME/.zshrc or $HOME/.bashrc depending on the shell application you use)

export PATH="$HOME/.local/bin/:$PATH"

Once saved, reload your shell profile by typing source $HOME/.zshrc or source $HOME/.bashrc (depending on the shell application you use).

Check the version that has been installed:

cardano-cli --version
cardano-node --version

Congratulations, you have successfully installed Cardano components into your MacOS system! 🎉🎉🎉

Next, we will talk about how to run cardano-node.

Windows

info

Currently, the Windows installation guide is still in progress. In the meantime, we recommend using WSL (Windows Subsystem for Linux) to get a Linux environment on top of Windows. Once installed, you can use the Linux guide to install and run cardano-node within WSL.

Installing cardano-node and cardano-cli from source | Cardano Developer Portal (2024)

FAQs

What do I need to run a Cardano node? ›

The latest technical specifications and supported platforms can be found on the Cardano Node release page. Currently the following specifications are recommended on Mainnet: Servers: 1 for block producer node + at least 2 for relay nodes. CPU: An Intel or AMD x86 processor with two or more cores at 2GHz or faster.

How to build Cardano node? ›

To compile Cardano Node:

For example, using a Web browser you can navigate to the above URL https://api.github.com/repos/IntersectMBO/cardano-node/releases/latest to display the data that the curl command retrieves, and then confirm the value of the tag_name attribute that the jq command selects.

What is Cardano cli? ›

cardano-cli refers to the command-line interface (CLI) tool for interacting with the Cardano blockchain. Cardano is a blockchain platform that aims to provide a secure and scalable infrastructure for the development of decentralized applications (dApps) and the execution of smart contracts.

What does a Cardano node do? ›

Cardano is a Proof-of-Stake blockchain (PoS) that relies on the Ouroboros consensus mechanism. In short, the Ouroboros consensus randomly selects a node operator to be a slot leader. This node is then responsible for validating transactions and creating the next block on the chain in exchange for ADA rewards.

What are the hardware requirements for Cardano node? ›

Prerequisites​

To set up the components, you will need: Windows, MacOS, or Linux for your operating system. An Intel or AMD x86 processor with two or more cores, at 1.6GHz or faster (2GHz or faster for a stake pool or relay) 24GB of RAM and at least 150GB of free disk space (250GB recommended for future growth)

What is the difference between Cardano node and stake pool? ›

A stake pool is a reliable server node that represents the combined stake of various stakeholders in a single entity. Stake pools use the Cardano node to form the backbone of the Cardano network by processing transactions and validating and producing blocks.

What coding does Cardano use? ›

Plutus is the native smart contract programming language for Cardano. It is a Turing-complete language written in Haskell, and Plutus smart contracts are effectively Haskell programs. If you want to start with Plutus, having previous programming experience will help.

What is Cardano for beginners? ›

Cardano is a blockchain platform that uses proof-of-stake consensus to verify and validate transactions on the network. ADA is the native token of the Cardano network, the digital currency that facilitates transactions on the blockchain.

Is Cardano a good idea? ›

The investment potential of Cardano depends on several factors, such as individual risk tolerance, investment objectives, and market conditions. Many experts believe Cardano is an undervalued investment with significant growth potential due to its wide range of applications in the coming years.

What is the protocol of Cardano node? ›

Cardano node communication protocols​
  1. chain-sync: a protocol that allows a node to reconstruct a chain of an upstream node.
  2. block-fetch: a protocol that allows a node to download block bodies from various peers.
  3. tx-submission: a protocol that allows submission of transactions.

How many nodes are in Cardano? ›

The Cardano network consists of almost 6000 relay nodes. Approximately 1800 of them are in the USA, 1400 in Germany, and around 250 in Japan, the UK, Canada, etc. 1400 pool operators run only one relay node, 1000 of them run 2 relay nodes and over 230 of them run 3 relay nodes.

What is the purpose of a node in crypto? ›

A blockchain node is a device, usually a computer, that participates in a blockchain network. It runs the blockchain protocol's software, allowing it to help validate transactions and keep the network secure. Blockchain nodes communicate with each other. The more nodes there are, the more decentralized the network is.

What do you need to run a crypto node? ›

If you can meet the following requirements, you'll have an easy-to-use node.
  1. Desktop or laptop hardware running recent versions of Windows, Mac OS X, or Linux.
  2. 7 gigabytes of free disk space, accessible at a minimum read/write speed of 100 MB/s.
  3. 2 gigabytes of memory (RAM)

How much ADA do I need to run a stake pool? ›

Aside from the initial 2 ADA delegation fee, Cardano stake pools have two types of fees which are not taken out from your rewards or wallet, but from the total rewards distributed to a stake pool. There is a fixed fee of 340 ADA set by the protocol and a variable margin fee set by each pool operator.

How to be a Cardano validator? ›

Cardano utilizes Proof-of-Stake as its consensus mechanism, in which users invest a coin to have the chance to serve as a validator. There are two ways to take part in the staking and validation process: by becoming a stake pool owner or operator. Stake pools serve as trusted server nodes that validate transactions.

Top Articles
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 6541

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.