How to Launch an ACES Marketplace in Five Steps.

ARK ACES
8 min readMay 29, 2018

--

This blog post is part of a tutorial series. Stay tuned this week for updates on what’s coming next in the ACES project. If you are interested in learning how to launch your own ACES marketplace instances, take a look at this guide.

An ACES marketplace is a place for you to list all your various blockchain services and provide a positive user experience for consumers.

You will be able to register your services, and accept other service listings as well. In this post we will teach you where to go to get all the resources you need to launch your own marketplace.

In this guide we will launch an ACES Marketplace in five steps: Get a webserver, prepare your webserver, install the ACES Marketplace backend, install the ACES Marketplace frontend, and finally launch the application.

An ACES Marketplace can be a key component of launching an ARK ICO. In additional to the marketplace, you may want to deploy your own blockchain using ARK’s Deployer or future Push-Button-Blockchains. In addition, you will need to have at least one service to post to the marketplace. We recommend using an ARK to ARK transfer service, so that you can allow users to convert ARK coins into your own blockchain coins automatically. As always, you can find the tools you need to get going on the ark-aces Github repository.

Step 1: Get a web server.

We will use AWS Lightsail for this tutorial. This is an easy way to quickly get started. Once you have an account, you can go to the lightsail console which will appear as follows:

Click the orange “Create Instance” button to start up a new Linux OS Only Ubuntu instance.

We recommend using at least the $20/m option which has 2GB of RAM.

Once your server is named and created, you’ll see it Pending. It should take less than a minute for it to move from Pending to Running, but you will need to refresh the page to see that.

You can now connect using SSH, though you may have a better experience if you connect through a Ubuntu terminal rather than through the AWS website. In order to do this, you will need to set up SSH keys. You can follow the guides provided on the AWS page to create an SSH key if desired.

Step 2: Prepare your server.

Preparing your server simply means installing all the necessary tools to secure your server. We provide all these details in the Marketplace Setup guide on the Github respository. We will use this guide to allow SSH access, setup our firewall, install system dependencies and create a database.

Allow SSH Access

This step is not unique to ACES, and you can follow any guide for this. We recommend using the guide provided from DigitalOcean for server setups with Ubuntu 16.04.

Firewall Setup

You can learn more about firewall configurations with the DigitalOcean guide on common firewall rules and commands.

sudo apt-get install ufw
sudo ufw allow ssh
sudo ufw allow http
sudo ufw enable

Install System Dependencies

There are several packages we need to install before using ACES software. We will install the dependencies now.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update -y
sudo apt-get install oracle-java8-installer -y

sudo apt-get install maven -y
sudo apt-get install pwgen
sudo apt-get install nginx -y
sudo apt-get install python-software-properties -y
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install nodejs -y

Install Postgres Database

The ACES Marketplace backend application requires a postgresql database to use for marketplace data.

Some cloud providers may have simplified tools for deploying and managing the database instance (automated backups and replication), such as Amazon RDS. The ACES Marketplace backend app can be configured to connect to any accessible postgresql instance including ones created by such tools.

Manging a postgresql database is outside the scope of this guide, but instructions for installing a locally running postgresql instance are given below.

First, we should generate a password for the database. We can use the following command to create a good password for us.

pwgen 20 1

This will print out a 20 character string, which we can then use during the creation process

Create Database

Run the following commands, but make sure to replace the ‘change-me’ string with the string you generated with pwgen. This will install postgres, create a database user named aces_marketplace_user, and create a database named aces_marketplace. Then we will enter into the psql console so we can give our user a password and privileges to use the aces_marketplace database.

sudo apt-get install postgresql -y
sudo -u postgres createuser aces_marketplace_user
sudo -u postgres createdb aces_marketplace
sudo -u postgres psql
psql=# alter user aces_marketplace_user with encrypted password 'change-me';
psql=# grant all privileges on database aces_marketplace to aces_marketplace_user;

Press CTRL+D to leave the psql console.

Start the Database

Now simply restart the database.

sudo service postgresql restart

Step 3: Install the ACES Marketplace Backend

Now that our server is prepared, we can continue to install what we need to launch the marketplace. First we must get all the ACES Marketplace code from the Github repository. We should install this part into an apps directory.

sudo mkdir /apps
cd /apps
git clone https://github.com/ark-aces/aces-marketplace

If you have permission issues, you should make sure to give permission to the folder before using git clone.

sudo chmod 777 /apps

Generate OAuth2 Secret

As before, we can generate a password for the backend using pwgen to use in the following section.

pwgen 20 1

Get Recaptcha v2 API Key

The ACES Marketplace application uses captcha verification to prevent spamming of account registrations and secures some forms from brute force attacks.

Follow the instructions at https://developers.google.com/recaptcha/intro to set up a ReCaptcha v2 account and generate an API secret to use in the application.yml config file below.

Once submitting you’ll be taken to a page where you’ll be able to find your Secret key. Save this for later as we will be populating our application config file with this data shortly. Also, write down the Site key as well, as we will be needing this later for the frontend.

Get SMTP Credentials

The backend application needs to send emails for password reset and other notifications.

There are many email providers that can be used including Gmail, SendGrid, MailGun, or hosting your own postfix server.

We recommend using MailGun since it is easy to set up and is free up to 10k emails per month.

Use your SMTP credentials supplied by email delivery provider in the application.yml configuration below.

Create Backend Application config

Create a marketplace application config at /etc/aces-marketplace-backend/application.yml

sudo mkdir /etc/aces-marketplace-backend
sudo touch /etc/aces-marketplace-backend/application.yml
sudo vim /etc/aces-marketplace-backend/application.yml

Now paste in the following text (making sure to first type A to edit in vim). You should still have all your passwords saved to update all the “change-me” strings with your actual passwords. You should also replace the baseUrl with your actual Url, as well as your fromEmailAddress as applicable.

server:
port: 8081

oauth2:
clientId: "marketplace"
secret: "change-me"
tokenValiditySeconds: 86400

spring:
datasource:
platform: "postgres"
url: "jdbc:postgresql://localhost:5432/aces_marketplace"
username: "aces_marketplace_user"
password: "change-me"
jpa:
hibernate:
ddl-auto: "validate"

mail:
host: "smtp.mailgun.org"
port: 587
username: "change-me"
password: "change-me"
properties:
mail.smtp.auth: true
mail.startttls.enable: true

baseUrl: "https://marketplace.example.com"

recaptcha:
secret: "change-me"

email:
fromName: "ACES Marketplace"
fromEmailAddress: "support@example.com"

You can exit vim with Esc + :x+ Enter

Create Backend Application Start script

Create /etc/systemd/system/aces-marketplace-backend.service and add the following configuration:

sudo touch /etc/systemd/system/aces-marketplace-backend.service
sudo vim /etc/systemd/system/aces-marketplace-backend.service

Paste in the following and then save and exit:

[Unit]
Description=Aces Marketplace Backend

[Service]
Restart=always
WorkingDirectory=/apps/aces-marketplace/backend
ExecStart=/usr/bin/mvn spring-boot:run -Dspring.config.location=file:/etc/aces-marketplace-backend/application.yml

[Install]
WantedBy=multi-user.target

Now you should enable this service to start on system boot using the following commands.

sudo systemctl daemon-reload
sudo systemctl enable aces-marketplace-backend

Finally, start the backend application.

sudo service aces-marketplace-backend start

You can check the status of the application by running the following command:

tail -f /var/log/syslog

Step 4: Install the ACES Marketplace Frontend

Finally, we can install the ACES Marketplace Frontend.

Update Recaptcha Site Key

Edit /apps/aces-marketplace/frontend/src/environments/environment.prod.ts and change the recaptchaSiteKey value to the site key for your ReCaptcha account. The recaptchaSiteKey is different from the recaptcha secret used on the backend.

Build Frontend

Since we’ve already pulled the code in earlier steps, we only need to navigate to the frontend folder and use npm to build and package the angular frontend application. Installing npm will take several minutes.

cd /apps/aces-marketplace/frontend
npm install
npm run-script build --prod --build-optimizer

Install Frontend

Copy the generated static frontend application files into /var/www/aces-marketplace/ that will be served up by your nginx configuration in a later step.

sudo mkdir /var/www/aces-marketplace/
sudo cp -R /apps/aces-marketplace/frontend/dist/** /var/www/aces-marketplace/

Step 5: Finish Up

Install SSL Certificates

We recommend using LetsEncrypt for free SSL certificates.

Install Dependencies

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install certbot -y

Generate Certificates

Set DOMAIN_NAME below to a domain name registered to your server IP address. LetsEncrypt will start a local webserver to validate the registered domain name points to the server IP.

First temporarily disable nginx server to allow LetsEncrypt to validate your domain and issue the SSL certs.

sudo service nginx stopexport DOMAIN_NAME=marketplace.example.com
sudo certbot certonly -d $DOMAIN_NAME --force-renewal

In this example we show marketplace.example.com, but you should replace that with your actual marketplace instance domain.

Select option 1.

Setup Nginx

Edit /etc/nginx/sites-enabled/default.

sudo vim /etc/nginx/sites-enabled/default

Add the following basic setup. Replace marketplace.example.com with your actual marketplace domain name.

server {
listen 80;
root /var/www/aces-marketplace/;
server_name marketplace.example.com;

# Serve ACES Marketplace frontend app directly
location / {
try_files $uri $uri/ /index.html;
}

# Pass api requests to the ACES Marketplace backend app
location /api/ {
proxy_pass http://127.0.0.1:8081/;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/marketplace.example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/marketplace.example.com/privkey.pem; # managed by Certbot
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}

Then restart nginx.

sudo service nginx restart

Testing the Setup

With this setup, the frontend application is served at https://marketplace.example.com (replace domain name with the one used in your setup).

The backend API is served at https://marketplace.example.com/api/.

You can follow the instructions in ACES Marketplace Guide for posting services to your marketplace instance using the API.

--

--