# Aave V4 Solidity Quickstart

The Aave smart contract interfaces provide methods for interacting with Aave V4. They enable lending, borrowing, and collateral workflows inside custom integrations. We recommend using [Foundry](https://getfoundry.sh/) for Solidity development.

## Getting Started

Start new projects from the [Foundry boilerplate](https://github.com/aave/aave-v4-foundry-template) for Aave V4. It includes a setup for deploying and testing contracts that integrate with the protocol.

Included in the boilerplate are:

- `/src`: A sample smart contract demonstrating how to fetch user positions.
- `/script`: Deployment scripts for your contracts.
- `/test`: Example tests for your contracts.
- `foundry.toml`: A Foundry configuration file customized for Aave V4.

Install or update [Foundry](https://getfoundry.sh/):

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

Then, follow these steps to get started:

### 1. Clone the Repository

Clone the boilerplate repository into a new project directory:

```bash
git clone https://github.com/aave/aave-v4-foundry-template.git my-project
cd my-project
```

### 2. Install Dependencies

Install the project dependencies:

```bash
forge install
```

### 3. Set Up Environment

Create `.env` file from the `.env.example` template:

```bash
cp .env.example .env
```

Then populate the required environment variables:

```text
RPC_URL=https://…
SPOKE_ADDRESS=0x…
PRIVATE_KEY=0x…
```

## Usage

The project includes several Foundry commands designed to streamline your workflow:

- `forge build`: Compiles the contracts.
- `forge test`: Executes tests.
- `forge script <script-path>`: Deploys contracts using deployment scripts.
- `forge clean`: Removes build artifacts from the project.
- `forge fmt`: Formats the Solidity code.

## Example Deployment

To deploy the example `ReserveUtilization` contract to the Spoke set in `SPOKE_ADDRESS`:

```bash
source .env
forge script script/Deploy_ReserveUtilization.s.sol:DeployReserveUtilization \
  --rpc-url $RPC_URL \
  --broadcast
```

## Advanced

### Add to Existing Project

If you have an existing Foundry project and want to add Aave V4 contracts, install the dependency:

```bash
forge install aave/aave-v4
```

Update `remappings.txt` for imports to resolve correctly:

```text
aave-v4/=lib/aave-v4/
forge-std/=lib/forge-std/src/
```

---

## Next Steps

  <IconCard
    href="/aave-v4/liquidity/reserves"
    icon="MarketsIcon"
    title="Reserves"
    description="Find where to supply and borrow"
  />
  <IconCard
    href="/aave-v4/positions/supply"
    icon="SupplyIcon"
    title="Supply Assets"
    description="Open a position"
  />
