Deployment Guide
Complete guide for deploying Prophyt protocol components.
Overview
Prophyt consists of three main components that need to be deployed:
- Smart Contracts: Deployed on Sui blockchain
- Indexer: Event processing and REST API server
- Nautilus Server: Trust oracle server (optional, for enclave-based resolution)
Smart Contract Deployment
Prerequisites
- Sui CLI installed and configured
- Sui wallet with sufficient SUI for gas
- Access to Sui network (mainnet/testnet/devnet)
Deployment Steps
- Build Contracts
BASHcd contracts sui move build
- Publish Contracts
BASHsui client publish --gas-budget 100000000
- Initialize Components
After publishing, initialize each component:
BASH# Initialize prediction market sui client call --package <PACKAGE_ID> \ --module prediction_market \ --function initialize \ --args <fee_recipient> <protocol_fee> <transaction_fee> \ --gas-budget 10000000 # Initialize protocol registry sui client call --package <PACKAGE_ID> \ --module protocol_selector \ --function initialize \ --args <min_apy_threshold> <max_risk_tolerance> \ --gas-budget 10000000 # Initialize protocol adapters sui client call --package <PACKAGE_ID> \ --module suilend_adapter \ --function initialize \ --args <initial_apy> \ --gas-budget 10000000 # Initialize Prophyt agent sui client call --package <PACKAGE_ID> \ --module prophyt_agent \ --function initialize \ --args <rebalance_threshold> <min_rebalance_amount> <rebalance_interval> \ --gas-budget 10000000 # Initialize Nautilus registry sui client call --package <PACKAGE_ID> \ --module nautilus_oracle \ --function initialize \ --gas-budget 10000000
- Register Protocols
BASH# Register Suilend sui client call --package <PACKAGE_ID> \ --module protocol_selector \ --function register_protocol \ --args <registry_id> <protocol_type> <protocol_address> <state_id> <risk_level> \ --gas-budget 10000000 # Register Haedal # Register Volo
- Register Nautilus Enclaves
BASHsui client call --package <PACKAGE_ID> \ --module nautilus_oracle \ --function register_enclave \ --args <registry_id> <public_key> <pcrs> <name> \ --gas-budget 10000000
Configuration
Store all object IDs and package IDs for use in indexer and frontend:
BASH# Create config file cat > .env << EOF PROPHYT_PACKAGE_ID=<package_id> PREDICTION_MARKET_STATE=<state_object_id> PROTOCOL_REGISTRY=<registry_object_id> SUILEND_STATE=<suilend_state_id> HAEDAL_STATE=<haedal_state_id> VOLO_STATE=<volo_state_id> NAUTILUS_REGISTRY=<nautilus_registry_id> EOF
Indexer Deployment
Prerequisites
- Node.js >= 18.0.0
- PostgreSQL database
- pnpm package manager
- Sui network access
Local Development
- Install Dependencies
BASHcd indexer pnpm install
- Configure Environment
BASHcp .env.example .env # Edit .env with your configuration
- Setup Database
BASH# Using Docker Compose docker-compose up -d # Run migrations pnpm db:setup:dev pnpm db:generate
- Start Services
BASH# Start API server pnpm dev # Start indexer (separate terminal) pnpm indexer
Production Deployment
- Build Application
BASHpnpm build
- Database Setup
- Set up PostgreSQL instance
- Configure connection string
- Run migrations
- Environment Variables
BASHDATABASE_URL=postgresql://user:password@host:5432/database NETWORK=mainnet PROPHYT_PACKAGE_ID=0x... NAUTILUS_SERVER_URL=http://nautilus-server:8080 WALRUS_CLI_PATH=/path/to/walrus PORT=8000
- Process Management
Using PM2:
BASH# Install PM2 npm install -g pm2 # Start API server pm2 start dist/server.js --name prophyt-api # Start indexer pm2 start dist/indexer.js --name prophyt-indexer # Save PM2 configuration pm2 save pm2 startup
- Docker Deployment
BASH# Build image docker build -t prophyt-indexer . # Run container docker run -d \ --name prophyt-indexer \ -p 8000:8000 \ --env-file .env \ prophyt-indexer
Monitoring
- Monitor event processing cursor advancement
- Track API response times and error rates
- Monitor database connection pool
- Track Walrus upload success rates
- Monitor market resolution success rates
Nautilus Server Deployment
Prerequisites
- Rust 1.75+
- PostgreSQL database (shared with indexer)
- AWS Nitro Enclaves SDK (for production)
Local Development
- Install Dependencies
BASHcd nautilus-server cargo build
- Configure Environment
BASHexport DATABASE_URL=postgresql://user:password@localhost:5432/prophyt_indexer
- Run Server
BASHcargo run
Production Deployment (AWS Nitro Enclaves)
- Build Docker Image
BASHdocker build -t prophyt-nautilus-server .
- Create Enclave Image
BASHnitro-cli build-enclave \ --docker-uri prophyt-nautilus-server:latest \ --output-file nautilus-server.eif
- Deploy Enclave
- Launch EC2 instance with Nitro Enclaves support
- Configure network and storage
- Run enclave with proper resource allocation
- Register on Chain
- Extract PCRs from enclave
- Register enclave in Prophyt NautilusRegistry contract
- Provide public key and PCRs
- Configure Database
- Ensure database is accessible from enclave
- Configure connection string
- Verify database schema is initialized
Frontend Deployment
Prerequisites
- Node.js >= 18.0.0
- pnpm package manager
- Access to indexer API
Build and Deploy
- Install Dependencies
BASHcd frontend pnpm install
- Configure Environment
BASHNEXT_PUBLIC_API_URL=http://indexer-api:8000 NEXT_PUBLIC_NETWORK=mainnet NEXT_PUBLIC_PROPHYT_PACKAGE_ID=0x...
- Build
BASHpnpm build
- Deploy
Deploy to Vercel, Netlify, or your preferred hosting:
BASH# Vercel vercel deploy --prod # Or use Docker docker build -t prophyt-frontend . docker run -p 3000:3000 prophyt-frontend
Health Checks
Indexer Health
BASHcurl http://localhost:8000/
Nautilus Health
BASHcurl http://localhost:8080/health
Database Health
BASHpsql $DATABASE_URL -c "SELECT 1"
Backup and Recovery
Database Backups
BASH# Backup pg_dump $DATABASE_URL > backup.sql # Restore psql $DATABASE_URL < backup.sql
Event Cursor Backup
Cursors are stored in the database. Regular database backups include cursor state.
Scaling Considerations
Indexer Scaling
- Run multiple indexer instances with shared database
- Use connection pooling for database
- Implement rate limiting for API
- Use caching for frequently accessed data
Database Scaling
- Use read replicas for query load
- Implement connection pooling
- Monitor query performance
- Optimize slow queries
API Scaling
- Use load balancer for multiple API instances
- Implement caching layer (Redis)
- Use CDN for static assets
- Monitor and scale based on load
Security Checklist
- Use HTTPS in production
- Secure database connections
- Implement API authentication
- Store secrets in environment variables
- Use secure enclave for Nautilus
- Regular security updates
- Monitor for suspicious activity
- Implement rate limiting
- Validate all inputs
- Use parameterized queries
Troubleshooting
Common Issues
Indexer not processing events:
- Check Sui network connection
- Verify package ID is correct
- Check database connection
- Review cursor state
API not responding:
- Check server logs
- Verify database connection
- Check environment variables
- Review error messages
Nautilus not responding:
- Check enclave health
- Verify database connection
- Check network connectivity
- Review server logs
Support
For deployment issues:
- GitHub Issues
- X - Latest updates
- Documentation
