Skip to main content

Documentation Index

Fetch the complete documentation index at: https://o1.network/docs/llms.txt

Use this file to discover all available pages before exploring further.

Deploying Your First Application

This guide walks you through deploying your first application using O1’s powerful deployment capabilities. We’ll deploy Anvil, a popular Ethereum development node, as our example.

Prerequisites

  • O1 backend service running (see Getting Started)
  • At least one node configured and accessible
  • SSH keys configured for the target node

Step 1: Verify Your Environment

First, ensure your O1 environment is ready:
# Check if O1 is running
curl http://localhost:3000/health

# List available nodes
curl http://localhost:3000/api/nodes

# Verify node connectivity
curl -X POST http://localhost:3000/api/nodes/verify \
  -H "Content-Type: application/json" \
  -d '{"name": "your-node-name"}'

Step 2: Create the Application Specification

Before deploying, we need to create an application specification. Let’s create a spec for Anvil:
curl -X POST http://localhost:3000/api/applications/create \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Anvil",
    "basic_info": {
      "description": "A fast local Ethereum development node from Foundry"
    },
    "installation": {
      "setup_type": "dual",
      "binary": {
        "url": "https://github.com/foundry-rs/foundry/releases/download/v1.0.0/anvil-linux-amd64",
        "executable": "anvil"
      },
      "docker": {
        "image": "ghcr.io/foundry-rs/foundry:latest"
      }
    },
    "configuration": {
      "config_files": [
        {
          "filename": "config.yaml",
          "content": "server:\n  port: {anvil_port}\n  host: {anvil_host}",
          "destinationPath": "/etc/anvil/config.yaml"
        }
      ],
      "environment_variables": [
        {
          "key": "ANVIL_IP_ADDR",
          "value": "{anvil_host}"
        }
      ]
    }
  }'

Step 3: Check Available Deployment Modes

Anvil supports both Docker and binary deployments. Let’s check what’s available:
curl http://localhost:3000/api/applications/Anvil/deployment-modes
You should see a response like:
{
  "isDualMode": true,
  "availableModes": ["docker", "binary"],
  "defaultMode": "binary",
  "versions": {
    "docker": ["latest", "1.0.0", "1.1.0"],
    "binary": ["1.0.0", "1.1.0", "1.2.0"]
  }
}

Step 4: Create a Deployment

Now let’s deploy Anvil using binary mode:
curl -X POST http://localhost:3000/api/applications/deploy \
  -H "Content-Type: application/json" \
  -d '{
    "applicationName": "Anvil",
    "nodeName": "your-node-name",
    "version": "1.0.0",
    "deploymentMode": "binary",
    "variables": {
      "anvil_port": 8545,
      "anvil_host": "0.0.0.0",
      "accounts": 10
    },
    "deploymentId": "anvil-deploy-$(date +%Y%m%d-%H%M%S)"
  }'
Response:
{
  "success": true,
  "deploymentId": "anvil-deploy-20240115-103000",
  "message": "Deployment started"
}

Step 5: Monitor the Deployment

Use the deployment ID to monitor progress:

Option 1: WebSocket Real-time Monitoring

O1 provides real-time deployment monitoring via WebSocket. Open a WebSocket connection:
// JavaScript example
const ws = new WebSocket('ws://localhost:3000/api/websocket');
ws.onopen = () => {
  ws.send(
    JSON.stringify({
      type: 'subscribe',
      deploymentId: 'anvil-deploy-20240115-103000',
    })
  );
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log(`${data.type}: ${data.message}`);
};

Option 2: Check Deployment Status

You can also check the deployment status via API:
# Get deployment details
curl http://localhost:3000/api/applications/Anvil/deployments

Step 6: Verify the Deployment

Once deployment completes, verify everything is working:
# Check if Anvil is running
curl -X POST http://localhost:3000/api/nodes/execute \
  -H "Content-Type: application/json" \
  -d '{
    "node": "your-node-name",
    "application": "Anvil",
    "command": "ps aux | grep anvil",
    "setup_mode": "binary"
  }'

# Test the Anvil RPC endpoint
curl -X POST http://localhost:3000/api/nodes/execute \
  -H "Content-Type: application/json" \
  -d '{
    "node": "your-node-name",
    "application": "Anvil",
    "command": "curl -X POST -H \"Content-Type: application/json\" --data \'{\\\"jsonrpc\\\":\\\"2.0\\\",\\\"method\\\":\\\"web3_clientVersion\\\",\\\"params\\\":[],\\\"id\\\":1}\' http://localhost:8545",
    "setup_mode": "binary"
  }'

Step 7: Set Up Monitoring

Set up monitoring to keep track of your application:
# Create a healthcheck
curl -X POST http://localhost:3000/api/monitoring/healthchecks \
  -H "Content-Type: application/json" \
  -d '{
    "host": "your-node-name",
    "application": "Anvil",
    "type": "http",
    "endpoint": "http://localhost:8545",
    "interval": 30,
    "timeout": 5
  }'

# Start background metrics collection
curl -X POST http://localhost:3000/api/monitoring/register-app \
  -H "Content-Type: application/json" \
  -d '{
    "node": "your-node-name",
    "application": "Anvil",
    "setup": "binary"
  }'

Step 8: View Application Logs and Metrics

Monitor your application’s performance:
# Get recent logs
curl -X POST http://localhost:3000/api/monitoring/logs \
  -H "Content-Type: application/json" \
  -d '{
    "host": "your-node-name",
    "application": "Anvil",
    "timespan": "1h"
  }'

# Get metrics snapshot
curl -X POST http://localhost:3000/api/monitoring/metrics/snapshot \
  -H "Content-Type: application/json" \
  -d '{
    "host": "your-node-name",
    "application": "Anvil",
    "timespan": "1h"
  }'

Common Deployment Scenarios

Deploying with Docker

If you prefer Docker deployment:
curl -X POST http://localhost:3000/api/applications/deploy \
  -H "Content-Type: application/json" \
  -d '{
    "applicationName": "Anvil",
    "nodeName": "your-node-name",
    "version": "latest",
    "deploymentMode": "docker",
    "variables": {
      "anvil_port": 8545,
      "anvil_host": "0.0.0.0"
    }
  }'

Deploying with Custom Configuration

For more complex configurations:
curl -X POST http://localhost:3000/api/applications/deploy \
  -H "Content-Type: application/json" \
  -d '{
    "applicationName": "Anvil",
    "nodeName": "your-node-name",
    "version": "1.0.0",
    "deploymentMode": "binary",
    "variables": {
      "anvil_port": 8547,
      "anvil_host": "0.0.0.0",
      "accounts": 20,
      "block_time": 5,
      "gas_limit": 30000000
    }
  }'

Troubleshooting

Deployment Fails

If deployment fails, check the following:
# Check deployment logs
curl http://localhost:3000/api/applications/Anvil/deployments

# Verify node connectivity
curl -X POST http://localhost:3000/api/nodes/verify \
  -H "Content-Type: application/json" \
  -d '{"name": "your-node-name"}'

# Check SSH key configuration
curl http://localhost:3000/api/nodes/ssh-keys

Application Not Starting

If the application doesn’t start properly:
# Check application logs
curl -X POST http://localhost:3000/api/monitoring/logs \
  -H "Content-Type: application/json" \
  -d '{
    "host": "your-node-name",
    "application": "Anvil",
    "timespan": "10m",
    "search": "error"
  }'

# Restart the application
curl -X POST http://localhost:3000/api/nodes/state/restart \
  -H "Content-Type: application/json" \
  -d '{
    "node": "your-node-name",
    "application": "Anvil",
    "setup_mode": "binary"
  }'

Next Steps

Congratulations! You’ve successfully deployed your first application with O1. Here’s what to explore next: Remember to regularly monitor your deployed applications and set up appropriate alerts to ensure they remain healthy and performant.