# Setting Up a Foundry Project and Installing Open-Zeppelin at a Specific Version

## Installing

Foundry is an excellent modern framework for developing and testing solidity smart contracts. One of the primary benefits is being able to write tests directly in solidity.

First, we need to install the toolchain installer

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

Then we can install everything we need with:

```bash
$ foundryup
```

After that we can create a hello world project.

```bash
$ forge init hello_world
```

This sets up a foundry project with an example contract and test. Now you can run

```bash
$ forge build 
$ forge test
```

now you can have a look at the example test file and see how tests are written in solidity.

## Install external libraries and Remap imports

To install an external library like openzeppelin you can run

```bash
$ forge install Openzeppelin/openzeppelin-contracts@v5.0.1 --no-commit
```

Then in your foundry.toml file you can add the following line to include the library in your project.

```toml
remappings = [
   '@openzeppelin/contracts@v5.0.0/=lib/openzeppelin-contracts/contracts/'
]
```

after that run :

```bash
$ forge remappings > remappings.txt
```

now you can import openzeppelin files and lock their versions in your project. like so:

```solidity
import { ERC20, IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
```
