Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Yield on Aave

Overview

This sample showcases how to pair Openfort's embedded wallet infrastructure with the Aave protocol to build a full-stack DeFi experience.

Aave recipe interface

GitHub Icon
View Sample Code
GitHub Repository
Complete source code for the Aave DeFi application with frontend, backend, and smart contract integrations.

Project structure

aave/
├── src/
│   ├── App.tsx                # Main application component
│   ├── main.tsx               # React entry point
│   ├── components/            # UI components for lending flows
│   │   └── env_validation/    # Environment validation components
│   ├── assets/                # Images, icons, and static assets
│   ├── contracts/             # Contract ABIs, addresses, and protocol helpers
│   ├── hooks/                 # Custom React hooks for Wagmi/Viem
│   ├── lib/                   # Configuration and providers
│   └── utils/                 # Shared utilities and formatting
├── public/                    # Static assets served by Vite
├── .env.example               # Environment template
├── package.json               # Dependencies and scripts
├── vite.config.ts             # Vite configuration
└── README.md                  # Project documentation

Key features

  • Openfort Shield authentication
  • Aave lending and borrowing flows
  • Gas-sponsored transactions (optional)
  • APY tracking and balance monitoring
ComponentTechnology
FrontendReact + Vite
BackendExpress.js
BlockchainEthereum
Key Libraries@aave/react, wagmi, viem
StylingTailwind CSS

Quick start

Clone the repository using gitpick:

pnpx gitpick openfort-xyz/recipes-hub/tree/main/aave openfort-aave
cd openfort-aave

Prerequisites

  • Node.js 18+
  • pnpm
  • Openfort dashboard project credentials

Get Openfort credentials

Create an Openfort account

  1. Go to Openfort Dashboard
  2. Sign up or log in
  3. Create a new project

Get your API keys

  1. Navigate to DevelopersAPI Keys
  2. Copy your Publishable Key (starts with pk_)
  3. Navigate to Shield section
  4. Copy your Shield Public Key

Create a policy (optional)

  1. Navigate to Gas Policies
  2. Create a new policy to sponsor user transactions
  3. Copy the Policy ID

Set up backend

This app requires a backend server for Shield authentication sessions.

git clone https://github.com/openfort-xyz/openfort-backend-quickstart.git
cd openfort-backend-quickstart
cp .env.example .env

Add your Openfort Secret Key to the backend .env:

OPENFORT_SECRET_KEY=sk_...

Start the backend:

pnpm i
pnpm dev  # Runs on http://localhost:3001

Configure environment

Return to the aave project directory and configure the frontend:

cp .env.example .env

Add your credentials to .env:

VITE_OPENFORT_PUBLISHABLE_KEY=pk_...
VITE_OPENFORT_SHIELD_PUBLISHABLE_KEY=...
VITE_OPENFORT_POLICY_ID=pol_...     # Optional
VITE_BACKEND_URL=http://localhost:3001

Install and run

pnpm i
pnpm dev  # http://localhost:5173
Copyright © 2023-present Alamas Labs, Inc