Files
solace-bg-dubai/ENV_CONFIGURATION.md

167 lines
4.2 KiB
Markdown
Raw Permalink Normal View History

# Environment Configuration Guide
This document describes all environment variables used in the Solace Treasury DApp.
## Overview
The project uses environment variables across three workspaces:
- **Frontend**: Next.js public environment variables
- **Backend**: Server-side configuration
- **Contracts**: Hardhat deployment configuration
## Frontend Environment Variables
**File**: `frontend/.env.local` (development) or `.env.production` (production)
### Required Variables
```env
# WalletConnect Project ID
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_project_id_here
# Chain 138 Configuration (Primary Network)
NEXT_PUBLIC_CHAIN138_RPC_URL=http://192.168.11.250:8545
NEXT_PUBLIC_CHAIN138_WS_URL=ws://192.168.11.250:8546
NEXT_PUBLIC_CHAIN_ID=138
# Contract Addresses (after deployment)
NEXT_PUBLIC_TREASURY_WALLET_ADDRESS=0x...
NEXT_PUBLIC_SUB_ACCOUNT_FACTORY_ADDRESS=0x...
```
### Optional Variables
```env
# Other Network Support
NEXT_PUBLIC_SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
NEXT_PUBLIC_MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
```
**Note**: All frontend variables must be prefixed with `NEXT_PUBLIC_` to be accessible in the browser.
## Backend Environment Variables
**File**: `backend/.env`
### Required Variables
```env
# Database Configuration
DATABASE_URL=postgresql://user:password@host:port/database
# Chain 138 Configuration
RPC_URL=http://192.168.11.250:8545
CHAIN_ID=138
# Contract Address (after deployment)
CONTRACT_ADDRESS=0x...
```
### Optional Variables
```env
# Server Configuration
PORT=3001
NODE_ENV=production
```
## Contracts Environment Variables
**File**: `contracts/.env`
### Required Variables
```env
# Chain 138 RPC URL (Primary Network)
CHAIN138_RPC_URL=http://192.168.11.250:8545
# Deployment Account
PRIVATE_KEY=0x...your_private_key_here
```
### Optional Variables
```env
# Other Networks
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
# Block Explorer API Keys (for contract verification)
ETHERSCAN_API_KEY=your_key
POLYGONSCAN_API_KEY=your_key
OPTIMISTIC_ETHERSCAN_API_KEY=your_key
BASESCAN_API_KEY=your_key
GNOSIS_API_KEY=your_key
# Cloudflare (if using Cloudflare tunnels)
CLOUDFLARE_TUNNEL_TOKEN=...
CLOUDFLARE_API_KEY=...
CLOUDFLARE_ACCOUNT_ID=...
CLOUDFLARE_ZONE_ID=...
CLOUDFLARE_DOMAIN=...
# MetaMask/Infura (optional)
METAMASK_API_KEY=...
METAMASK_SECRET=...
INFURA_GAS_API=...
```
## Chain 138 Configuration
Chain 138 is the primary network for this DApp. Default configuration:
- **Chain ID**: 138
- **RPC Endpoints**:
- Primary: `http://192.168.11.250:8545`
- Backup 1: `http://192.168.11.251:8545`
- Backup 2: `http://192.168.11.252:8545`
- **WebSocket**: `ws://192.168.11.250:8546`
- **Block Explorer**: `http://192.168.11.140`
- **Network Type**: Custom Besu (QBFT consensus)
- **Gas Price**: 0 (zero base fee)
## Environment File Structure
```
solace-bg-dubai/
├── frontend/
│ ├── .env.local # Local development (gitignored)
│ ├── .env.production # Production build (gitignored)
│ └── .env.example # Template file
├── backend/
│ ├── .env # Backend API config (gitignored)
│ ├── .env.indexer # Indexer config (gitignored)
│ └── .env.example # Template file
└── contracts/
├── .env # Deployment config (gitignored)
└── .env.example # Template file
```
## Setup Instructions
1. **Copy example files**:
```bash
cd frontend && cp .env.example .env.local
cd ../backend && cp .env.example .env
cd ../contracts && cp .env.example .env
```
2. **Fill in values**:
- Update database credentials
- Add RPC URLs
- Add contract addresses after deployment
- Add API keys as needed
3. **Never commit .env files**:
- All `.env` files are in `.gitignore`
- Only commit `.env.example` files
## Security Notes
- ⚠️ Never commit `.env` files to git
- ⚠️ Use strong database passwords
- ⚠️ Protect private keys (use hardware wallets for mainnet)
- ⚠️ Rotate API keys regularly
- ⚠️ Use environment-specific values (dev/staging/prod)