Skip to main content

Overview

Proteus runs on BASE (Coinbase L2) and deploys to two environments:
  • Testnet (BASE Sepolia): For development and testing (current deployment)
  • Mainnet (BASE): For production (not yet deployed)

Current Deployment

The production testnet deployment is running on Railway:
ComponentProviderURL/Address
BackendRailwayproteus-production-6213.up.railway.app
RedisRailwayInternal
ContractsBASE SepoliaSee Contract Addresses

Railway Deployment

The Flask backend auto-deploys from the main branch on GitHub.

Railway Configuration

1

Connect Repository

  1. Log in to Railway
  2. Create a new project
  3. Connect your GitHub repository
  4. Select the main branch for auto-deployment
2

Add Redis

Add a Redis instance to your Railway project:
  1. Click + New
  2. Select Database > Redis
  3. Railway will automatically set the REDIS_URL environment variable
3

Configure Environment Variables

Set the following environment variables in Railway:
# Network
NETWORK=base-sepolia
CHAIN_ID=84532
RPC_URL=https://sepolia.base.org

# Security
JWT_SECRET_KEY=your_secret_key_here
SESSION_SECRET=your_session_secret_here

# Firebase
FIREBASE_API_KEY=your_key
FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
FIREBASE_PROJECT_ID=your-project
FIREBASE_APP_ID=your_app_id

# Coinbase
COINBASE_PROJECT_ID=your_project_id

# Contracts
DEPLOYER_PRIVATE_KEY=your_private_key

# X.com API (optional)
XCOM_BEARER_TOKEN=your_bearer_token

# Redis (auto-configured by Railway)
REDIS_URL=redis://...
4

Configure Start Command

Railway uses railway.json for configuration. The start command is:
railway.json
{
  "$schema": "https://railway.app/railway.schema.json",
  "build": {
    "builder": "NIXPACKS"
  },
  "deploy": {
    "startCommand": "gunicorn main:app --bind 0.0.0.0:$PORT --workers 4 --timeout 120",
    "restartPolicyType": "ON_FAILURE",
    "restartPolicyMaxRetries": 10
  }
}
5

Deploy

Push to main to trigger automatic deployment:
git add .
git commit -m "Deploy to Railway"
git push origin main
Watch the deployment logs in the Railway dashboard.

Health Checks

Railway monitors the /health endpoint:
curl https://proteus-production-6213.up.railway.app/health
Expected response:
{
  "status": "healthy",
  "redis": "connected",
  "blockchain": "connected"
}

Contract Deployment

Deploy to BASE Sepolia Testnet

1

Configure Hardhat

Ensure your hardhat.config.js includes BASE Sepolia:
hardhat.config.js
module.exports = {
  networks: {
    baseSepolia: {
      url: process.env.RPC_URL || "https://sepolia.base.org",
      accounts: [process.env.DEPLOYER_PRIVATE_KEY],
      chainId: 84532
    }
  }
};
2

Fund Deployer Wallet

Get test ETH from the BASE Sepolia faucet.Request at least 0.1 ETH to your deployer wallet.
3

Compile Contracts

npx hardhat compile
4

Deploy Contracts

Deploy PredictionMarketV2 and related contracts:
make deploy-testnet
Save the deployed contract addresses from the output.
5

Verify on Basescan

Verify your contracts on Basescan for transparency:
npx hardhat verify --network baseSepolia <CONTRACT_ADDRESS>
For contracts with constructor arguments:
npx hardhat verify --network baseSepolia <CONTRACT_ADDRESS> "arg1" "arg2"

Contract Addresses

Current deployed contracts on BASE Sepolia:
ContractAddressExplorer
PredictionMarketV20x5174Da96BCA87c78591038DEe9DB1811288c9286View
GenesisNFT0x1A5D4475881B93e876251303757E60E524286A24View
PayoutManager0x142F944868596Eb0b35340f29a727b0560B130f7View
PredictionMarket V1 (0x667121e8f22570F2c521454D93D6A87e44488d93) is deprecated and should not be used. It lacks a resolution mechanism.

Seed Example Markets

The scripts/seed_examples.py script creates 6 example markets demonstrating different prediction scenarios:
1

Configure Wallets

Set environment variables for test wallets:
export OWNER_PRIVATE_KEY=your_owner_key
export TEST_WALLET_KEY_1=test_wallet_1
export TEST_WALLET_KEY_2=test_wallet_2
export TEST_WALLET_KEY_3=test_wallet_3
export TEST_WALLET_KEY_4=test_wallet_4
export BASE_SEPOLIA_RPC_URL=https://sepolia.base.org
2

Preview (Dry Run)

See what will be created without sending transactions:
python scripts/seed_examples.py --dry-run
3

Create Markets

Create markets and submissions:
python scripts/seed_examples.py
This creates 6 markets with different prediction quality examples.
4

Resolve Markets

After markets end, resolve them:
python scripts/seed_examples.py --resolve

Production Deployment (BASE Mainnet)

Proteus is not yet deployed to mainnet. Before mainnet deployment:
DO NOT deploy to mainnet without completing these prerequisites:

Prerequisites Checklist

1

Security Audit

  • Complete external security audit of all contracts
  • Address all high and medium severity findings
  • Get audit report published
2

Decentralize Resolution

  • Implement multi-oracle consensus (commit-reveal)
  • Add slashing for dishonest oracles
  • Require screenshot proofs (IPFS-pinned)
3

Production Infrastructure

  • Set up hardware wallet for deployer
  • Implement multisig for contract owner (Gnosis Safe 2-of-3)
  • Use production RPC (Alchemy/QuickNode)
  • Set up monitoring (Sentry, Datadog)
  • Configure alerting for critical events
4

Real Wallet Integration

  • Replace PBKDF2 shim with Coinbase CDP Server Signer
  • Test with real Coinbase wallet credentials
  • Implement proper key rotation
5

Validate Demand

  • Test on testnet with real users
  • Confirm product-market fit
  • Gather feedback and iterate

Mainnet Configuration

When ready for mainnet, update environment variables:
.env
# BASE Mainnet
NETWORK=base-mainnet
CHAIN_ID=8453
RPC_URL=https://base-mainnet.g.alchemy.com/v2/YOUR_API_KEY

# Production security
DEPLOYER_PRIVATE_KEY=hardware_wallet
JWT_SECRET_KEY=strong_random_secret
SESSION_SECRET=strong_random_secret

# Production RPC
ALCHEMY_API_KEY=your_alchemy_key
QUICKNODE_URL=your_quicknode_url

Mainnet Deployment Steps

1

Final Testing

Run full test suite and load tests:
make test-all
locust -f tests/load/locustfile.py
2

Deploy Contracts

Deploy using hardware wallet:
npx hardhat run scripts/deploy-genesis-phase1.js --network baseMainnet
3

Transfer Ownership to Multisig

Transfer contract ownership to Gnosis Safe:
await contract.transferOwnership(GNOSIS_SAFE_ADDRESS);
4

Verify Contracts

npx hardhat verify --network baseMainnet <CONTRACT_ADDRESS>
5

Monitor

Watch deployment logs and metrics:
  • Contract interactions
  • Gas usage
  • Error rates
  • User activity

Monitoring

Backend Monitoring

Key metrics to monitor:
  • Response times: API endpoint latency
  • Error rates: 4xx/5xx responses
  • Redis health: Connection status, memory usage
  • Blockchain health: RPC latency, failed transactions

Contract Monitoring

Monitor on-chain events:
// Listen for MarketCreated events
contract.on("MarketCreated", (marketId, creator, actorHandle) => {
  console.log(`New market: ${marketId} by ${creator}`);
});

// Listen for MarketResolved events
contract.on("MarketResolved", (marketId, winnerId) => {
  console.log(`Market ${marketId} resolved, winner: ${winnerId}`);
});

Rollback Procedures

Backend Rollback

Railway keeps deployment history. To rollback:
  1. Go to Railway dashboard
  2. Select your project
  3. Click Deployments
  4. Find the last known good deployment
  5. Click Redeploy

Contract Rollback

Smart contracts are immutable. You cannot rollback a deployed contract.
Instead:
  1. Deploy a new fixed version
  2. Update frontend to use new contract address
  3. Announce migration to users
  4. Consider implementing upgradeable proxies for future deployments

Next Steps

Local Setup

Set up your development environment

Testing

Run the comprehensive test suite

Architecture

Understand the system design

API Reference

Explore the API endpoints

Build docs developers (and LLMs) love