CoordinatorSetup & Deployment

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:

  1. Polls Solana for schedules due for execution
  2. Delegates schedule to ER
  3. Executes claim_payment for each recipient (private in TEE)
  4. Commits state back to Solana
  5. Undelegates schedule

Prerequisites

  • Node.js 18+
  • PostgreSQL database
  • ER authority keypair
  • Solana RPC endpoint

Installation

cd coordinator
yarn install

Database Setup

  1. Create PostgreSQL database:
createdb veil_coordinator
  1. Configure database URL in .env:
DATABASE_URL=postgresql://user:password@localhost:5432/veil_coordinator
  1. Generate and run migrations:
yarn db:generate
yarn db:migrate
  1. (Optional) Use Drizzle Studio to inspect database:
yarn db:studio

Configuration

Copy .env.example to .env and configure the following environment variables:

Solana Configuration

SOLANA_RPC_URL=https://api.devnet.solana.com

Options:

  • 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.json

ER 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=60000

Poll 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=10

Connection 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=10

Production 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 dev

Production

yarn build
yarn start