This document outlines all environment variables and configuration needed for both frontend and backend components of the CloutCards application.
The CloutCards application consists of:
- Backend: Express.js server (Node.js/TypeScript)
- Frontend: React application (Vite)
- Database: PostgreSQL (local via Docker Compose, production via AWS RDS)
- Blockchain: Anvil (local) or production network
DB_HOST- PostgreSQL host (RDS endpoint)DB_USERNAME- PostgreSQL usernameDB_PASSWORD- PostgreSQL passwordDB_NAME- PostgreSQL database nameCHAIN_ID- Ethereum chain ID (e.g.,84532for Base Sepolia)MNEMONIC- TEE wallet mnemonic for signing eventsAPP_PORT- Express server port (defaults to3000if not set)
DB_PORT- PostgreSQL port (defaults to5432)TEE_VERSION- TEE binary version (defaults to1)ADMIN_ADDRESSES- Comma-separated list of admin addresses (production only, defaults to empty)CLOUTCARDS_CONTRACT_ADDRESS- Address of the deployed CloutCards proxy contract (required for contract interactions)NODE_ENV- Set toproductionto enable production modeENVIRONMENT- Alternative toNODE_ENV, set toproductionfor production mode
The backend uses hardcoded defaults for local development (no env vars needed):
- Database:
localhost:5432/cloutcards/cloutcards/cloutcards_dev - Chain ID:
31337(Anvil default) - Server Port:
3000 - Admin Addresses: Anvil's first default address (
0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266) - Contract Address: Not set by default - must be provided via
CLOUTCARDS_CONTRACT_ADDRESSenv var or command line
Production mode is enabled when:
NODE_ENV === 'production'ORENVIRONMENT === 'production'
Otherwise, local development defaults are used.
VITE_TEE_ENDPOINT- Full URL of the TEE backend (e.g.,https://tee.example.com)
Important: Vite requires environment variables to be prefixed with VITE_ to be exposed to client code.
VITE_TEE_TIMEOUT- Request timeout in milliseconds (default:30000/ 30 seconds)VITE_TEE_API_VERSION- API version to use (default:v1)VITE_ENVIRONMENT- Set toproductionto enable production mode
The frontend uses hardcoded defaults for local development (no env vars needed):
- TEE Endpoint:
http://localhost:8000 - Timeout:
30000ms(30 seconds) - API Version:
v1
Production mode is enabled when:
import.meta.env.MODE === 'production'ORVITE_ENVIRONMENT === 'production'
Otherwise, local development defaults are used.
# Production Database (required in production)
DB_HOST=your-rds-endpoint.region.rds.amazonaws.com
DB_USERNAME=your_username
DB_PASSWORD=your_password
DB_NAME=your_database
# Blockchain (required in production)
CHAIN_ID=84532
# TEE (required in production)
MNEMONIC=your twelve word mnemonic phrase here
# Admins (optional - defaults to empty array if not set)
ADMIN_ADDRESSES=0x1234567890123456789012345678901234567890,0xabcdefabcdefabcdefabcdefabcdefabcdefabcd
# Server (optional)
APP_PORT=3000
TEE_VERSION=1
# Contract Address (required for contract interactions)
CLOUTCARDS_CONTRACT_ADDRESS=0x1234567890123456789012345678901234567890
# Environment (optional - set to 'production' for production)
NODE_ENV=production
# OR
ENVIRONMENT=production# TEE Backend (required in production)
VITE_TEE_ENDPOINT=https://tee.example.com
# Optional
VITE_TEE_TIMEOUT=30000
VITE_TEE_API_VERSION=v1
VITE_ENVIRONMENT=productionNote: For local development, you don't need to create .env files - the application will use hardcoded defaults.
The backend does NOT include a TEE service layer or make RPC calls to the TEE backend. The backend:
- Manages database connections and migrations
- Handles event logging and EIP-712 signing (using
MNEMONICenv var) - Provides Express API endpoints
- Does NOT make RPC calls to TEE backend
- Does NOT need
TEE_ENDPOINTor any TEE-related environment variables
The frontend includes a TEE service layer (frontend/src/services/tee.ts) that:
- Makes RPC calls to the TEE backend
- Handles request/response formatting
- Provides error handling and timeouts
- Uses environment-based configuration (via
VITE_TEE_ENDPOINT)
Backend:
- No
.envfile needed - Database: Docker Compose (PostgreSQL on
localhost:5432) - Chain: Anvil (chain ID
31337) - Server:
http://localhost:3000
Frontend:
- No
.envfile needed - TEE Backend:
http://localhost:8000(default) - Dev Server:
http://localhost:5173(Vite default)
Backend:
.envfile required with:DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAMECHAIN_IDMNEMONICADMIN_ADDRESSES(optional - comma-separated list of admin addresses)NODE_ENV=productionorENVIRONMENT=production
Frontend:
.envfile required with:VITE_TEE_ENDPOINTVITE_ENVIRONMENT=production(optional, but recommended)
curl http://localhost:3000/healthResponse:
{
"status": "ok"
}curl http://localhost:8000/adminsResponse (Local):
["0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"]Response (Production):
["0x1234567890123456789012345678901234567890","0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"]Or empty array if ADMIN_ADDRESSES is not set:
[]The frontend can check TEE backend health using:
import { checkTeeHealth } from './services/tee';
const isHealthy = await checkTeeHealth();-
Database Connection Errors
- Verify Docker Compose is running:
docker-compose ps - Check database credentials match Docker Compose config
- Ensure
DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAMEare set in production
- Verify Docker Compose is running:
-
Chain ID Errors
- Local: Should default to
31337(Anvil) - Production: Must set
CHAIN_IDenvironment variable
- Local: Should default to
-
TEE Signing Errors (for event signing, not RPC calls)
- Ensure
MNEMONICis set in production - Verify mnemonic is valid (12 words)
- Note: Backend does NOT make RPC calls to TEE - only signs events
- Ensure
-
TEE Connection Errors
- Verify TEE backend is running on expected port
- Check
VITE_TEE_ENDPOINTis set correctly in production - Ensure CORS is configured on TEE backend
-
Environment Variables Not Working
- Remember: Frontend env vars must be prefixed with
VITE_ - Restart Vite dev server after changing
.envfile - Check
import.meta.envin browser console
- Remember: Frontend env vars must be prefixed with
-
CORS Errors
- TEE backend must allow requests from frontend origin
- For local dev: TEE should allow
http://localhost:5173
| Component | Local Defaults | Production Required |
|---|---|---|
| Backend | ||
| Database | localhost:5432 / cloutcards / cloutcards / cloutcards_dev |
DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME |
| Chain ID | 31337 (Anvil) |
CHAIN_ID |
| TEE Mnemonic | N/A | MNEMONIC (for signing events) |
| Server Port | 3000 |
APP_PORT (optional) |
| Admin Addresses | Anvil default (0xf39Fd6...) |
ADMIN_ADDRESSES (comma-separated, optional) |
| Contract Address | Not set (must provide) | CLOUTCARDS_CONTRACT_ADDRESS |
| TEE Endpoint | N/A - Backend does not call TEE | N/A |
| Frontend | ||
| TEE Endpoint | http://localhost:8000 |
VITE_TEE_ENDPOINT |
| Timeout | 30000ms |
VITE_TEE_TIMEOUT (optional) |
| API Version | v1 |
VITE_TEE_API_VERSION (optional) |