Install Forge on CentOS

A brand new centos machine lacks several dependencies that Forge requires. If you met issues on running Forge under CentOS, please read on. This guide is tested on CentOS 7 on a $5/month Digital Ocean machine.

WARNING

We do not suggest you to run Forge on CentOS 6 or lower. This guide may even not work for that version.

Setting up users

First of all, let's create a sudo user. Some cloud provider (e.g. digital ocean) ships CentOS with root user, thus we need to disable it. You can skip this step if you're already a sudo user.

Create user arcblock (feel free to change it) and add it to wheel group (sudoer):

adduser arcblock
usermod -aG wheel arcblock
1
2

Then run visudo to allow wheel group to run sudo commands without password:

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

## Same thing without a password
%wheel  ALL=(ALL)       NOPASSWD: ALL
1
2
3
4
5

From now on we can switch the user to this sudo user.

TIP

If you previously ssh to the host with root account, and you want to ssh with newly created arcblock account, you can run this command:

cat ~/.ssh/id_rsa.pub | ssh root@host "mkdir -p ~arcblock/.ssh && touch ~arcblock/.ssh/authorized_keys && chown -R arcblock ~arcblock/.ssh && chmod -R go= ~arcblock/.ssh && cat >> ~/.ssh/authorized_keys"
1

Install common dependencies

sudo yum -y update
sudo yum install -y autoconf automake epel-release git gcc libtool m4 make ncurses-devel openssl-devel perl-core rpm-build tar vim wget zlib-devel
1
2

Install nodejs 10/11

Forge CLI requires nodejs runtime, so we shall install latest 10.x or 11.x node. For ubuntu, please follow this guide: NodeSource Node.js Binary Distributions.

Basically, you need:

curl -sL https://rpm.nodesource.com/setup_11.x | sudo bash -
sudo yum install -y nodejs
1
2

If you want to install nodejs 10, just replace setup_11.x to setup_10.x.

Once finished, please check nodejs version is desired version:

$ node -v
v11.12.0
1
2

Although nodejs ships with npm, we highly recommend you install yarn:

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install -y yarn
1
2

Install Forge CLI

Let's use yarn to install forge cli. Note we install it globally so that different users could use it.

sudo yarn global add @arcblock/forge-cli
1

Add a non-privileged user and install Forge

We don't recommend running forge on a sudo user. So let's create a new user, and add proper path for it:

sudo adduser forge
echo 'export PATH=/usr/local/bin:/usr/local/ssl/bin:/usr/local/sbin:$PATH' | sudo tee --append ~forge/.bashrc
1
2

The sudo user arcblock shall only be used for ssh to install software, and the normal user forge shall only be used to run forge.

Let's sudo to this user: sudo su forge, and then init forge:

cd ~
forge init
1
2

As we discussed in intro, this will create .forge_cli folder and put forge assets into it. By default, it will put forge data under .forge_release, if you don't like this, you can change it

Then you shall be able to run forge start. You may want to check forge status by forge status:

$ forge start
✔ Forge daemon successfully started
┌───────────────┬──────────┬───────────────┬───────────────┬────────────────────┐
│ Name          │ PID      │ Uptime        │ Memory        │ CPU                │
├───────────────┼──────────┼───────────────┼───────────────┼────────────────────┤
│ starter       │ 4104     │ 16.1s         │ 61.6 MB       │ 0.00 %             │
│ forge         │ 4357     │ 12.7s         │ 433 MB        │ 0.00 %             │
│ ipfs          │ 4670     │ 6.7s          │ 27.1 MB       │ 0.00 %             │
│ tendermint    │ 4677     │ 6.6s          │ 22.6 MB       │ 0.00 %             │
└───────────────┴──────────┴───────────────┴───────────────┴────────────────────┘

ℹ If you want to access interactive console, please run /home/forge/.forge_cli/release/forge/0.18.6/bin/forge remote_console
forge@forge-cli:~$ forge status
──────────────
✔ Chain Info
──────────────
{
  id: '99cd4f098ed96c5d3ae1391a2858ab4fbf3db799',
  network: 'forge',
  moniker: 'forge',
  consensusVersion: '0.30.2',
  synced: true,
  appHash: 'bc40d2b84429b70564bf1aa51aefa956b636674b78d6511851d5a2721e151cb3',
  blockHash: 'd9ddd9d5873a155be66aa553574a7b53a7f9154713875ebf7e4dfca4cd526798',
  blockHeight: 2,
  blockTime: '2019-03-16T17:52:32.000Z',
  address: 'zystc5rNpeE462e3DokUC4nR7PUsrL5zM38J',
  votingPower: 10,
  totalTxs: 0,
  version: '0.18.6',
  dataVersion: '1.4',
  forgeAppsVersion: {},
  supportedTxs: [
    'fg:t:update_asset',
    'fg:t:transfer',
    'fg:t:sys_upgrade',
    'fg:t:stake',
    'fg:t:exchange',
    'fg:t:declare_file',
    'fg:t:declare',
    'fg:t:consensus_upgrade',
    'fg:t:create_asset',
    'fg:t:consume_asset',
    'fg:t:poke',
    'fg:t:account_migrate'
  ]
}

──────────────
✔ Forge State
──────────────
{
  address: 'forge_state',
  consensus: {
    maxBytes: 150000,
    maxGas: -1,
    maxValidators: 64,
    maxCandidates: 256,
    pubKeyTypes: [
      'ed25519'
    ],
    validators: [
      {
        address: 'zystc5rNpeE462e3DokUC4nR7PUsrL5zM38J',
        power: 10
      }
    ],
    validatorChanged: false,
    paramChanged: false
  },
  tasks: {},
  stakeSummary: {},
  version: '0.18.6',
  dataVersion: '1.4',
  forgeAppHash: '',
  token: {
    name: 'ArcBlock',
    symbol: 'ABT',
    unit: 'arc',
    description: 'Forge token ABT',
    decimal: 16,
    initialSupply: 93000000,
    totalSupply: 186000000,
    inflationRate: 0
  }
}

──────────────
✔ Net Info
──────────────
{
  listening: true,
  listeners: [
    'Listener(@)'
  ],
  nPeers: 0,
  peers: []
}

──────────────
✔ Validators Info
──────────────
{
  blockHeight: 3,
  validators: [
    {
      address: '766D728A8CD7204FF7631912B963B8AE860D6DF6',
      votingPower: 10,
      proposerPriority: '0',
      name: ''
    }
  ]
}

──────────────
✔ Forge Web
──────────────
ℹ forge web started at:     http://localhost:8210
ℹ graphql endpoint at:      http://localhost:8210/api
ℹ graphql playground at:    http://localhost:8210/api/playground
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

Have fun!

Last Updated: 3/22/2019, 12:45:51 PM