# Run your first StarkNet node

By [DZupp](https://paragraph.com/@dzupp) · 2022-03-05

---

Thanks to the great work of [Equilibrium](https://www.equilibrium.co/) and [Starkware](https://starkware.co/) teams we are now able to **run our own nodes** on StarkNet, helping to keep the network secure and the data accurate.

This tutorial will guide you through the process of setting up your first **StarkNet node**.

Part 1: Install Windows Subsystem for Linux
===========================================

You can skip this part if you have a **Linux distribution** already running.

In this tutorial we will use **Ubuntu 20.04 LTS** or **18.04 LTS** as Linux distributions. Feel free to use any other distro if you find it more preferable.

*   First, open **Windows PowerShell** or CMD by searching for it in your Windows search bar, then select Run as administrator.
    

![](https://storage.googleapis.com/papyrus_images/056af7fc4a2abbd800196c860b334aa0ac83707d0be77ce85aacfeb3d5e72da6.png)

*   At the command prompt type:
    
    `wsl –install`
    
    And wait for the process to complete.
    
    For WSL to be properly activated, you will now need to **restart** your computer.
    
*   Open **Microsoft store app** and search for **Ubuntu**. There will be three options available. You can choose any of them. Once installed, you can either launch the application directly from the store or search for Ubuntu in your Windows search bar.
    

![](https://storage.googleapis.com/papyrus_images/ba08ec352d3d785a4928f58d028abd0170bf46b7cfa7f39c6951f9da270889de.png)

*   **Configure Ubuntu**
    

Congratulations, you now have an Ubuntu terminal running on your Windows machine. Once it has finished its initial setup, you will need to create a username and password (this does not need to match your Windows user credentials).

![](https://storage.googleapis.com/papyrus_images/96fa3e0238fece50574c0e87b4fd7da3a1a18c87b2baa40cea1d8a8b8db0d3bd.png)

Finally, it’s always good practice to install the latest **updates** with the following commands, entering your password when prompted.

`sudo apt update`

Then

`sudo apt full-upgrade`

Press **Y** when prompted.

For any **troubleshooting** or more in-depth instructions on how to get Ubuntu running on your system please visit Ubuntu official tutorials - links provided in _Resources_ part at the end of tutorial.

Part 2: Install dev tools on your Linux distro
==============================================

*   First check the **version of Python 3** that is installed in the system by typing:
    
    `python3 -V`
    
    You’ll receive output in the terminal window that will let you know the version number. While this number may vary, the output will be similar to this:
    

![](https://storage.googleapis.com/papyrus_images/9d5c3b2cb9b7b48381b092b88c4c13b2202d90fef791ddc8d41d7c8384cccb7a.png)

*   To manage software packages for Python, let’s install **pip**, a tool that will install and manage programming packages we may want to use later.
    
    `sudo apt install -y python3-pip`
    
*   There are a **few more packages and development tools** to install to ensure that we have a robust setup for our programming environment:
    
    `sudo apt install -y build-essential libssl-dev libffi-dev python3-dev`
    
    Then
    
    `sudo apt-get install libgmp-dev`
    
    And then
    
    `pip3 install fastecdsa`
    
    Now you have **fastecdsa** (a python tool for doing fast elliptic curve cryptography, specifically digital signatures) installed. To really not miss something later also run
    
    `sudo apt-get install -y pkg-config`
    

Part 3: Install Rust
====================

*   We also need to install **Rust programming language** and its tools since Equilibrium node is built in Rust.
    
    Run
    
    `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
    
*   Just in case if there was something left uninstalled in previous step then run
    
    `sudo apt install cargo`
    
*   Update your Rust to the latest version
    
    `rustup update stable`
    

Part 4: Clone pathfinder github repository
==========================================

Congratulations, you now made it to the part where we will actually start preparing environment for our node.

**Create a local copy** of pathfinder’s github repository by typing:

`git clone --branch v0.1.2-alpha https://github.com/eqlabs/pathfinder.git`

_Replace_ `v0.1.3-alpha` _with newer version if that exists. You check that by visiting_ [_pathfinder’s repo_](https://github.com/eqlabs/pathfinder/tags)_._

Output will look something like below. Don’t worry about `detached HEAD state`. This simply means you cannot impact active development of the pathfinder code.

![](https://storage.googleapis.com/papyrus_images/48b44b0ca0613ac6d18868d671135b14b5c8fc779fba7a493a527dadb936e8e8.png)

Part 5: Create a virtual environment for a node
===============================================

*   Install a **tool that will enable us to create virtual environment** in which our node will run:
    
    `sudo apt install python3.8-venv`
    
*   Move to **py folder** by typing
    
    `cd pathfinder/py`
    
    You should now see something like this:
    

![](https://storage.googleapis.com/papyrus_images/602d6a7522669bfbcf3c79ad65d2f32dc555ee0e859ad9385d622149d1004ef8.png)

*   Create the **virtual environment** called _venv_
    
    `python3 -m venv .venv`
    
    and activate it
    
    `source .venv/bin/activate`
    
    You will know that you are in your virtual environment when you will see (.venv) on the left side of you command line:
    

![](https://storage.googleapis.com/papyrus_images/8c89f75735253b4d7abd0e4cf3b06cf1e078cdbef73f8d43f856cb1aecd2341e.png)

*   Install some **more tools** for our node by running
    
    `PIP_REQUIRE_VIRTUALENV=true pip install --upgrade pip`
    
    then
    
    `PIP_REQUIRE_VIRTUALENV=true pip install -r requirements-dev.txt`
    
*   **Test** if your previous steps were successful by running
    
    `pytest`
    
    Your output should look something like this:
    

![](https://storage.googleapis.com/papyrus_images/45c7151d6925916e6c685786df255fc7eca366bc8387274b41ac5554e68663ab.png)

Part 6: Assemble your node
==========================

You can compile your node by running the following command. Please stay in your virtual environment (venv) for this step. You will also be running your node from venv.

`cargo build --release --bin pathfinder`

This step will take a bit longer than the others (up to 30 minutes depending on your system configuration).

Part 7: Create Infura or Alchemy account
========================================

If you want to run a node on Layer 2 (StarkNet) you will also need to know what is happening on Layer 1 since your node will calculate StarkNet state’s root and **confirm it against L1**.

Thus, we need to access **L1 full archive node**. You can do that by connecting to your L1 node or if you don’t run one set up an account with a third party API provider like [Infura](https://infura.io/), [Alchemy](https://alchemyapi.io/), [ArchiveNode](https://archivenode.io/) or [QuikNode](https://www.quiknode.io/).

In this tutorial we will set up an account with **Infura** or **Alchemy**. Choose one.

> Additional tutorial on how to run your L2 node in parallel with **Ethereum execution client** like [Nethermind](http://nethermind.io/), [Erigon](https://github.com/ledgerwatch/erigon) or [Besu](https://consensys.net/quorum/developers/) will be provided at a later date.

### Infura

*   Go to [infura.io](http://infura.io/) and sing up
    
*   On your dashboard click on _Connect to the Ethereum network in seconds_
    

![](https://storage.googleapis.com/papyrus_images/def405186acf2fbe6d7f9b80096574bd88f67ffb9d61ea653a5afcc0724c395e.png)

*   Create a new project and gave it a name.
    
*   Still on your dashboard Click on Settings
    

![](https://storage.googleapis.com/papyrus_images/394a1b9dc6db9e92ae3c561db3905b1a89b86be501291a5aa0e1a3c65599b25e.png)

*   In settings panel you will be able to see the endpoints. Copy the **https** one.
    

At this stage you will also have to decide on which Ethereum network you will run your node on. You can choose either **Mainnet** or **Goerli**.

> If you choose the endpoint on the Goerli network, then your node will run on the **StarkNet testnet** on Goerli. If the chosen endpoint is on mainnet, then it will run on **StarkNet Mainnet**.

### Alchemy

*   Go to [alchemy.com](https://www.alchemy.com/) and sing up
    
*   On your dashboard click on _Create App_
    

![](https://storage.googleapis.com/papyrus_images/5bbf2e9250a57b923929f48001c3927557b128183b499a00ef4ea75ee90e6184.png)

*   Give your new app a name and choose either Mainnet or Goerli Network
    

![](https://storage.googleapis.com/papyrus_images/cf888d6e9d1e4f65677dabbc02c65b8ef83d54b622d3a3b44bc294bd52aad7b4.png)

*   You will now be able to see the endpoint on your dashboard. Copy the **https** one.
    

![](https://storage.googleapis.com/papyrus_images/49d0805ebb1c452cb10d5980e0e1bb9db32fc3477c32449a0fea7650795e4342.png)

Part 8: Run your node
=====================

There is only one thing left to do → to run your first node on Layer 2!

You can test run your node by typing (replace the xxxxx with your Infura endpoint number)

`cargo run --release --bin pathfinder -- --ethereum.url https://mainnet.infura.io/v3/xxxxx`

or in case you are using Alchemy API (replace the xxxxx with your Alchemy API key)

`cargo run --release --bin pathfinder -- --ethereum.url https://eth-goerli.alchemyapi.io/v2/xxxxx`

Please make sure that you are in your pathfinder/py folder and have your virtual environment activated in order to successfully run the node.

You should see something like this:

![](https://storage.googleapis.com/papyrus_images/a34bf7bfe1617676a5500e4e585f90053427a62fa791bc54ec891bceafa73c8b.png)

Resources
=========

**Ubuntu** installation (Win10 and Win11)

[https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-10#1-overview](https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-10#1-overview)

[https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#1-overview](https://ubuntu.com/tutorials/install-ubuntu-on-wsl2-on-windows-11-with-gui-support#1-overview)

**Rust** installation

[https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install)

**Pathfinder** repository

[https://github.com/eqlabs/pathfinder](https://github.com/eqlabs/pathfinder)

---

*Originally published on [DZupp](https://paragraph.com/@dzupp/run-your-first-starknet-node)*
