Stake With Linux 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.
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 2CPU/2GB ram VPS.
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.
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.
### Enabling SWAP
##### 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.
dd if=/dev/zero of=/swapfile bs=1M count=2048
chmod 600 /swapfile
echo "/swapfile none swap defaults 0 0" >> /etc/fstab
This creates a 2GB swap file which will allow you to build and run Hydra without issues.
### Compiling Hydra
This is a quick start script for compiling Hydra on Ubuntu
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils git cmake libboost-all-dev
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev
# If you want to build the Qt GUI:
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
git clone https://github.com/LockTrip/Blockchain/tree/hydra_testnet_v0.1.0 --recursive
# Note autogen will prompt to install some more dependencies if needed
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
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.
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 2,000+ confirmations before they become mature enough for 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.
To check your balance, type
hydra-cli getinfothis will show general information, including your available balance and balance in staking
To check your transactions (incoming and outgoing) type
Check staking info
To check Hydra's staking information, type
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 getnewaddressEach 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.
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!.
You can view your Coin balance and amount currently staked with the following command:
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:
./hydra-cli gethexaddress <YOURADDRESS>
We can then call the contract replacing <YOURHEXADDRESS> here:
./hydra-cli callcontract 4ab26aaa1803daa638910d71075c06386e391147 70a08231000000000000000000000000<YOURHEXADDRESS>
Finally convert the "output" section of the response from hex to decimal to arrive at your LOC balance.
Below is a full example:
Amount displayed is adjusted by 8 decimal places. It is 64,172.22773141.
To see expected time enter the following command:
Note below the section "expectedtime".
The "expectedtime" can be converted to human readable format using the following command (replace
1254588with your expectedtime value:
date -u -d "@1254588" "+%d days %H hours %M minutes"