> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/reserve-protocol/reserve-index-dtf/llms.txt
> Use this file to discover all available pages before exploring further.

# Development Environment Setup

> Set up your local development environment for building with Reserve Folio

## Prerequisites

Before you begin, ensure you have the following tools installed:

<CardGroup cols={3}>
  <Card title="Foundry" icon="hammer">
    Ethereum development toolkit
  </Card>

  <Card title="Node.js v20+" icon="node-js">
    JavaScript runtime environment
  </Card>

  <Card title="Yarn" icon="box">
    Package manager
  </Card>
</CardGroup>

### Install Foundry

Foundry is the primary development framework for Reserve Folio. Install it using the following command:

```bash theme={null}
curl -L https://foundry.paradigm.xyz | bash
foundryup
```

Verify your installation:

```bash theme={null}
forge --version
```

### Install Node.js

Reserve Folio requires Node.js version 20 or higher. We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage Node.js versions:

```bash theme={null}
nvm install 20
nvm use 20
```

### Install Yarn

Install Yarn globally using npm:

```bash theme={null}
npm install -g yarn
```

## Clone the Repository

Clone the Reserve Folio repository and navigate to the project directory:

```bash theme={null}
git clone https://github.com/reserve-protocol/reserve-index-dtf.git
cd reserve-index-dtf
```

## Install Dependencies

Install the required dependencies using Yarn:

```bash theme={null}
yarn install
```

This will install:

* **OpenZeppelin Contracts**: Standard smart contract libraries
* **PRB Math**: Advanced fixed-point math library
* **Reserve Governor**: Governance framework
* **Trusted Fillers**: Auction filling mechanisms
* **Forge Standard Library**: Testing utilities

## Configuration

### Environment Variables

Create a `.env` file in the project root based on `.env.example`:

```bash theme={null}
cp .env.example .env
```

Configure the following environment variables:

```bash .env theme={null}
FORK_RPC_MAINNET="your-ethereum-mainnet-rpc-url"
FORK_RPC_ARBITRUM="your-arbitrum-rpc-url"
FORK_RPC_BASE="your-base-rpc-url"
ETHERSCAN_KEY="your-etherscan-api-key"
```

<Info>
  You can get free RPC endpoints from [Alchemy](https://www.alchemy.com/), [Infura](https://www.infura.io/), or use public endpoints from [PublicNode](https://publicnode.com/).
</Info>

### Foundry Configuration

The project comes with a pre-configured `foundry.toml` file that includes:

```toml foundry.toml theme={null}
[profile.default]
script = "script"
src = "contracts"
test = "test"

gas_limit = "18446744073709551615"
memory_limit = 1073741824

optimizer = true
optimizer_runs = 200
solc_version = "0.8.28"
evm_version = "paris"

[rpc_endpoints]
base = "https://base-rpc.publicnode.com"
bsc = "https://bsc-rpc.publicnode.com"
mainnet = "https://ethereum-rpc.publicnode.com"
```

## Build the Project

Compile the smart contracts using Forge:

```bash theme={null}
yarn compile
```

This command runs `forge compile` and generates the contract artifacts in the `out/` directory.

### Check Contract Sizes

To verify that contracts are within the size limit:

```bash theme={null}
yarn size
```

## Code Quality

### Formatting

Format Solidity, TypeScript, and configuration files:

```bash theme={null}
yarn format
```

Check formatting without making changes:

```bash theme={null}
yarn format:check
```

### Linting

Run Solhint to check for code quality issues:

```bash theme={null}
yarn lint
```

Automatically fix linting issues:

```bash theme={null}
yarn lint:check
```

## Local Development Network

Start a local Anvil node forked from Ethereum mainnet:

```bash theme={null}
yarn anvil
```

This starts a local node at `http://127.0.0.1:8545` with chain ID `31337`, forked from Ethereum mainnet.

<Note>
  The local node uses historical state from Ethereum mainnet, allowing you to test against real deployed contracts and token balances.
</Note>

## Verify Your Setup

Run the test suite to verify your setup is working correctly:

```bash theme={null}
yarn test
```

If all tests pass, your development environment is ready!

## Next Steps

<CardGroup cols={2}>
  <Card title="Running Tests" icon="vial" href="/development/testing">
    Learn how to run and write tests
  </Card>

  <Card title="Deployment" icon="rocket" href="/development/deployment">
    Deploy contracts to networks
  </Card>
</CardGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Forge command not found">
    Make sure Foundry is properly installed and added to your PATH. Run `foundryup` to update to the latest version.
  </Accordion>

  <Accordion title="Compilation errors">
    Ensure you're using Solidity version 0.8.28. Run `forge --version` to check your compiler version.
  </Accordion>

  <Accordion title="Out of memory errors">
    The project requires significant memory for compilation. Try increasing your system's available memory or reducing the `memory_limit` in `foundry.toml`.
  </Accordion>

  <Accordion title="RPC connection issues">
    Verify your RPC endpoints in the `.env` file are valid and have sufficient rate limits.
  </Accordion>
</AccordionGroup>
