Setting up a Foundry Project
From Paradigm's website:
Foundry is a portable, fast, and modular toolkit for Ethereum application development, written in Rust. Our goal with Foundry is to create the best developer experience for building secure smart contracts on EVM chains. Most importantly: Foundry is built by Solidity developers for Solidity developers.
(Source: https://www.paradigm.xyz/2022/03/foundry-02)
My interest in Foundry comes from its enhanced testing and debugging capabilities. It also seems to be getting a lot of good reviews in the Ethereum development community, and I could see it becoming the main application development kit replacing Hardhat and Truffle at some point. I'm very eager to try it out myself and see how well I like it.
Paradigm even has a Foundry book (hosted on IPFS) that provides a great overview of it.
In Foundry v0.2.0 it seems Paradigm has made it so you don't have to install Rust before you can get started, however that seem to only be for Linux users for the moment. I am a Windows user, and I tried following the instructions for Windows users through Command Prompt, but found it too difficult. I ended up pivoting to using Windows Subsystem for Linux to in Windows 11.
I actually used instructions from here. Specifically I found success with How to Install Linux Distributions from the Microsoft Store section and downloaded Ubuntu.
I also learned that using Windows Subsystem for Linux I could still access my C file drive when using Terminal App from the Microsoft Store. For any other Linux noobs out there I was simply able to do
cd ../../mnt/c/<the-rest-of-your-file-path>
in Terminal. Your C Drive is located in the mnt folder. You start (in Ubuntu) in a folder like /home/soorya so you need to go to the parent directory twice to get to the parent of the home folder, which is where you can access the mnt folder.
Once I did all this I could just follow the instruction from the Foundry book which are
curl -L https://foundry.paradigm.xyz | bash
Which will download foundryup which is a script that download the latest version of Foundry from Github.
foundryup
This does not set up your project however. That is a separate step, but it does give you the ability to use forge and cast, which are two binaries/actions you can use in Foundry to do a number of things (that I'll explore in later posts). To do set up your project you must do:
forge init hello_foundry
Where hello_foundry is the name of the directory you want to use as your project folder.
Once that is done you can cd into the new directory
cd hello_foundry
It will create a git repository and set up three directories, lib (library to reference dependencies and comes with the Forge Standard Library which has lots of testing tools and capabilities), src (where your Smart Contracts go), and test (where your test files for your Contracts go).
You can build the sample contract with:
forge build
and test it with:
forge test
Now you have a simple Foundry project set up for you to start working on! In later posts I'll go over connecting to GitHub, deploying contracts with Foundry, and more.
