4.2 KiB
4.2 KiB
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
# 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
# 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
# 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
# Server Configuration
PORT=3001
NODE_ENV=production
Contracts Environment Variables
File: contracts/.env
Required Variables
# 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
# 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
- Primary:
- 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
-
Copy example files:
cd frontend && cp .env.example .env.local cd ../backend && cp .env.example .env cd ../contracts && cp .env.example .env -
Fill in values:
- Update database credentials
- Add RPC URLs
- Add contract addresses after deployment
- Add API keys as needed
-
Never commit .env files:
- All
.envfiles are in.gitignore - Only commit
.env.examplefiles
- All
Security Notes
- ⚠️ Never commit
.envfiles 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)