Skip to Content
docs

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 for Solidity development.

Getting Started

Start new projects from the Foundry boilerplate 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:

Terminal
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:

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

2. Install Dependencies

Install the project dependencies:

forge install

3. Set Up Environment

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

cp .env.example .env

Then populate the required environment variables:

Plain 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:

Terminal
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:

forge install aave/aave-v4

Update remappings.txt for imports to resolve correctly:

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

Next Steps