Stake With Linux VPS

Staking with a VPS

For a newer updated guide please see Staking with linux on DigitalOcean VPS
Many users prefer using a VPS for staking purposes, it is safer than using your local machine and it is more convenient for most people as you don't need to leave your computer turned on 24/7, there are also some very cheap and stable solutions you can use.
This tutorial is made with a Vultr https://vultr.com instance, which is a very stable, cost effective and fast provider with instances all over the world, the same principles apply to any other cloud provider you may prefer. Other good alternatives are AWS, DigitalOcean, and many more.

Launching instance

Let's begin, we log into our cloud provider dashboard where we get several options.
Choose a location for the VPS, for this test we've chosen Miami.
Choose a server type, our linux wallet runs on any linux distribution, however, it is recommended to use Ubuntu 18.04 if you want to compile the wallet yourself, (we'll do this on this tutorial). You can select any desired option, we went with a basic 1CPU/512MB ram VPS.
SSH Keys
It is recommended to use ssh-key to login instead of passwords, its far more secure and convenient.
Creating ssh-keys is out of the scope of this tutorial, but here are some good references on how to do this:
After we've created our SSH key, we click on "add new"
Here we can paste our SSH-key, enter a name for it and click on add ssh key.

Build on Ubuntu 16.04 and up

It's always good to refresh installed libraries, for that we do apt update && apt upgrade and just press enter when prompted. This will update all installed packages while also installing any available security updates.
Once we finish the update, let's proceed to installing dependencies and cloning the Hydra sources from Github.
1
2
### Enabling SWAP
3
4
##### This step is necessary as most VPS don't come with SWAP enabled and it'll cause low-ram compilation errors, here's how to create SWAP.
5
6
dd if=/dev/zero of=/swapfile bs=1M count=2048
7
chmod 600 /swapfile
8
mkswap /swapfile
9
swapon /swapfile
10
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
11
This creates a 2GB swap file which will allow you to build and run Hydra without issues.
12
13
### Compiling Hydra
14
15
This is a quick start script for compiling Hydra on Ubuntu
16
17
18
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git cmake libboost-all-dev
19
sudo apt-get install software-properties-common
20
sudo add-apt-repository ppa:bitcoin/bitcoin
21
sudo apt-get update
22
sudo apt-get install libdb4.8-dev libdb4.8++-dev
23
24
# If you want to build the Qt GUI:
25
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
26
27
git clone https://github.com/LockTrip/Blockchain/tree/hydra_testnet_v0.1.0 --recursive
28
cd Hydra
29
30
# Note autogen will prompt to install some more dependencies if needed
31
./autogen.sh
32
./configure
33
make -j2
34
make install
Copied!
Compiling Hydra takes a while, it depends a lot on your VPS resources, it can take anywhere from 3 minutes to 20+ minutes.
Once the process is finished, you'll have all Hydra executables in /usr/local/bin/ you can check by typing
ls /usr/local/bin/

Launching Hydra daemon

hydra-daemon -> This launches the Hydra daemon and the blockchain begins to synchronize right after launching. It can take some minutes before it's fully synced.

Encrypting wallet

We can encrypt the wallet at any time, it's better to do it before we go any further.
To do this, type the following on the command line:
hydra-cli encryptwallet yourpassword
This will encrypt the wallet which in turn closes the daemon, you'll see the following message:
wallet encrypted; Hydra server stopping, restart to run with encrypted wallet. The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.
hydra-cli getaccountaddress "" -> Right after launching the daemon, you can obtain your wallet address by typing this.
You can send Hydra coins to the address we just obtained from the daemon, please remember that those transactions require at least 500+ confirmations before they become mature enough for staking.

Staking

Now that we've waited until we have at least 501 confirmations on our received transaction, we are elligible for staking, however, if our wallet is encrypted (which we did for security reasons) we won't be able to stake, let's open our wallet for staking using the command line!.
hydra-cli walletpassphrase password 999999999 true
The above command will unlock the walet for staking only for 31.6 Years! that should be enough for now. Please note, this will not unlock your backup, only the wallet that's running right now.
Now that we've unlocked our wallet, we need to wait until we have more than 501 confirmations to be elligible for staking, if we already do, it's a matter of time which will vary depending on the network weight vs your wallet's weight.
Checking Balance
To check your balance, type hydra-cli getinfo this will show general information, including your available balance and balance in staking
Check transactions
To check your transactions (incoming and outgoing) type hydra-cli listtransactions
Check staking info
To check Hydra's staking information, type hydra-cli getstakinginfo

Staking tips

Staking really depends on network weight vs your wallet’s weight which is based on the amount of coins you have, higher weight increases your chances of staking a block.
If you have a large amount of coins, it’s a good idea to split those up in separate transactions, for instance, if you have 10.000 Hydra, it’s better to send 10 transactions of 1000 Hydra each to your wallet, each one generates a UTXO input which will take part in staking. This optimizes the staking process and works much better than just one large 10.000 HYDRA input.
If you want to split your coins into different addresses inside your VPS wallet, type the following to obtain new addresses inside your wallet: hydra-cli getnewaddress Each time you type this, you’ll get a new address, Hydra can generate any amount of addresses you want, but please keep in mind, if you do go over 100 new address, you might want to make a new backup of your wallet.

Wallet Backup

Backing up your wallet from a Linux VPS is different from a desktop but not too complicated, there's several ways to do this, and here are some steps which should work on all major desktop OS.
First, we'll download Filezilla, which is an easy to use and secure FTP/SFTP server
Installing is just like any other windows app.
When the installer finishes, we launch Filezilla and are greeted with this screen, let's proceed and add our previously created ssh-key
We go into Edit -> Settings -> SFTP. This will give us the following screen in which we will be able to import our SSH key.
Please note that Filezilla only accepts the private key which is created when the ssh-key was generated.
Here we've already added the ssh key, now we can log into our server
we enter our VPS ip address + username (root in this case), leave a blank password because we're using ssh-key to login
Just press ok when prompted, and you'll be able to log in.
Here we can see the /root/ folder of our VPS, this is where our wallet runs and has the wallet stored in /root/.hydra we can go ahead and double click the folder which will show us the following:
Now all we need to do is scroll down to wallet.dat, right click and select download from the list. This will download the wallet.dat file to our computer, we've successfully backed up our Hydra wallet!.

Updating wallet

Currently we require users to use the repository at https://github.com/Hydra-Chain/node/releases We will update this section shortly.

Getting information through the cli

General wallet information balance/staking

You can view your Coin balance and amount currently staked with the following command:
1
./hydra-cli getwalletinfo
Copied!

Retrieving your LOC token balance through the cli:

This is slightly involved, first we'll need to find out the HEX equivalent of our address. We can do this through the cli with this command:
1
./hydra-cli gethexaddress <YOURADDRESS>
Copied!
We can then call the contract replacing <YOURHEXADDRESS> here:
1
./hydra-cli callcontract 4ab26aaa1803daa638910d71075c06386e391147 70a08231000000000000000000000000<YOURHEXADDRESS>
Copied!
Finally convert the "output" section of the response from hex to decimal to arrive at your LOC balance.
1
echo $((0x<YOUROUTPUT>))
Copied!
Below is a full example:
Amount displayed is adjusted by 8 decimal places. It is 64,172.22773141.

Time until expected block creation

To see expected time enter the following command:
1
./hydra-cli getstakinginfo
Copied!
Note below the section "expectedtime".
The "expectedtime" can be converted to human readable format using the following command (replace 1254588 with your expectedtime value:
1
date -u -d "@1254588" "+%d days %H hours %M minutes"
Copied!
Last modified 6mo ago