Coordinator Setup
Deploy and run the Veil coordinator service.
Overview
The coordinator monitors payment schedules and executes them via MagicBlock Ephemeral Rollups (ER) for privacy.
Flow:
- Polls Solana for schedules due for execution
- Delegates schedule to ER
- Executes
claim_paymentfor each recipient (private in TEE) - Commits state back to Solana
- Undelegates schedule
Prerequisites
- Node.js 18+
- PostgreSQL database
- ER authority keypair
- Solana RPC endpoint
Installation
cd coordinator
yarn installDatabase Setup
- Create PostgreSQL database:
createdb veil_coordinator- Configure database URL in
.env:
DATABASE_URL=postgresql://user:password@localhost:5432/veil_coordinator- Generate and run migrations:
yarn db:generate
yarn db:migrate- (Optional) Use Drizzle Studio to inspect database:
yarn db:studioConfiguration
Copy .env.example to .env and configure the following environment variables:
Solana Configuration
SOLANA_RPC_URL=https://api.devnet.solana.comOptions:
- Devnet:
https://api.devnet.solana.com - Mainnet:
https://api.mainnet-beta.solana.com - Custom RPC: Your RPC provider URL
ER Configuration
ER_RPC_URL=https://devnet.magicblock.app
ER_VALIDATOR=MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd
ER_AUTHORITY_KEYPAIR_PATH=./er-authority-keypair.jsonER Authority Keypair:
- Must have authority to execute claims
- Generate with Solana CLI:
solana-keygen new -o er-authority-keypair.json
Server Configuration
PORT=3001
POLL_INTERVAL_MS=60000Poll Interval:
- How often to check for due schedules (milliseconds)
- Default: 60000 (1 minute)
- Lower = more frequent checks, higher RPC usage
Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/veil_coordinator
DB_POOL_MAX=10Connection Pool:
DB_POOL_MAX- Maximum database connections- Default: 10
- Increase for high load
Complete Example .env File
# Solana
SOLANA_RPC_URL=https://api.devnet.solana.com
# ER Configuration
ER_RPC_URL=https://devnet.magicblock.app
ER_VALIDATOR=MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd
ER_AUTHORITY_KEYPAIR_PATH=./er-authority-keypair.json
# Server
PORT=3001
POLL_INTERVAL_MS=60000
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/veil_coordinator
DB_POOL_MAX=10Production Considerations
- Use environment-specific RPC endpoints
- Secure ER authority keypair (never commit to git)
- Use connection pooling for database
- Set appropriate poll intervals
- Monitor RPC rate limits
ER Validators
Available ER validators:
- US:
MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd(devnet-us.magicblock.app) - EU:
MEUGGrYPxKk17hCr7wpT6s8dtNokZj5U2L57vjYMS8e(devnet-eu.magicblock.app) - Asia:
MAS1Dt9qreoRMQ14YQuhg8UTZMMzDdKhmkZMECCzk57(devnet-as.magicblock.app) - TEE:
FnE6VJT5QNZdedZPnCoLsARgBwoE6DeJNjBs2H1gySXA(tee.magicblock.app)
Running
Development
yarn devProduction
yarn build
yarn start