Setting up your Starknet development environment

If you encounter an issue while following this tutorial, check out "Hello, Starknet!" quickstart tutorial troubleshooting.

Introduction

Welcome to the first installment of the "Hello, Starknet!" quickstart series, the official tutorial for starting your journey as a Starknet developer! 🚀

As a popular phrase (often attributed to Abraham Lincoln) says, "Give me six hours to chop down a tree, and I will spend the first four sharpening the axe". The first installment of the series will therefore guide you through setting up your development environment, which will include the four most recommended tools to begin developing on Starknet:

  • Scarb, a build toolchain and package manager for Cairo and Starknet ecosystems

  • Starknet Foundry, the go-to framework for building and testing Starknet Smart Contracts

  • Starknet Devnet, a Rust implementation of a local Starknet node

To review these tools in more detail, as well as all other Starknet developer tools, check out the Tooling section.

Setting up your environment on MacOS and Linux

Installing Scarb and Starknet Foundry

On MacOS and Linux, Scarb and Starknet Foundry can be easily installed using the Starkup installer by running:

curl --proto '=https' --tlsv1.2 -sSf https://sh.starkup.sh | sh

and following the onscreen instructions. You can verify that Scarb and Starknet Foundry are installed correctly by running:

scarb --version
snforge --version && sncast --version

Starkup installs Scarb and Starknet Foundry Devnet on MacOS and Linux via the asdf version manager, which allows to easily switch between their different versions, both globally and per project (see full details in the asdf documentation or by running asdf --help). Alongside Scarb and Starknet Foundry, Starkup uses asdf to install additional useful tools, including the Universal Sierra Compiler, Cairo Profiler, Cairo Coverage, and CairoLS.

If you encounter any issues while using it or have any requests, please help by submitting an issue.

Installing Starknet Devnet

Similar to Scarb and Starknet Foundry, it is highly recommended to install Starknet Devnet on MacOS and Linux via the asdf version manager. Luckily, if you installed Scarb and Starknet Foundry using the Starkup installer, you should already have asdf installed. To install Starknet Devnet using asdf:

  1. Verify that asdf is installed:

    asdf --version

    or install it by following the instructions in the asdf documentation.

  2. Install the asdf Starknet Devnet plugin:

    asdf plugin add starknet-devnet
  3. Install the latest version of Starknet Devnet:

    asdf install starknet-devnet latest
  4. Set global version for Starknet Devnet:

    asdf set -u starknet-devnet latest
  5. Restart the terminal and verify that Starknet Devnet is installed correctly:

    starknet-devnet --version

Setting up your environment on Windows

Setting up Scarb and Starknet Foundry on Windows requires configuring the Windows Subsystem for Linux (WSL) and installing the tools inside a Linux distribution such as Ubuntu.

Installing WSL and Ubuntu

  1. Open PowerShell as administrator and run:

    wsl --install

    This command installs WSL along with the default Ubuntu distribution. If WSL or virtualization is not yet enabled, reboot and re-run the command as needed.

  2. Restart your computer when prompted.

  3. After reboot, launch Ubuntu from the Start menu. On the first launch, create a UNIX username and password when prompted.

If wsl --install does not work, enable WSL manually by running:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

and installing Ubuntu from the Microsoft Store.

Installing prerequisites in Ubuntu

  1. Open the Ubuntu terminal and run:

    sudo apt update
    sudo apt install -y curl git build-essential

Installing Homebrew

  1. Run the Homebrew install script:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Add Homebrew to your shell environment:

    echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.profile
    source ~/.profile
  3. Verify that Homebrew was installed correctly:

    brew --version

Installing asdf

Using asdf allows you to easily switch between versions of Scarb, Starknet Foundry, and Starknet Devnet globally or per project.

  1. Install asdf using Homebrew:

    brew install asdf
  2. Add asdf to your shell:

    echo '. "$(brew --prefix asdf)/libexec/asdf.sh"' >> ~/.bashrc
    source ~/.bashrc
  3. Verify that asdf is installed correctly:

    asdf --version

Installing Scarb, Starknet Foundry, and Starknet Devnet

  1. Add the Scarb plugin and install the latest Scarb version:

    asdf plugin add scarb
    asdf install scarb latest
    asdf set -u scarb latest
  2. Add the Starknet Foundry plugin and install the latest Starknet Foundry version:

    asdf plugin add starknet-foundry
    asdf install starknet-foundry latest
    asdf set -u starknet-foundry latest
  3. Add the Starknet Devnet plugin and install the latest Starknet Devnet version:

    asdf plugin add starknet-devnet
    asdf install starknet-devnet latest
    asdf set -u starknet-devnet latest
  4. Restart your terminal and verify that Scarb, Starknet Foundry, and Starknet Devnet were installed correctly:

    scarb --version
    snforge --version && sncast --version
    starknet-devnet --version

    If scarb, snforge, or starknet-devnet are not recognized, try running source ~/.bashrc or restarting your terminal.