Aleo Node Guide
Published: 2022-11-06 14:31:18

## Project Information
Aleo is a blockchain that uses Zero-Knowledge proof technology. The use of this technology allows for a high level of privacy when working with the network - non-disclosure of the sender's wallet and transaction amount.

Aleo supports the operation of smart contracts, and as a consequence, the possibility of creating DApps on it. The LEO application development language and its own development environment (IDE) were developed especially for this purpose.

## Installing Node
**Server requirements**
Minimum (VDS/DS):
16 CPUs, 16 GB RAM, 128 GB SSD, Ubuntu 20.04

Recommended (VDS/DS):
32 CPU, 32 GB RAM, 128 GB SSD, Ubuntu 20.04

I use Hetzner
https://accounts.hetzner.com/login


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/82eu3reoyo1rdaa7ummv.jpeg)

## Launch
**Linux |Manual|**
Refresh packets

```javascript
sudo apt update && sudo apt upgrade -y
```
Install the required packages

```javascript
sudo apt install wget jq git build-essential pkg-config libssl-dev -y
```
Install the Rust

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/installers/rust.sh)
```
Clone a repository with a node

```javascript
cd; git clone https://github.com/AleoHQ/snarkOS.git --depth 1
```
Go to the snarkOS folder

```javascript
cd snarkOS
```
Build a snarkOS binary

```javascript
cargo build --release
```
Copy the binary file to the standard binary storage

```javascript
mv $HOME/snarkOS/target/release/snarkos /usr/bin
```
Check version

```javascript
snarkos --version
```

> Already have a wallet

Place a file called `account_aleo.txt`, necessarily containing the line

```javascript
 Address  aleo1___
```
By path (the command displays the path)

```javascript
echo $HOME/account_aleo.txt
```

> No wallet yet.

**Create a Wallet**

```javascript
snarkos experimental new_account > $HOME/account_aleo.txt
```

> Make a backup copy of the wallet data file, saving it in a safe place (the command shows the path)
> 

```javascript
echo $HOME/account_aleo.txt
```
> _Do not show your private key to anyone_

**Continued**

Add the wallet address to the system as a variable

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n aleo_wallet_address -v `grep -oPm1 "(?<=Address  )([^%]+)(?=$)" $HOME/account_aleo.txt`
```
Check that the address was added to the system

```javascript
echo $aleo_wallet_address
```
_If not, go back to the step with the wallet work_

Open the ports in use

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/ports_opening.sh) 3032 4132
```
Create a service file

```javascript
printf "[Unit]
Description=Aleo Miner
After=network-online.target

[Service]
User=$USER
ExecStart=`which snarkos` --miner $aleo_wallet_address --trial  --node 0.0.0.0:4132 --rpc 0.0.0.0:3032
Restart=on-failure
RestartSec=3
LimitNOFILE=65535

[Install]
WantedBy=multi-user.target" > /etc/systemd/system/aleod.service
```
Run the service file

```javascript
sudo systemctl daemon-reload
sudo systemctl enable aleod
sudo systemctl restart aleod
```
Add a command to view the miner's log to the system as a variable

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n aleo_log -v "sudo journalctl -fn 100 -u aleod" -a
```
Add a command to view information about the miner in the system as a variable

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n aleo_node_info -v ". <(wget -qO- https://raw.githubusercontent.com/SecorD0/Aleo/main/node_info.sh) -l RU 2> /dev/null" -a
```
Wait a couple of minutes for the miner to start up

```javascript
aleo_log
```
**Linux |automatic|**
Run the script and wait for the installation to complete

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/Aleo/main/multi_tool.sh)
```
To start the miner on an existing wallet, you need to put a file called `account_aleo.txt`, which must contain the line

```javascript
      Address aleo1___
```
Path (the command shows the path)

```javascript
echo $HOME/account_aleo.txt
```
And run the script after that

## Reset synchronization
Stop the miner

```javascript
sudo systemctl stop aleod
```
Uninstall the database

```javascript
rm -rf $HOME/.aleo/storage/ledger-2
```
Restart the miner

```javascript
sudo systemctl restart aleod
```

## Information about the miner
Add a command to view information about the miner in the system as a variable

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/utils/main/miscellaneous/insert_variable.sh) -n aleo_node_info -v ". <(wget -qO- https://raw.githubusercontent.com/SecorD0/Aleo/main/node_info.sh) -l RU 2> /dev/null" -a
```

View information about the miner

```javascript
aleo_node_info
```

## Update
**Manual**
If you have not downloaded the GitHub repository with the node (snarkOS folder), then clone it

```javascript
cd; git clone https://github.com/AleoHQ/snarkOS.git --depth 1
```
Update the binary files

```javascript
cd $HOME/snarkOS && \
git stash; \
git pull; \
git stash; \ git pull; \ cargo clean; \
cargo build --release; \
mv $HOME/snarkOS/target/release/snarkos /usr/bin; \
cd
```
Run the service file

```javascript
sudo systemctl restart aleod
```
**Semi-automatic**
Run the script and wait for the update to complete

```javascript
. <(wget -qO- https://raw.githubusercontent.com/SecorD0/Aleo/main/multi_tool.sh) -u
```

**Automatic**
Create a service file

```javascript
printf "[Unit]
Description=Aleo auto-updater
After=network.target

[Service]
type=forking
User=$USER
Environment="HOME=$HOME"
WorkingDirectory=$HOME
ExecStartPre=`which wget` -qO $HOME/.aleo/multi_tool.sh https://raw.githubusercontent.com/SecorD0/Aleo/main/multi_tool.sh
ExecStartPre=`which chmod` +x $HOME/.aleo/multi_tool.sh
ExecStart=$HOME/.aleo/multi_tool.sh -u
Restart=always
RestartSec=1m

[Install]
WantedBy=multi-user.target" > /etc/systemd/system/aleou.service
```
Run the service file

```javascript
sudo systemctl daemon-reload
sudo systemctl enable aleou
sudo systemctl restart aleou
```

> The script restarts every minute

To view the log of the auto update script

```javascript
sudo journalctl -fn 100 -u aleou
```

## Useful Commands
Available variables (remove echo if used)

```javascript
echo $aleo_wallet_address
```
View log
Miner

```javascript
aleo_log
sudo journalctl -fn 100 -u aleod
```
automatic update script
```javascript
sudo journalctl -fn 100 -u aleou
```
View information about the miner

```javascript
aleo_node_info
```
Restart the miner

```javascript
sudo systemctl restart aleod
```