logo
    Go back
    paul simroth; guide to installing foundry on windows, forge

    How to install Foundry on Windows

    April 27, 2024

    Avatar Paul Simroth

    Paul Simroth

    Here is a short guide to follow in order to install the smart contract development toolkit Foundry on your windows machine.

    • Guides & Tools

    Introduction to Foundry

    In this article I will show you all the necessary step in order to set up Foundry on your Windows PC.

    Foundry is an agile, adaptable, and modular toolkit tailored specifically for Ethereum application development, written in Rust. Within its architecture are tools such as Forge, designed as an Ethereum testing framework similar to industry counterparts like Truffle, and Hardhat. Additionally, Foundry incorporates Cast, a versatile tool for the management of EVM smart contracts, execution of transactions, and fetching of chain data. Anvil is the included local Ethereum node similar to other solutions like Ganache and Hardhat Network. Chisel is Foundry´s a swift and functional Solidity REPL (A Read-Eval-Print Loop, abbreviated as REPL, denotes a computational environment that processes user inputs, evaluates them, and subsequently presents the results back to the user). You can see the full docs here: getfoundry

    Please keep in mind, that you should always double check every step and always consult the docs as well as do your own research before installing anything on your machine.

    Step 1 – Install Windows Subsystem for Linux (WSL)

    Now, one problem Windows has compared to MacOS or Linux Users, is that we can´t simply install Foundry like you for example do other tools like hardhat. In order to use Foundry, we first need to install A Windows Subsystem for Linux (WSL).

    You could also use Bitbucket, but I suggest you do it this way. Despite Windows' progress in developer support, challenges persist when configuring the ideal development environment and executing specific command-line tools. To ensure cross-platform compatibility with Unix-based systems like Mac and Linux, WSL proves highly advantageous. How does WSL assist? By installing a Linux distribution via WSL, you acquire access to a Unix-like terminal directly on your Windows system.

    Follow this step to install WSL on your machine. First, open your Windows Terminal or Powershell. Then enter the command wsl --install and hit enter.

    After that your machine should reboot and upon login you should be prompted with the steps for installation. You will have to enter/create a Unix username and password. In Powershell you should now be able to open a new Tab using Ubuntu. There you can create your project folders using the command line.

    Here again in summary:

    open your Windows Terminal
    wsl --install
    Reboot
    enter/create a Unix username and password.

    Step 2 – Make Visual Studio code compatible with WSL

    Now that we have configured our Linux terminal through WSL, we need to ensure its compatibility with VS Code.

    • Open VS Code and navigate to the Extensions tab.
    • Search for the Remote Development extensions and install each of them. This enables seamless operation between VS Code and WSL.
    • After installation, you'll notice a new icon called 'Remote Explorer,' which ebales VS Code to directly connect to WSL.

    You can also create folders through the command line. You can follow the steps in Powershell using the Ubuntu terminal.

    • In the terminal, create a new folder (e.g., "foundry-project") with the command mkdir <FOLDER_NAME>, navigate to it with cd <FOLDER_NAME>, then type code . and press Enter. This command opens VS Code and starts a new WSL connected with VS Code.
    mkdir <FOLDER_NAME>
    cd <FOLDER_NAME>
    code . 
    • You will now see the WSL Ubuntu banner at the bottom of your VS Code window.

    Please be aware that when operating from a folder within Windows, it's essential to understand that the WSL console can only access local files within the WSL instance. Therefore, it's recommended to store files within the WSL instance.

    Step 3 – Install Git

    If you ever coded anything on your machine, you will most likely already have git installed. So, you can just go on to the next step.

    If you don’t have git, follow these steps. Check if git is installed with this command:

    git version

    If it is not installed, head over to gitforwindows.org and install it.

    That is all for this step.

    Step 4 – Install Foundry

    Now you should have your terminal and VS Code environment ready for this step.

    You can also consult the steps listed on the Foundry docs. foundry docs - installation

    Just enter this command:

    curl -L https://foundry.paradigm.xyz | bash

    After hitting Enter you should see outputs in the terminal which tell you that the installation is in progress. Once that is finished, enter the command

    foundryup

    This command can be also used for updating the foundry version in an existing project. You can confirm your foundry version by running forge –version

    Now you should have everything set up. If you encounter issues, please consult the official foundry docs.

    Step 5 – Start your Foundry Project

    Now all that is left to do, is to create your first project. For this you just need to run:

    forge init <PROJECT_NAME>

    Use the following command to enter the project folder:

    cd <PROJECT_NAME> 

    open it in VS code

    code .

    and start your project.

    Conclusion

    I wrote this short guide to have everything in place for people starting out with foundry. If you want to learn how to use Foundry, I highly suggest signing up to Cyfrin Updraft, which you can do here: Cyfrin Updraft. All the steps outlined here are explained there with much more detail, and you can learn how to use Foundry to its full capabilities and much more. I myself learned a lot in a very short time there.

    When I started out with Smart Contract Development, I started in Truffle, later moved to Hardhat (which I also use at work) and started using Foundry just a couple of months ago. In my opinion, what you can do with it seems to me more intuitive compared to other tools. What I like, is the speed and the fact that you can use Solidity for writing test and deployment scripts.

    I hope I could help you with this guide and wish you all the best on your coding journey.

    Go back

    This site uses Cookies. By clicking "Accept All" you help me with improving this website and its performance better. It helps me understand where the website is visited from and by how many people. "Accept (required only)" only tracks the performance of the website. Visit the Data Policy for more information!