Deployment Guide

Complete guide for deploying Prophyt protocol components.

Overview

Prophyt consists of three main components that need to be deployed:

  1. Smart Contracts: Deployed on Sui blockchain
  2. Indexer: Event processing and REST API server
  3. 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

  1. Build Contracts
BASH
cd contracts sui move build
  1. Publish Contracts
BASH
sui client publish --gas-budget 100000000
  1. 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
  1. 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
  1. Register Nautilus Enclaves
BASH
sui 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

  1. Install Dependencies
BASH
cd indexer pnpm install
  1. Configure Environment
BASH
cp .env.example .env # Edit .env with your configuration
  1. Setup Database
BASH
# Using Docker Compose docker-compose up -d # Run migrations pnpm db:setup:dev pnpm db:generate
  1. Start Services
BASH
# Start API server pnpm dev # Start indexer (separate terminal) pnpm indexer

Production Deployment

  1. Build Application
BASH
pnpm build
  1. Database Setup
  • Set up PostgreSQL instance
  • Configure connection string
  • Run migrations
  1. Environment Variables
BASH
DATABASE_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
  1. 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
  1. 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

  1. Install Dependencies
BASH
cd nautilus-server cargo build
  1. Configure Environment
BASH
export DATABASE_URL=postgresql://user:password@localhost:5432/prophyt_indexer
  1. Run Server
BASH
cargo run

Production Deployment (AWS Nitro Enclaves)

  1. Build Docker Image
BASH
docker build -t prophyt-nautilus-server .
  1. Create Enclave Image
BASH
nitro-cli build-enclave \ --docker-uri prophyt-nautilus-server:latest \ --output-file nautilus-server.eif
  1. Deploy Enclave
  • Launch EC2 instance with Nitro Enclaves support
  • Configure network and storage
  • Run enclave with proper resource allocation
  1. Register on Chain
  • Extract PCRs from enclave
  • Register enclave in Prophyt NautilusRegistry contract
  • Provide public key and PCRs
  1. 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

  1. Install Dependencies
BASH
cd frontend pnpm install
  1. Configure Environment
BASH
NEXT_PUBLIC_API_URL=http://indexer-api:8000 NEXT_PUBLIC_NETWORK=mainnet NEXT_PUBLIC_PROPHYT_PACKAGE_ID=0x...
  1. Build
BASH
pnpm build
  1. 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

BASH
curl http://localhost:8000/

Nautilus Health

BASH
curl http://localhost:8080/health

Database Health

BASH
psql $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:

Previous
Code Examples