# Publish Your Starport Blockchain App on DigitalOcean
In this tutorial, you will publish your blockchain application an Ubuntu 20.04 droplet on DigitalOcean.
You will follow step-by-step instructions to build and run your blockchain app with these high-level steps:
- Create a Cosmos SDK blockchain app with Starport
- Create a Droplet on DigitalOcean
- Upload your app to the Droplet
- Run the app on the Droplet
This article is written for DigitalOcean. While this information can be helpful with other cloud services, the details apply only to DigitalOcean Droplets. Because DigitalOcean Droplets are Linux-based virtual machines (VMs), the operating system steps in this tutorial apply to MacOS and Linux operating systems.
Steps might be significantly different for Windows operating systems.
For the best experience using this tutorial, we recommend using DigitalOcean.
Important Placeholder values are used in the code examples throughout this tutorial:
- When you see username be sure to substitute it with your username.
- Although you can use digitalocean as your directory and app name, you can replace it with your own app name.
To complete this guide, you will need:
- A DigitalOcean (opens new window) account. If you do not have an account, DigitalOcean may offer a free trial to let you build Basic Droplets.
- A supported version of Starport (opens new window). To install Starport, see Install Starport.
- Go (version 1.16 or higher). See Download and install Go (opens new window) documentation. Using brew to install Go is not recommended.
# Step 1 — Create Your Starport App
In this step, you create your Starport application on your local computer. Later, you will upload the app to your DigitalOcean Droplet.
Create a directory and run Starport to create a Cosmos SDK blockchain app.
On your local computer, run these commands in a terminal window:
A blockchain app with backend and frontend is created. The default scaffold is a working blockchain app with the functionality that is similar to the Cosmos Hub ($ATOM). Learn about the Cosmos Hub (opens new window) and ATOM (opens new window).
To change any parameters of the blockchain, learn how to configure (opens new window) your blockchain app with Starport.
# Step 2 — Host Your App on DigitalOcean
DigitalOcean provides developers cloud services that help to deploy and scale applications that run simultaneously on multiple computers.
Use the DigitalOcean infrastructure to publish a Cosmos SDK blockchain application to ensure the app is accessible on the web. Your app must be accessible on the web to allow other apps and new nodes to connect to your blockchain network.
# Create a Droplet on DigitalOcean
Log into your DigitalOcean account and access the control panel (opens new window).
From the Create menu in the top right of the control panel, click Droplets.
Choose the Ubuntu 20.04 (LTS) x64 image and a Shared CPU Basic plan:
Choose your memory and compute resources. Virtual machines offer a mix of memory and compute resources. For a typical blockchain app that is not computing intense, 2 GB Ram/1 CPU are sufficient for your development and test environment.
Accept the default datacenter region and VPC network selections.
We recommend SSH keys for your Authentication method to access your Droplet. Learn how to setup your SSH key (opens new window).
For How many Droplets? accept the default 1 Droplet selection.
For Choose a hostname you can optionally add an identifying name.
For Tags you can optionally add one or more tags.
For Select Project you can accept the default project.
Do not select Add backups.
Select Create Droplet.
You new Droplet is shown in the list of your Droplets.
# Access Your New Node
Congratulations, you are now ready to connect to your new node.
In the list of Droplets in the DigitalOcean Control Panel, you can mouse over the IP address to copy it into your clipboard.
Open a terminal window and type
ssh root@<IP address>to connect to your new node. See How to Connect to your Droplet with OpenSSH (opens new window).
# Create a User to Run the Blockchain
First, create a user that to run the blockchain. For this example, you can use
appuser as the username. Use the
When prompted, enter and confirm a password for
After the password is successfully updated, you are prompted to change the user information for appuser. Press ENTER to use the default values. Type
Y to confirm the information is correct.
To give appropriate permissions, add
appuser to the
To be able to login as
appuser, copy your ssh public key to the new home directory for
Now, switch to your new user account:
# Set Up Your Droplet
To set up your Droplet, you need to install a few tools to help us to publish your blockchain app.
Install Go (opens new window).
At the time of writing the tutorial, the latest version of Go is 1.16.5.
Extract the archive and keep it in
A directory named
gois now in the
Next, recursively change this directory’s owner and group to
Add the go paths to your profile:
At the end of the file, add the following two lines:
Update your profile:
Verify your go installation:
To use Starport, install the Starport CLI:
The latest stable version of Starport is installed.
# Upload Your App to the Droplet
Several methods are available to upload your app to the Droplet.
One convenient method is to upload the app to GitHub and then download it on your Droplet. Starport creates a GitHub repository that makes it convenient to add your app to your repositories.
To upload the files, you can use
scp to avoid a few extra steps.
In a terminal window on your local machine, make sure you are in the parent directory of the Starport repo that you created earlier. For example,
/Users/username/blockchainis the parent directory of your
digitaloceanapp directory. From the
/Users/username/blockchaindirectory, use the following command to upload the local app directory to your DigitalOcean server:
scp -r digitalocean appuser@<IP address>:/home/appuser/
This command uploads your local
digitaloceanapp to your home directory on your DigitalOcean Droplet,
# Install your app
In a terminal window on the Droplet, you can change to the
/home/appuser/digitaloceandirectory after the upload is completed:
To install your app and configuration on the Droplet, use the Starport CLI:
starport serve command builds your Starport app, creates a genesis file, and creates your configuration.
You see an output similar to:
Press Ctrl+C to stop the chain that you started with the
starport serve command.
To confirm the installation (and celebrate your success), start the app:
When all of these steps were successful, the output prints:
# Create a Systemd process
starport serve command helps installing, building, and configuring your app for a new blockchain. You received tokens on newly created accounts.
This new app is useful only for development purposes and is not intended to be run for an extended time or in production.
For the app to run for a longer time, you need a
systemd process on your Droplet.
Create the log files and a
systemd file to manage your process so that you can log off from the terminal and be confident the app keeps running even when the server restarts.
Use nano to edit the systemd service file:
Add your application details to the file:
To close and save the file, press Ctrl+x. Then type
Y and press Enter.
The next step is to enable the file so the app is available even after a system start:
Now start the systemd process:
Check the logs with:
Your app is now running on DigitalOcean.
# Connect your local running chain to the published chain
To connect your local running chain with the published app, you need to:
- Find the node you just created with the IP address
- Download the genesis file
- Configure your app to connect to the published node
On your DigitalOcean droplet, find the hash of the node by typing:
Each node has a different node id.
At a terminal window back on your local machine, initialize your blockchain with:
Next, download the
genesis.json file from your node:
Then add the published node ID and IP into the configuration file on your local machine:
Add a persistent connection. Use the node-id from the Droplet together with the IP address and default port:
Start the node:
You can use a tool like gex to see if you are connected to a node. You can install gex on your remote and local machine. Run this command at a terminal window on each machine:
Afterward gex is installed, start the gex tool with:
1 shows in the
Connected Peers box, then everything is setup successfully.
# Access API and RPC
Now, you can access the API. The Swagger documentation is available at:
While the RPC is available on:
# Optional: Set Up a Firewall on Your Droplet
To reduce load and attacks to your droplet, you can set up a firewall.
Although DigitalOcean provides a nice UI for creating a firewall, this tutorial uses a general approach with the
ufw command to block everything that is not related to your blockchain app.
Setup the following rules for
ufw to make it work with your blockchain app: