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:
/: A sample smart contract demonstrating how to fetch user positions.src /: Deployment scripts for your contracts.script /: Example tests for your contracts.test foundry.: A Foundry configuration file customized for Aave V4.toml
Install or update Foundry:
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:
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 . file from the . template:
cp .env.example .env
Then populate the required environment variables:
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 Reserve contract to the Spoke set in SPOKE_:
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. for imports to resolve correctly:
aave-v4/=lib/aave-v4/
forge-std/=lib/forge-std/src/