DEV Community

Samarth Saxena
Samarth Saxena

Posted on • Originally published at awesamarth.hashnode.dev on

How to Install Foundry on Windows/macOS/Linux

Introduction

If you are a web3 developer, I'm sure you must have heard of Foundry somewhere- maybe in a YouTube video, maybe in a Twitter thread, or maybe from a friend of yours. Foundry is a smart contract development toolchain. You can write, compile, deploy and test smart contracts as well as interact with them using Foundry.

Foundry vs Remix IDE

You may be asking yourself: why should I choose Foundry over Remix IDE? Well, first of all, Foundry is installed locally on your system. So if you're making, let's say, a website, you can initialize a Foundry project alongside your other files and then make changes there directly. This allows you to structure your files in an organized manner and work quickly. Moreover, Remix can be pretty unreliable sometimes and you might end up losing all your progress unexpectedly. Most importantly however, Foundry shines through with its testing suite which allows you test your contracts significantly faster than Remix and it thus provides a seamless development experience.

OK enough yapping. Now without further ado, let's see how we can install this Swiss Army Knife on our machines.

Installing on Linux/macOS

If you have Linux or macOS, the process is pretty straightforward.

First download Foundryup, which is the official installer for the Foundry toolchain, by running this command in your terminal

curl -L https://foundry.paradigm.xyz | bash
Enter fullscreen mode Exit fullscreen mode

Follow the on-screen instructions and the foundryup command will become available in your terminal. Then, just run:

foundryup
Enter fullscreen mode Exit fullscreen mode

This will automatically install the latest (nightly) versions of the: forge, cast, anvil, and chisel tools, which are a part of Foundry.

And that's pretty much it lmao. Linux users have it easy this time. A welcome change, I'm sure. Jump to the Did it work section.

Installing on Windows

You can just use WSL and then refer to the commands in the previous section. However, if you don't want to install WSL, read on.

Make sure you have the Rust compiler and Cargo already installed on your machine. If you don't, download rustup from this link and run it to install both. You'll also need a recent version of Visual Studio, with the Desktop Development With C++ workload installed. Rustup will prompt you to install it. This is what you'll see when you run the downloaded file:

Enter 1 here

Enter 1 here and let the setup run

Once Visual Studio is installed, you will get this screen:

(just press enter here)

If everything is successful, you will get something like this:

Awesome! Now press enter, relaunch your terminal and run this command

cargo install --git https://github.com/foundry-rs/foundry --profile release --locked forge foundry-cast chisel anvil
Enter fullscreen mode Exit fullscreen mode

This command will install the Foundry suite, ie. Forge, Cast, Anvil and Chisel on your machine. This might take some time as it will download and compile multiple crates. This will happen for all 4 tools so grab a cup of coffee or something while you wait. Once that is done, you'll see:

💡

Don't worry if it seems stuck at any point

Did it work?

To check if it worked, relaunch your terminal and run these commands one by one. Each should give you some output

forge --version

anvil --version

chisel --version

cast --version
Enter fullscreen mode Exit fullscreen mode

The output should be something like this:

Conclusion

Congratulations, you've successfully installed Foundry on your machine! In the next instalment of this series, we'll see how we can create a new Foundry project and write smart contracts in it. Stay tuned till then. Bye for now! 👋👋

Top comments (0)