Files
smom-dbis-138/scripts/deployment/check-mainnet-balances.sh
defiQUG 1fb7266469 Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control.
- Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities.
- Created .gitmodules to include OpenZeppelin contracts as a submodule.
- Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment.
- Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks.
- Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring.
- Created scripts for resource import and usage validation across non-US regions.
- Added tests for CCIP error handling and integration to ensure robust functionality.
- Included various new files and directories for the orchestration portal and deployment scripts.
2025-12-12 14:57:48 -08:00

137 lines
4.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Check Mainnet ETH and LINK balances for deployment
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
# Load environment variables
if [ -f "$PROJECT_ROOT/.env" ]; then
source "$PROJECT_ROOT/.env"
else
log_error "Error: .env file not found"
exit 1
fi
log_info "=== Mainnet Wallet Balance Check ==="
# Check if cast is available
if ! command -v cast &> /dev/null; then
log_error "Error: cast (Foundry) not found. Please install Foundry."
exit 1
fi
# Get wallet address from private key
if [ -z "$PRIVATE_KEY" ]; then
log_error "Error: PRIVATE_KEY not set in .env"
exit 1
fi
WALLET_ADDRESS=$(cast wallet address --private-key "$PRIVATE_KEY" 2>/dev/null || echo "")
if [ -z "$WALLET_ADDRESS" ]; then
log_error "Error: Could not derive address from private key"
exit 1
fi
log_info "Wallet Address: $WALLET_ADDRESS"
# Mainnet RPC
if [ -z "$MAINNET_RPC_URL" ]; then
MAINNET_RPC_URL="https://eth.llamarpc.com"
fi
# Mainnet LINK token address
MAINNET_LINK="0x514910771AF9Ca656af840dff83E8264EcF986CA"
# Required amounts
ETH_RECOMMENDED="50000000000000000" # 0.05 ETH
LINK_RECOMMENDED="10000000000000000000" # 10 LINK
log_info "=== Mainnet ETH Balance ==="
# Check ETH balance
ETH_BALANCE=$(cast balance "$WALLET_ADDRESS" --rpc-url "$MAINNET_RPC_URL" 2>/dev/null || echo "0")
ETH_AMOUNT=$(cast --to-unit "$ETH_BALANCE" ether 2>/dev/null || echo "0")
echo "Balance: $ETH_AMOUNT ETH"
echo "Required: 0.025 ETH (minimum)"
echo "Recommended: 0.05 ETH (with buffer)"
# Check if sufficient
if [ "$(echo "$ETH_BALANCE >= $ETH_REQUIRED" | bc 2>/dev/null || echo "0")" == "1" ]; then
log_success "✅ Status: Sufficient ETH for deployment"
ETH_PASS=true
else
log_error "❌ Status: Insufficient ETH"
DEFICIT=$(echo "$ETH_REQUIRED - $ETH_BALANCE" | bc 2>/dev/null || echo "$ETH_REQUIRED")
DEFICIT_ETH=$(cast --to-unit "$DEFICIT" ether 2>/dev/null || echo "0.025")
log_warn "Need: $DEFICIT_ETH ETH more"
ETH_PASS=false
fi
log_info "=== Mainnet LINK Balance ==="
# Check LINK balance
LINK_BALANCE=$(cast call "$MAINNET_LINK" "balanceOf(address)(uint256)" "$WALLET_ADDRESS" --rpc-url "$MAINNET_RPC_URL" 2>/dev/null || echo "0")
if [ "$LINK_BALANCE" != "0" ] && [ -n "$LINK_BALANCE" ]; then
LINK_AMOUNT=$(cast --to-unit "$LINK_BALANCE" ether 2>/dev/null || echo "0")
echo "Balance: $LINK_AMOUNT LINK"
else
echo "Balance: 0 LINK"
LINK_AMOUNT="0"
fi
echo "Required: 0 LINK (not needed for deployment)"
echo "Recommended: 10 LINK (for CCIP fees and testing)"
# Check if sufficient (LINK is optional)
if [ "$(echo "$LINK_BALANCE >= $LINK_RECOMMENDED" | bc 2>/dev/null || echo "0")" == "1" ]; then
log_success "✅ Status: Sufficient LINK for CCIP fees"
LINK_PASS=true
elif [ "$LINK_BALANCE" != "0" ] && [ -n "$LINK_BALANCE" ]; then
log_warn "⚠️ Status: LINK available but below recommended amount"
LINK_PASS=true # Still pass, just a warning
else
log_warn "⚠️ Status: No LINK (not required for deployment)"
log_warn "Note: LINK is only needed for CCIP fees when users bridge tokens"
LINK_PASS=true # Pass because LINK is optional for deployment
fi
# Summary
log_info "=== Summary ==="
if [ "$ETH_PASS" == "true" ]; then
log_success "✅ ETH: Sufficient for Mainnet deployment"
else
log_error "❌ ETH: Insufficient - Please fund wallet"
echo "Send ETH to: $WALLET_ADDRESS"
echo "Amount needed: $DEFICIT_ETH ETH"
fi
if [ "$LINK_PASS" == "true" ] && [ "$LINK_AMOUNT" != "0" ]; then
log_success "✅ LINK: Available for CCIP fees"
elif [ "$LINK_PASS" == "true" ]; then
log_warn "⚠️ LINK: Not available (optional for deployment)"
fi
if [ "$ETH_PASS" == "true" ]; then
log_success "✅ Ready for Mainnet deployment!"
echo "You can proceed with:"
echo " ./scripts/deployment/deploy-bridges-mainnet.sh"
exit 0
else
log_error "❌ Not ready for Mainnet deployment"
echo "Please fund your wallet:"
echo " Address: $WALLET_ADDRESS"
echo " Amount: $DEFICIT_ETH ETH minimum (0.05 ETH recommended)"
exit 1
fi