Contributing to open source projects can be a bit scary sometimes 👻 But it’s usually not that hard!

I just made my first (really small) contribution to Foundry (a toolkit to help develop smart contracts for Ethereum) today, and I really enjoyed it! 😍

While tackling the issue I took some notes, so if you’re thinking about contributing, I’m going to walk you through what I did and hopefully you’ll see that it’s pretty easy. Obviously the bug I fixed was really simple but it helped me get into the code and I’m ready to take on some more challenging ones 💪

It all started with this issue: https://github.com/foundry-rs/foundry/issues/4434

There was a bug in my forge script… I didn’t have time to look into it that day, so I left the issue opened for a few days, and today I finally took the time to do it. It took me about 3 hours from the moment I cloned the repo to the moment I opened the PR.

Setup

Foundry repo

First thing I did after cloning the repo was heading to the dev doc for help.

Since my PR was specifically related to forge script I thought I would only install forge locally with cargo build -p ./forge --profile local.

And I ran the tests: cargo test -p ./forge --profile local

I didn’t dig into it, but it seems like adding the local profile flag makes the build take longer, so in the end I just went with cargo build and built the entire project.

I now have the forge binary in foundry/target/debug/forge

And then I ran this command so that it would rebuild automatically when i make a change

cargo watch -x "build"

On every change, the build takes about 15-20 seconds on my Macbook Pro M1

Reproduce the error

I then created another directory where I setup my project for testing with the problematic script and I linked the newly built forge inside this repo with

$ ln -s ../foundry/target/debug/forge ./myforge

The repo looks like this

|-- cache
|-- foundry.toml
|-- lib
|-- myforge -> ../foundry/target/debug/forge
|-- myscript.s.sol
`-- out