Overview
MetaVault AI requires configuration across three packages. Each package has its own .env file with specific settings.
Contracts Configuration
The contracts package requires minimal configuration for deployment.
Create Environment File
cd packages/contracts
cp .env.example .env
Configure Variables
Edit packages/contracts/.env:# Deployer Wallet Private Key (for local development)
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# INFURA API Key (for testnet/mainnet deployment)
INFURA_KEY=your_infura_api_key
The private key shown above is the first Hardhat test account. Never use it on mainnet or with real funds.
Configuration Reference
Private key of the wallet that will deploy contracts.For local development, use one of Hardhat’s test account private keys.
Your Infura API key for connecting to Ethereum networks.Only required for testnet or mainnet deployments. Get one at infura.io.
AI Agents Configuration
The agents package requires the most configuration, including API keys and contract addresses.
Create Environment File
cd packages/agents/defi-portfolio
cp .env.example .env
Configure Core Settings
Edit packages/agents/defi-portfolio/.env:# Debug Mode
ADK_DEBUG="false"
# OpenRouter API Key (Required)
OPEN_ROUTER_KEY=your_openrouter_api_key
# LLM Model
LLM_MODEL=anthropic/claude-3.5-sonnet
# Server Ports
PORT=3001
CHAT_PORT=3002
Configure Blockchain Connection
Add blockchain settings:# RPC URL
RPC_URL=http://127.0.0.1:8545
# Vault Deployer Wallet Private Key
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Configure Contract Addresses
Add the contract addresses from your deployment:# CORE CONTRACTS
VAULT_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
ROUTER_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
STRATEGY_LEVERAGE_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
STRATEGY_AAVE_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
# Mock TOKEN
LINK_ADDRESS=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
# Mock AAVE POOL
MOCK_AAVE_POOL_ADDRESS=0x0165878A594ca255338adfa4d48449f69242Eb8F
Replace these example addresses with the actual addresses from your deployment output.
Configure Telegram (Optional)
For Telegram notifications:# Telegram Bot Token & Chat/Channel ID
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHANNEL_ID=your_channel_id
Create a Telegram bot via @BotFather to get your bot token.
Configuration Reference
Enable debug logging for the ADK framework.Set to "true" to see detailed framework logs.
Your OpenRouter API key for AI model access.The agents use OpenRouter to access LLM models like Claude.
LLM_MODEL
string
default:"anthropic/claude-3.5-sonnet"
Port for the main agent server.
Port for the chat agent server.
Ethereum RPC endpoint URL.Use http://127.0.0.1:8545 for local Hardhat node.
Private key for the agent’s wallet to sign transactions.
Address of the deployed MetaVault contract.
Address of the deployed Router contract.
STRATEGY_LEVERAGE_ADDRESS
Address of the Aave Leverage Strategy contract.
Address of the Aave V3 Strategy contract.
Address of the LINK token (or mock LINK for testing).
Address of the mock Aave pool contract.
Token for your Telegram bot.Optional. Used for sending strategy alerts and notifications.
Telegram channel or chat ID for notifications.Optional. Where the bot will send messages.
Frontend Configuration
The frontend requires contract addresses to interact with the blockchain.
Create Environment File
cd packages/frontend
cp .env.example .env.local
Configure Contract Addresses
Edit packages/frontend/.env.local:# RPC URL
RPC_URL=http://127.0.0.1:8545
# Private Key (for backend operations)
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# Agent API URL
AGENT_API_URL=http://localhost:3001
# CORE CONTRACTS
NEXT_PUBLIC_VAULT_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
NEXT_PUBLIC_ROUTER_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
NEXT_PUBLIC_STRATEGY_LEVERAGE_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
NEXT_PUBLIC_STRATEGY_AAVE_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9
# TOKENS
NEXT_PUBLIC_LINK_ADDRESS=0x5FC8d32690cc91D4c39d9d3abcBD16989F875707
All variables prefixed with NEXT_PUBLIC_ are exposed to the browser. Never put sensitive keys in these variables.
Configuration Reference
Ethereum RPC endpoint (not exposed to browser).
Private key for server-side operations (not exposed to browser).
URL of the AI agent server API.Should match the PORT configured in the agents package.
NEXT_PUBLIC_VAULT_ADDRESS
Address of the MetaVault contract (exposed to browser).
NEXT_PUBLIC_ROUTER_ADDRESS
Address of the Router contract (exposed to browser).
NEXT_PUBLIC_STRATEGY_LEVERAGE_ADDRESS
Address of the Aave Leverage Strategy contract (exposed to browser).
NEXT_PUBLIC_STRATEGY_AAVE_ADDRESS
Address of the Aave V3 Strategy contract (exposed to browser).
Address of the LINK token contract (exposed to browser).
Environment-Specific Configuration
Local Development
Testnet
Mainnet
Use Hardhat’s local network:RPC_URL=http://127.0.0.1:8545
Use Hardhat’s first test account:PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Use a testnet RPC (e.g., Sepolia via Infura):RPC_URL=https://sepolia.infura.io/v3/YOUR_INFURA_KEY
Use your testnet wallet private key:PRIVATE_KEY=your_testnet_private_key
Never commit private keys to version control. Use environment variables or secret management.
Use a mainnet RPC:RPC_URL=https://mainnet.infura.io/v3/YOUR_INFURA_KEY
Use a secure wallet and never expose your mainnet private key. Consider using a hardware wallet or secure key management service.
Validation
After configuration, verify your setup:
cd packages/contracts
pnpm hardhat compile
If all builds succeed, your configuration is correct.
Troubleshooting
Ensure your Hardhat node is running:cd packages/contracts
pnpm hardhat node
Contract Address Not Found
Make sure you’ve deployed the contracts:cd packages/contracts
pnpm hardhat run scripts/deploy_mocks.ts --network localhost
Copy the addresses from the deployment output to your .env files.
Verify your OpenRouter API key is correct and has credits.Check your account at openrouter.ai.
Change the PORT variables in your configuration:
Next Steps
Architecture
Understand how MetaVault AI components work together
AI Agents
Learn about the AI agents managing your vault