2.8.2022

How to Run Starknet Devnet on Windows

In this tutorial we will show how to run Starknet devnet on Windows.

Hello there! 👋

So, you use Windows, and want to get started with Cairo and Starknet? In this tutorial we will show how to run Starknet devnet on Windows!

General info

The purpose of using the Starknet devnet is to try out your smart contracts locally, on your machine, to play around and run tests, before deploying it on a testnet / mainnet.

Devnet doesn't run on Windows out of the box, so a workaround is needed, either by:

  • using Docker desktop
  • running some Linux distribution on a Virtual Machine
  • working with the WSL2 (Windows subsystem for Linux 2)

We recommend using WSL2! It's like running Linux on your Windows machine, but without the overhead of running a virtual machine.

Setup

We won't be going into details on how to set up WSL2 on your machine, because there is a ton of info on the web - first and foremost the official Microsoft documentation: https://docs.microsoft.com/en-us/windows/wsl/

After you got WSL2 up and running, search the Microsoft Store and install: 

  • some of the available Linux distributions (I will use Ubuntu 20.04.4 LTS * on my machine)
  • Windows Terminal, we will be using it to access our Linux distro quickly

* note: Maybe easiest to Ubuntu 20.04.4 LTS which comes with Python version 3.8.10 by default, since Ubuntu 22 comes with Python >3.10 which we do not support

Open the Terminal, and click on the little arrow to get a dropdown:

Choose Ubuntu, and follow the instructions to finish your setup. To get the latest updates for your Ubuntu you can also run:


sudo apt update

Devnet

Go to Shard-Labs/starknet-devnet and take a look at the documentation.

Important:

  • Works with Python versions >=3.7.2 and <3.10
  • Check python version with command: python3 --version

Install the devnet:


pip install starknet-devnet

But it doesn’t work!

That’s because we have a fresh Ubuntu, and we don’t have pip installed.  Luckily, Ubuntu gives us a suggestion what to do:


sudo apt install python3-pip

After it is done, run this command again:


pip install starknet-devnet

But wait! It doesn’t work again??

That’s because we didn’t install Cairo dependencies! You can take a look at: Setting up the environment — Cairo documentation

But basically, you have to run:


sudo apt install -y libgmp3-dev

And now finally running pip install starknet-devnet should do the trick.

Last thing to do is to start a new shell (new window with Ubuntu in the Terminal) and you can start the devnet with the command:


starknet-devnet 

There you go! You finally set up the starknet devnet on your Windows machine!

In other tutorials we will cover other use cases of the devnet, so make sure you follow our blog and Twitter.

Happy coding!🚀🚀🚀

‍*This article is also available on SpaceShard Medium.

Downlaod all images