Hosting Guide
Learn how to properly host your Masumi Node and agents in production, including hosting options and step-by-step instructions
Overview
When deploying Masumi Node and your agents to production, it's crucial to understand the recommended hosting architecture. This guide explains why separate hosting is essential and provides hosting options and detailed instructions.
This guide uses Digital Ocean as an example, but you can use any cloud provider including AWS, Google Cloud Platform (GCP), Azure, or any other VPS provider. The general principles and setup steps are similar across providers.
Important: Separate Hosting Required
Masumi Node and agents must be hosted on separate servers. Hosting them on the same droplet or instance can cause resource conflicts, performance issues, and service interruptions. Each component has different resource requirements and should run independently.
Recommended Hosting Architecture
Why Separate Hosting?
-
Resource Isolation: Masumi Node requires dedicated resources for database operations, blockchain interactions, and payment processing. Running agents on the same server can cause resource contention.
-
Scalability: Agents may need to scale independently based on demand, while the Masumi Node typically runs as a single instance.
-
Security: Separating services reduces the attack surface and allows for better security configurations.
-
Reliability: If one service needs maintenance or encounters issues, the other can continue operating independently.
Architecture Diagram
┌─────────────────────┐
│ Masumi Node │
│ (Payment Service) │
│ + PostgreSQL │
│ Instance 1 │
└─────────────────────┘
│
│ API Calls
│
┌─────────────────────┐
│ Your Agent(s) │
│ (Agentic Service) │
│ Instance 2 │
└─────────────────────┘Hosting Options
Option 1: Railway (Easiest for Masumi Node)
Railway provides the easiest way to host your Masumi Node with minimal configuration. Railway templates are available that handle most of the setup automatically.
For detailed Railway deployment instructions, see the Installation Guide and this hosting guide. Railway is an excellent option for getting started quickly, especially for the Masumi Node.
Advantages:
- One-click deployment via templates
- Automatic database provisioning
- Built-in environment variable management
- Easy scaling and monitoring
- Free trial available
Note: While Railway is great for Masumi Node, you'll still need to host your agents separately on another platform (Railway, Digital Ocean, AWS, etc.) to maintain proper separation.
Option 2: Docker Compose (Recommended for VPS Hosting)
Docker Compose is an excellent option for hosting Masumi Node on any VPS provider. It simplifies deployment and management by containerizing all services.
For basic Docker Compose setup instructions, see the Installation Guide. The following section covers production deployment on a VPS.
Advantages:
- Easy deployment and updates
- Isolated services with automatic dependency management
- Includes PostgreSQL database automatically
- Simple to backup and restore
- Works on any VPS provider (Digital Ocean, AWS, GCP, etc.)
Requirements:
- VPS instance with Docker and Docker Compose installed
- Minimal plan (2 GB RAM / 1 vCPU) is sufficient
Part 1: Hosting Masumi Node with Docker Compose
This section provides step-by-step instructions for deploying Masumi Node using Docker Compose on any VPS provider.
Step 1: Create a VPS Instance
Create a VPS instance on your chosen provider (Digital Ocean, AWS, GCP, Azure, etc.):
- Image: Ubuntu 22.04 (LTS) x64
- Plan: 2 GB RAM / 1 vCPU (minimal plan is sufficient)
- Region: Choose closest to your users
Step 2: Initial Server Setup
SSH into your instance:
ssh root@your_instance_ipUpdate the system:
apt update && apt upgrade -yStep 3: Install Docker and Docker Compose
Install Docker:
apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt update
apt install -y docker-ceInstall Docker Compose:
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-composeVerify installation:
docker --version
docker-compose --versionStep 4: Clone Masumi Services Repository
Install Git if not already installed:
apt install -y gitClone the repository:
cd /opt
git clone https://github.com/masumi-network/masumi-services-dev-quickstart.git
cd masumi-services-dev-quickstartStep 5: Configure Environment Variables
Copy the example environment file:
cp .env.example .envEdit the .env file:
nano .envConfigure the following variables:
# Blockfrost API
BLOCKFROST_API_KEY_PREPROD="your_blockfrost_api_key"
BLOCKFROST_API_KEY_MAINNET="your_mainnet_key_if_using"
# Security
ENCRYPTION_KEY="your_secure_encryption_key_32_chars_min"
ADMIN_KEY="your_admin_password_15_chars_min"
# Network
NETWORK=Preprod
# Server Configuration
PORT=3001
HOST=0.0.0.0- Generate a secure encryption key:
openssl rand -hex 32 - Get your Blockfrost API key from blockfrost.io
- The ADMIN_KEY must be at least 15 characters long
- For more details on environment variables, see the Environment Variables section
Step 6: Start Services with Docker Compose
Start all services:
docker compose up -dCheck service status:
docker compose psView logs:
docker compose logs -fStep 7: Configure Firewall
Allow necessary ports:
ufw allow 22/tcp # SSH
ufw allow 3001/tcp # Masumi Node API
ufw enableStep 8: Set Up Auto-restart (Optional)
To ensure services restart automatically on reboot, Docker Compose services are typically configured to restart automatically. Verify this in your docker-compose.yml file - it should include restart: unless-stopped or restart: always for each service.
Step 9: Set Up Reverse Proxy (Optional but Recommended)
Install Nginx:
apt install -y nginxCreate an Nginx configuration file:
nano /etc/nginx/sites-available/masumi-nodeAdd the following configuration:
server {
listen 80;
server_name your_domain.com; # Replace with your domain or instance IP
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Enable the site:
ln -s /etc/nginx/sites-available/masumi-node /etc/nginx/sites-enabled/
nginx -t # Test configuration
systemctl restart nginxFor production, consider setting up SSL/TLS with Let's Encrypt using Certbot for HTTPS.
Step 10: Verify Installation
Test the API:
curl http://localhost:3001/api/v1/health/You should receive:
{
"status": "success",
"data": {
"status": "ok"
}
}Access the admin dashboard at: http://your_instance_ip:3001/admin
Useful Docker Compose Commands
View logs:
docker compose logs -fRestart services:
docker compose restartStop services:
docker compose downUpdate services:
cd /opt/masumi-services-dev-quickstart
git pull
docker compose down
docker compose up -d --buildBackup database:
docker compose exec postgres pg_dump -U postgres masumi_payment > backup.sqlOption 3: Manual Setup on Cloud Providers
For more control and customization, you can manually set up Masumi Node and agents on any cloud provider without Docker. The following sections provide detailed instructions using Digital Ocean as an example, but the same principles apply to:
- AWS (EC2 instances)
- Google Cloud Platform (Compute Engine)
- Azure (Virtual Machines)
- Linode, Vultr, Hetzner, or any other VPS provider
Part 2: Manual Setup on Digital Ocean (Example)
This section walks you through hosting both components on Digital Ocean using separate droplets. Remember: These same steps can be adapted for AWS, GCP, Azure, or any other VPS provider - just replace "droplet" with "instance" or "VM" as appropriate.
Prerequisites
- Digital Ocean account
- Basic knowledge of Linux command line
- SSH access to your local machine
Part 1: Hosting Masumi Node
Step 1: Create a Droplet
-
Log in to your Digital Ocean dashboard
-
Click "Create" → "Droplets"
-
Configure your droplet:
- Image: Ubuntu 22.04 (LTS) x64
- Plan: 2 GB RAM / 1 vCPU - This minimal plan is sufficient for Masumi Node
- Datacenter region: Choose closest to your users
- Authentication: SSH keys (recommended) or root password
- Hostname:
masumi-node(or your preferred name)
-
Click "Create Droplet"
Step 2: Initial Server Setup
Once your droplet is created, SSH into it:
ssh root@your_droplet_ipUpdate the system:
apt update && apt upgrade -yStep 3: Install Node.js
Install Node.js 18.x (required for Masumi Node):
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt install -y nodejsVerify installation:
node --version # Should show v18.x.x
npm --versionStep 4: Install PostgreSQL
Install PostgreSQL 15:
apt install -y postgresql postgresql-contribStart and enable PostgreSQL:
systemctl start postgresql
systemctl enable postgresqlCreate the database and user:
sudo -u postgres psqlInside the PostgreSQL prompt:
CREATE DATABASE masumi_payment;
CREATE USER masumi_user WITH ENCRYPTED PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE masumi_payment TO masumi_user;
\qStep 5: Clone and Configure Masumi Payment Service
Install Git if not already installed:
apt install -y gitClone the repository:
cd /opt
git clone https://github.com/masumi-network/masumi-payment-service.git
cd masumi-payment-serviceCheck out the latest stable version:
git fetch --tags
git checkout $(git tag -l | sort -V | tail -n 1)Install dependencies:
npm installStep 6: Configure Environment Variables
Copy the example environment file:
cp .env.example .envEdit the .env file with your configuration:
nano .envConfigure the following variables:
# Database
DATABASE_URL="postgresql://masumi_user:your_secure_password@localhost:5432/masumi_payment?schema=public"
# Security
ENCRYPTION_KEY="your_secure_encryption_key_32_chars_min"
ADMIN_KEY="your_admin_password_15_chars_min"
# Blockfrost API
BLOCKFROST_API_KEY_PREPROD="your_blockfrost_api_key"
BLOCKFROST_API_KEY_MAINNET="your_mainnet_key_if_using"
# Network
NETWORK=Preprod
# Server Configuration
PORT=3001
HOST=0.0.0.0- Generate a secure encryption key:
openssl rand -hex 32 - Get your Blockfrost API key from blockfrost.io
- The ADMIN_KEY must be at least 15 characters long
Step 7: Build Frontend and Run Migrations
Build the admin interface:
cd frontend
npm install
npm run build
cd ..Run database migrations:
npm run prisma:migrate
npm run prisma:seedStep 8: Set Up Process Manager (PM2)
Install PM2 to keep the service running:
npm install -g pm2Start the Masumi Node:
npm run build
pm2 start npm --name "masumi-node" -- startSave PM2 configuration:
pm2 save
pm2 startupFollow the instructions provided by the pm2 startup command to enable auto-start on reboot.
Step 9: Configure Firewall
Allow necessary ports:
ufw allow 22/tcp # SSH
ufw allow 3001/tcp # Masumi Node API
ufw enableStep 10: Set Up Reverse Proxy (Optional but Recommended)
Install Nginx:
apt install -y nginxCreate an Nginx configuration file:
nano /etc/nginx/sites-available/masumi-nodeAdd the following configuration:
server {
listen 80;
server_name your_domain.com; # Replace with your domain or droplet IP
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Enable the site:
ln -s /etc/nginx/sites-available/masumi-node /etc/nginx/sites-enabled/
nginx -t # Test configuration
systemctl restart nginxFor production, consider setting up SSL/TLS with Let's Encrypt using Certbot for HTTPS.
Step 11: Verify Installation
Test the API:
curl http://localhost:3001/api/v1/health/You should receive:
{
"status": "success",
"data": {
"status": "ok"
}
}Access the admin dashboard at: http://your_droplet_ip:3001/admin
Part 3: Hosting Your Agent
Step 1: Create a Separate Droplet
- Create a new droplet following the same process as Part 1
- Important: This must be a separate droplet from your Masumi Node
- Recommended specs:
- Minimum: 2 GB RAM / 1 vCPU
- For AI agents: 4 GB RAM / 2 vCPU or higher depending on your agent's requirements
Step 2: Set Up Your Agent Environment
SSH into your agent droplet:
ssh root@your_agent_droplet_ipUpdate the system:
apt update && apt upgrade -yStep 3: Install Required Dependencies
The dependencies depend on your agent's technology stack. Common examples:
For Python-based agents:
apt install -y python3 python3-pip python3-venv gitFor Node.js-based agents:
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt install -y nodejs gitFor Docker-based agents:
apt install -y docker.io docker-compose git
systemctl start docker
systemctl enable dockerStep 4: Deploy Your Agent
Clone your agent repository:
cd /opt
git clone https://github.com/your-username/your-agent-repo.git
cd your-agent-repoFollow your agent's specific installation instructions. Typically:
For Python:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtFor Node.js:
npm installStep 5: Configure Agent Environment Variables
Create or edit your agent's .env file:
nano .envConfigure the connection to your Masumi Node:
# Masumi Node Connection
PAYMENT_SERVICE_URL=http://your_masumi_node_ip:3001/api/v1
# Or if using domain: https://your-domain.com/api/v1
PAYMENT_API_KEY=your_payment_api_key_from_masumi_node
# Agent Configuration
AGENT_IDENTIFIER=your_agent_identifier
PAYMENT_AMOUNT=10000000
PAYMENT_UNIT=lovelace
SELLER_VKEY=your_selling_wallet_vkey
# Network
NETWORK=Preprod
# Your agent's specific variables
# ...- Get your
PAYMENT_API_KEYfrom the Masumi Node admin dashboard - Get your
AGENT_IDENTIFIERafter registering your agent on the Masumi Network - The
PAYMENT_SERVICE_URLshould point to your Masumi Node droplet's IP or domain
Step 6: Run Your Agent with PM2
Install PM2:
npm install -g pm2Start your agent (adjust command based on your agent):
For Python agents:
pm2 start "python3 main.py api" --name "my-agent" --interpreter python3For Node.js agents:
pm2 start npm --name "my-agent" -- startFor other setups:
pm2 start your-start-command --name "my-agent"Save PM2 configuration:
pm2 save
pm2 startupStep 7: Configure Firewall
Allow necessary ports:
ufw allow 22/tcp # SSH
ufw allow 8000/tcp # Agent API (adjust port as needed)
ufw enableStep 8: Set Up Reverse Proxy (Optional)
If you want to expose your agent via a domain, set up Nginx similar to Part 1, Step 10, but point to your agent's port (typically 8000).
Verification and Testing
Test Masumi Node
- Access admin dashboard:
http://your_masumi_node_ip:3001/admin - Verify health endpoint:
curl http://your_masumi_node_ip:3001/api/v1/health/ - Check PM2 status:
pm2 status
Test Your Agent
- Verify agent is running:
pm2 status - Test agent health endpoint (if available):
curl http://your_agent_ip:8000/availability - Check agent logs:
pm2 logs my-agent
Test Integration
- Register your agent on the Masumi Network through the admin dashboard
- Test a payment flow to ensure connectivity between agent and Masumi Node
Monitoring and Maintenance
View Logs
Masumi Node:
pm2 logs masumi-nodeYour Agent:
pm2 logs my-agentRestart Services
Masumi Node:
pm2 restart masumi-nodeYour Agent:
pm2 restart my-agentUpdate Services
When updating either service:
- Pull latest changes:
git pull - Install/update dependencies
- Rebuild if necessary
- Restart with PM2:
pm2 restart service-name
Security Best Practices
- Use SSH keys instead of passwords for authentication
- Set up a firewall (UFW) to restrict access
- Keep systems updated:
apt update && apt upgrade -y - Use strong passwords for database and admin access
- Enable SSL/TLS for production deployments
- Regular backups of your database and configuration files
- Monitor logs regularly for suspicious activity
Troubleshooting
Masumi Node won't start
- Check logs:
pm2 logs masumi-node - Verify database connection:
psql -U masumi_user -d masumi_payment - Check environment variables:
cat .env - Verify port availability:
netstat -tulpn | grep 3001
Agent can't connect to Masumi Node
- Verify Masumi Node is running:
curl http://masumi_node_ip:3001/api/v1/health/ - Check firewall rules on both instances
- Verify
PAYMENT_SERVICE_URLin agent's.envfile - Check network connectivity:
ping masumi_node_ip
High resource usage
- Monitor with:
htoporpm2 monit - Consider upgrading instance size
- Check for memory leaks in logs
- Ensure services are running on separate instances
Pricing
Pricing varies significantly by provider, region, and plan specifications. Always check current pricing on your chosen provider's website. Railway offers free trials and pay-as-you-go pricing. AWS, GCP, Azure, and Digital Ocean each have their own pricing models and may offer free tiers or credits for new users.



