Skip to main content

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.
1

Create Environment File

cd packages/contracts
cp .env.example .env
2

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
string
required
Private key of the wallet that will deploy contracts.For local development, use one of Hardhat’s test account private keys.
INFURA_KEY
string
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.
1

Create Environment File

cd packages/agents/defi-portfolio
cp .env.example .env
2

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
Get your OpenRouter API key at openrouter.ai
3

Configure Blockchain Connection

Add blockchain settings:
# RPC URL
RPC_URL=http://127.0.0.1:8545

# Vault Deployer Wallet Private Key
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
4

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.
5

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

ADK_DEBUG
string
default:"false"
Enable debug logging for the ADK framework.Set to "true" to see detailed framework logs.
OPEN_ROUTER_KEY
string
required
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"
The LLM model to use for AI agents.See OpenRouter models for available options.
PORT
number
default:"3001"
Port for the main agent server.
CHAT_PORT
number
default:"3002"
Port for the chat agent server.
RPC_URL
string
required
Ethereum RPC endpoint URL.Use http://127.0.0.1:8545 for local Hardhat node.
PRIVATE_KEY
string
required
Private key for the agent’s wallet to sign transactions.
VAULT_ADDRESS
string
required
Address of the deployed MetaVault contract.
ROUTER_ADDRESS
string
required
Address of the deployed Router contract.
STRATEGY_LEVERAGE_ADDRESS
string
required
Address of the Aave Leverage Strategy contract.
STRATEGY_AAVE_ADDRESS
string
required
Address of the Aave V3 Strategy contract.
Address of the LINK token (or mock LINK for testing).
MOCK_AAVE_POOL_ADDRESS
string
required
Address of the mock Aave pool contract.
TELEGRAM_BOT_TOKEN
string
Token for your Telegram bot.Optional. Used for sending strategy alerts and notifications.
TELEGRAM_CHANNEL_ID
string
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.
1

Create Environment File

cd packages/frontend
cp .env.example .env.local
2

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

RPC_URL
string
Ethereum RPC endpoint (not exposed to browser).
PRIVATE_KEY
string
Private key for server-side operations (not exposed to browser).
AGENT_API_URL
string
URL of the AI agent server API.Should match the PORT configured in the agents package.
NEXT_PUBLIC_VAULT_ADDRESS
string
required
Address of the MetaVault contract (exposed to browser).
NEXT_PUBLIC_ROUTER_ADDRESS
string
required
Address of the Router contract (exposed to browser).
NEXT_PUBLIC_STRATEGY_LEVERAGE_ADDRESS
string
required
Address of the Aave Leverage Strategy contract (exposed to browser).
NEXT_PUBLIC_STRATEGY_AAVE_ADDRESS
string
required
Address of the Aave V3 Strategy contract (exposed to browser).
Address of the LINK token contract (exposed to browser).

Environment-Specific Configuration

Use Hardhat’s local network:
RPC_URL=http://127.0.0.1:8545
Use Hardhat’s first test account:
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

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
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:
PORT=3003
CHAT_PORT=3004

Next Steps

Architecture

Understand how MetaVault AI components work together

AI Agents

Learn about the AI agents managing your vault

Build docs developers (and LLMs) love