Setting up your environment manually on MacOS and Linux

Installing WSL and Ubuntu

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:
  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.
    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.
  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.
  4. 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.

Fetching a predeployed Sepolia account

Procedure:
  1. Export the private key from your wallet by:
    • For Ready wallets: navigating to Settings -> <YOUR_ACCOUNT> -> Export Private Key.
    • For Braavos wallets: navigating to Settings -> Privacy and Security -> Export Private Key.
  2. Create a keystore file by running:
starkli signer keystore from-key keystore.json
and entering the private key of your smart wallet, along with a password that will be used to encrypt it.
  1. Fetch the account by running:
starkli account fetch \
    <SMART_WALLET_ADDRESS> \
    --output account.json \
    --network=sepolia

Troubleshooting

Starkli unable to detect shell

Procedure:
  1. Detect whether your shell is zsh or bash:
echo $SHELL
  1. Add:
. /Users/<NAME>/.starkli/env
to either ~/.zshrc or ~/.bashrc.
  1. Restart the terminal, and run either:
source ~/.zshrc
or:
source ~/.bashrc

scarb build fails to run version command for Rust

Starting from Scarb version 2.10 and Starknet Foundry version 0.37.0, Rust is longer required for projects with the following line in their Scarb.toml file:
[tool.scarb]
allow-prebuilt-plugins = ["snforge_std"]
If not all three conditions are met and Rust is not installed, running scarb build (and scarb test) will result in a compilation error. To resolve this, either update Scarb, Starknet Foundry, and your Scarb.toml file accordingly or install Rust.

starkli declare unable to identify compiler version

When using starkli declare, Starkli will do its best to identify the compiler version of the declared class. In case it fails, the --compiler-version flag can be used to specify the version of the compiler. Procedure:
  1. Find the compiler versions supported by Starkli by running:
starkli declare --help 
and looking for the possible values of the --compiler-version flag.
  1. Find the current Scarb version in use:
scarb --version
  1. In case a different compiler version is required, switch to a different Scarb version using asdf: a. Install the desired Scarb version:
    asdf install scarb <VERSION>
    
    b. Select the desired Scarb version as the local version for the project:
    asdf set scarb <VERSION>