Two approaches for integrating with Aave using Alchemy's Smart Wallets - Core (recommended) and Wallet APIs.
-
Setup environment variables:
cp .env.example .env # Fill in your values in .env -
Install dependencies:
npm install
-
Initialize your smart wallet:
npm run account # Get your smart wallet address -
Fund your smart wallet: Send 0.01+ DAI to the smart wallet address from step 3
-
Run examples:
npm run supply # Supply DAI to Aave npm run withdraw # Withdraw DAI from Aave
Required in .env:
PRIVATE_KEY- Your EOA private key (0x prefixed)ALCHEMY_API_KEY- From dashboard.alchemy.comPAYMASTER_POLICY_ID- From Gas Manager (for gas sponsorship)
npm run core:*- Direct@aa-sdk/coreimplementation- Simpler API, fewer lines of code
npm run wallet:*-@account-kit/wallet-clientimplementation- Full prepare/sign/send workflow
To customize chain, token addresses, or amounts, edit src/config.ts:
export const config = {
chain: arbitrum, // Change to sepolia, polygon, etc.
amounts: {
deposit: "0.01", // Change deposit amount
withdraw: "0.01", // Change withdraw amount
}
}- Uses Arbitrum network and DAI token by default
- Creates smart wallets (not EOAs) - fund the smart wallet address
- Gas fees sponsored via Alchemy Gas Manager
- Get DAI on Arbitrum: Uniswap