Skip to content

Latest commit

 

History

History
117 lines (95 loc) · 3.48 KB

File metadata and controls

117 lines (95 loc) · 3.48 KB

Installation guide for 🛠 binaries

Factom Open API consists of API binary, user management binary & config file.

Step 1: Prepare a database

Postgres database is required for Factom Open API. You can connect to any internal/external Postgres DB by filling the config file. Please prepare DB connection credentials for the next step.

Step 2: Prepare configuration file

Download config template

Create any folder (e.g. ~/.foa) for config and download config template into it

mkdir ~/.foa
curl -o ~/.foa/config.yaml https://raw.githubusercontent.com/DeFacto-Team/Factom-Open-API/master/config.yaml.EXAMPLE

Introduction to config

There are few sections into config file:

  • admin (Admin params)
  • api (API params)
  • store (DB params)
  • factom (Factom params)

You may use custom config params: uncomment the line and put your value to override the default value.

Admin params

Login & password for Admin UI. Leave empty to disable Admin UI.

API params

By default Open API uses HTTP port 8081.
Log levels: 3 — Warn, 4 — Info, 5 – Debug, 6 – Debug+DB

DB params

Specify connection to your internal/external Postgres DB.

Factom params

Entry Credits (EC) purchase fixed amounts of data in the Factom network.
You need EC address filled with Entry Credits to write data on the Factom.

  • EC address may be imported or generated via Open API Admin UI
  • Fund your EC address in the EC store

    By default Open API is connected to Factom Open Node, that means you don't need to setup your own node on the Factom blockchain to work with blockchain. But if you want to use your own node, you may specify it into the config.

Fill the config

nano ~/.foa/config.yaml

Step 3: Download Factom Open API binary and run them

Download with cURL:

curl -o foa https://github.com/DeFacto-Team/Factom-Open-API/releases/download/1.1.0/foa

Run Factom Open API with default config location:

./foa

By default the binary uses the config located at <USER_FOLDER>/.foa/config.yaml. If you use custom location for config file, please don't forget to provide it with -c flag while running binaries.

./foa -c=/somewhere/placed/config.yaml

(Optional) Step 4: Run Factom Open API binary as a daemon

This instruction is for Linux. Setup running the Factom Open API as a daemon is needed to automatically start Factom Open API when your server starts after reboot.

Move binary

Move foa binary to /usr/bin/.

Create new user

It’s better to run Factom Open API as non-root user, so you need new user:

adduser foa

Create service file to run Factom Open API as daemon

nano /etc/systemd/system/foa.service

Fill this file with the following daemon config:

[Unit]
Description=Run the Factom Open API service
Documentation=https://github.com/DeFacto-Team/Factom-Open-API
After=network-online.target
[Service]
User=foa
Group=foa
EnvironmentFile=-/etc/default/foa
ExecStart=/usr/bin/foa $FOA_OPTS
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=multi-user.target

Create environment file for Factom Open API service

nano /etc/default/foa

Fill this file with FOA_OPTS param:

FOA_OPTS = ''

Enable Factom Open API daemon

systemctl daemon-reload
systemctl start foa
systemctl enable foa