This guide will teach you how to setup a Sparks Masternode on a remote server (VPS). You should have at least a basic knowledge of Linux. For better clarity, all commands that must be typed shall be displayed as such:

 

this is a command


Type the command exactly (you may copy&paste it). There will always be some space between commands, so that you can easily see commands spanning over several lines. Some commands may also be appended together with && to speed up the process when commands are short or trivial. You may execute these commands as one, or you may type each one separately.


If you need any additional help, feel free to join our discord and ask for help in the #masternode channel.

BEWARE scammers trying to impersonate team members! Do not accept help from people directly contacting you. No one from SparksPay team will contact you and “help” proactively!

 

What you’ll need


1.     A local computer – your everyday computer, typically a Windows or Mac, which will run a control wallet and hold your coins. This computer need not always be online.


2.    A remote server – typically a VPS, with Ubuntu Server 20.04 64-bit OS installed with a unique and static IP address (an IP address that does not change), which is always running and connected to the Internet. This VPS should at least have 1Gb of RAM and 10Gb of space storage.


3.    A collateral – an amount in Sparks that will be unspendable as long as you wish to keep your node running. You will need 25,000 SPK and some change for transaction fees, so 1 SPK more to cover expenses is good enough.

 

Setting up a Control wallet

 

Step 1 – Set up wallet


This involves downloading and synchronizing the wallet. Please refer to our wallet guide if you need any help

 

Step 2 – Create collateral


As mentioned above, you will need some Sparks to create what is called a collateral: a certain amount of Sparks that will be “frozen” in order for your masternode to keep running.

You will first need to get the amount of sparks for the collateral, as well as a small amount to pay the transactions fees. You may purchase some Sparks on exchanges (see available exchanges in Tools > Exchanges).

Once you have this amount in your control wallet, you need to set it as an official collateral. This is done by creating a receiving address in your wallet, and sending the exact amount – 25,000 SPK – to it. Making a payment to yourself requires a fee. This is why you needed that extra SPK.

After making that payment, you will need to retrieve some information about it: the Transfer ID and Index.

This information can be found using the Debug Console. Go to Tools > Debug Console and type the following command:

 

masternode outputs

 

This will yield something like this:

 

{
  "65cf41726b215976ee8c9e35a06aec003af1557be435d9d11f91cd47e7570911": "1",
}

 

The first part is the transfer ID, and the last (the digit) is the index. This information can also be found in the explorer if you type the address you sent the collateral to.

 

Step 3 – Create private key and BLS key

A private key is used to identify your masternode in your control wallet. You can create this key using the console again and typing the following command:

 

 

masternode genkey

 

The BLS key is needed for the new DIP3 deterministic masternodes. You may read more about deterministic masternodes here.

 

bls generate

 

The command yields a private key and a public key. You will need to keep both parts for future use. The private key will be inserted in the sparks.conf file of the masternode and the public key will be needed to activate the masternode on the blockchain.

 

Setting up a VPS

The following procedure assumes an installation from scratch. If you have an existing VPS already installed, then some steps might not be needed. BEWARE: while we provide certain security measures and best practices, securing your server is still your responsibility!

 

Step 1 – Acquire a VPS from any provider

The cheapest one will do, provided you create a swap file (see below). Here are a few providers:

When asked, choose the Ubuntu 20.04 LTS Linux distribution.

 

Step 2 – Log into your VPS and install updates and packages

In order to access your VPS, you will need a software/SSH client such as PuTTY. This tutorial does not cover installation of, nor how to use such software.

Once you have access to your VPS, create a user that will be running your masternode (for security reasons, it is always better not to run any application as root user):

 

adduser sparks && adduser sparks sudo

 

This creates user “sparks” with root privileges (be able to run root commands using the “sudo” prefix).

 

Switch to “sparks” user

 

su - sparks

 

A clean server install will likely need some software updates. Enter the following command which will bring the system up to date (can take a few minutes to complete):

 

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y

 

Reboot your VPS for changes to take effect:

 

sudo reboot

 

After rebooting, switch to sparks user again:

 

su - sparks

 

Install the following packages and libraries:

 

sudo apt-get install -y ufw wget git nano htop unzip autoconf automake
sudo apt-get update -y

 

Step 3 – Set up a Swap File

This will be needed especially if using a low end VPS and you wish to compile the source code. Some providers already install a swap on their VPS. You can check this by doing:

 

htop

This provides you with a nice view of your VPS resources. In the higher left part, check if Swp has any value higher than 0K. If so, you are good to go to Step 4. If not, continue below.

The following command sets up a 2 Gb swap file. You may change this size by modifying the 2G to anything you like (we still recommend at least 1G). Leave all other commands unchanged.

 

sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile && echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab && sudo sysctl vm.swappiness=10 && sudo sysctl vm.vfs_cache_pressure=50 && echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf && echo 'vm.vfs_cache_pressure=50' | sudo tee -a /etc/sysctl.conf

More information about swap files

 

Step 4 – Set up a Firewall

This protects your VPS against some attacks. You might need to add some additional allow clauses if your VPS is used for anything other than your Sparks masternode.

Allow all ports needed:

 

sudo ufw default allow outgoing && sudo ufw default deny incoming && sudo ufw allow ssh/tcp && sudo ufw limit ssh/tcp && sudo ufw logging on && sudo ufw enable

Allow Sparks port:

 

sudo ufw allow 8890/tcp comment Sparks

Check status:

 

sudo ufw status

You should see the following lines (maybe only one if IPv6 is not enabled on your VPS):

 

    8890/tcp       ALLOW       Anywhere         # Sparks
    8890/tcp (v6)  ALLOW       Anywhere (v6)    # Sparks

More information about ufw firewall

 

Step 5 – Install masternode binaries and configuration

Get the latest binaries from github. At the time of writing, latest version is v0.13.4.2. You should check on github and adapt the following commands with latest binaries reference.

 

wget https://github.com/sparkspay/sparks/releases/download/v0.13.4.2/sparkscore-0.13.4-x86_64-linux-gnu.tar.gz

 

tar zxvf sparkscore-0.13.4-x86_64-linux-gnu.tar.gz

 

sudo mv sparkscore-0.13.4/bin/sparks{d,-cli} /usr/local/bin/

 

rm -r sparkscore-0.13.4*

Before the node can operate as a masternode, a custom configuration file needs to be created. Since we have not loaded the blockchain yet, we will create the necessary directory and configuration file

 

mkdir .sparkscore && cd .sparkscore

Get the following values for your configuration file:

 

  • <user> – an alphanumerical string
  • <password> – an alphanumerical string, not the same as user
  • <vps ip> – the IP of your VPS (looks something like: 192.168.2.1)
  • <private key> – the one you created earlier in your control wallet’s Debug Console
  • <BLS private key> – the one you created earlier in your control wallet’s Debug Console

Create sparks.conf file

 

nano sparks.conf

then copy&paste the following in it, inserting the proper values:

 

rpcuser=<USER>
rpcpassword=<PASSWORD>
listen=1
server=1
daemon=1
maxconnections=16
masternode=1
printtodebuglog=0
disablewallet=1
 
externalip=<VPS IP>
rpcallowip=127.0.0.1
rpcport=8818
 
masternodeprivkey=<PRIVATE KEY>
masternodeblsprivkey=<BLS PRIVATE KEY>

*** END OF COPY PASTE ***

Save the file (ctrl-x, then ctrl-y)

 

Step 6 – Start the daemon

Now that you have everything set up, it’s time to start the daemon. To speed up the synchronization of the blockchain, you may download a booststrap file and put it in the .sparkscore directory you created earlier, the one where your sparks.conf file was created (this is not mandatory):

 

wget https://github.com/sparkspay/sparks/releases/download/bootstrap/bootstrap.dat

And finally, launch the masternode daemon

 

sparksd

Wait about 30 minutes for your masternode to sync completely.

You may monitor the sync progress using the following command:

 

watch sparks-cli getinfo

which should yield the following information:

 

{
  "version": 130402,
  "protocolversion": 70214,
  "blocks": <total number of blocks>,
  "timeoffset": 0,
  "connections": 8,
  "proxy": "",
  "difficulty": 22.7406807988061,
  "testnet": false,
  "paytxfee": 0.00000000,
  "relayfee": 0.00010000,
  "errors": ""
}

Here, “watch”-ing lets you see the synchronization (you can exit the watch at any time with ctrl-c).

The blocks number will go up until your masternode reaches the total number of blocks in the blockchain. This is the longest part. You can see what number it needs to reach by hovering over the small V in the lower right of your (Windows or Mac) control wallet.

BEWARE: the blocks number might not start growing for a while. This is because the blockchain could be stuck for lack of miners. As long as you have connections higher than zero you are fine.

You may verify that it is synced using the command:

 

watch sparks-cli mnsync status

which should yield the following information:

 

{
  "AssetID": 999,
  "AssetName": "MASTERNODE_SYNC_FINISHED",
  "Attempt": 0,
  "IsBlockchainSynced": true,
  "IsMasternodeListSynced": true,
  "IsWinnersListSynced": true,
  "IsSynced": true,
  "IsFailed": false
}

The masternode is completely synced when AssetID is 999 (it will go through 0, 1, 2, 3, 4 and 999).

Once your masternode is synced, you may delete the bootstrap file:

 

rm bootstrap*

 

Starting the masternode

Your masternode is now synchronized and chatting with the network but is not accepted as a masternode because it hasn’t been introduced to the network with your collateral. This is done with the control wallet, by issuing some commands in the debug window:

  • protx register_prepare: to format all the masternode information to be loaded on the blockchain
  • signmessage: to authenticate the data as being issued by the legitimate user
  • protx register_submit: to send the masternode data to the blockchain. Note that you will again need a small amount of sparks for this transaction.

 

Step 1 – Activate masternodes tab

If the masternodes tab is not available in your control wallet, you need to activate it. Go to Settings > Options, then Wallet tab and check the Show Masternodes Tab box.

 

Step 2 – Prepare the data to be sent: protx register_prepare

The first command prepares a lot of data to be later sent via a final transaction. You will need:

  • collateralHash: the txid of the 25,000 sparks collateral funding transaction
  • collateralIndex: the output index of the 25,000 sparks funding transaction
  • ipAndPort: the masternode IP address and port, in the format x.x.x.x:8890
  • ownerKeyAddr: A new Sparks address generated to specify the owner (this MUST be a new address, you cannot use the funding address)
  • operatorPubKey: The BLS public key generated using the command “bls generate” in the console (or provided by your hosting service). If you generate the bls keys, please save both private and public keys somewhere safe.
  • votingKeyAddr: A new Sparks address (which can be ownerKeyAddr above), or the address of a delegate. This will be used for proposals voting
  • operatorReward: The percentage of the block reward allocated to the operator as payment (can be up to two decimal places, ie. 0.01. Put 0 if no reward paid)
  • payoutAddress: A new or existing Sparks address to receive the owner’s masternode rewards (CANNOT be owner address)
  • feeSourceAddress: An (optional) Sparks address used to fund ProTx fee (payoutAddress will be used if nothing is specified)

 

/!\ BEWARE: YOU NEED FUNDS AVAILABLE EITHER IN THE payoutAddress OR feeSourceAddress, OR YOU WILL GET AN ERROR “no funds available” /!\

 

full command:

protx register_prepare collateralHash collateralIndex ipAndPort ownerKeyAddr operatorPubKey votingKeyAddr operatorReward payoutAddress (feeSourceAddress)

example:

protx register_prepare 091cf561c894aa0ce067c3b4a0272493939ab0b486a3ba973d49f30ad369b785 1 3.64.16.124:8891 n5pPgcjoYmhN2KqpuKCBBoj9v9NvDfkRy4 8f01b548a9b33b2faef8a8356e961e917859de9ee52768206b878bb7dbce4e46a615504c5371e6e726014eb64dc6f133 nTTypxJLQViZSAAMkcyLWpn6FYw2Fdsah8 0 nSukRcX4AbLQZf8Mr6qbDXPjPBU8YKhT5W​

output example:

{
"tx": "0300010001dd351f667446b5a972c67c7c2433a17c75b982d8d17e09236e9a9becaacc5eb60100000000feffffff0121c89a3b000000001976a9141e011bdb6131764f61be5b68e0b9269ea7d9646888ac00000000d10100000000001af98c73382c0f8c3e52490186a297fcf9364d0929a1cade9eadb03d971a45380100000000000000000000000000ffff0340107c22bb304fd462ae3f6a2ede3f29a8ef85e5ca669f82358f01b548a9b33b2faef8a8356e961e917859de9ee52768206b878bb7dbce4e46a615504c5371e6e726014eb64dc6f133bfb72abd6e8acc0d654cd86e80db98231734453b00001976a9141e011bdb6131764f61be5b68e0b9269ea7d9646888ac25cae9dbc717890a556a6dbc786680f7d075192f51f0897bc740b42c7d18e2a900",
"collateralAddress": "n9EhZUaEBt2CU3fQSA7jUR7XffZ73FiUgM",
"signMessage": "n7bCsxbkWCo1tjHbgiLkrKbMerdtdq6nbG|0|n9G1M2ihHkjSeTSQZtzpyoAEhzRHcs5D7Z|nNLFmTwGvLaq7ZmiGNyavRuW5kNPh12KL3|42ee265e330dc15d8d5281f3636a420c4c2dd87ac365f13503c3770fd2c84e1a"
}

 

Step 3 – Sign the message: signmessage

This command will create a signature for your masternode registration, based on all the info provided in the previous command. You will need:

  • collateralAddress: the Sparks address holding the 25,000 spk collateral (it is provided in the output of the previous command)
  • signMessage: the signMessage output from the previous command

full command:

signmessage collateralAddress signMessage

example:

signmessage n9EhZUaEBt2CU3fQSA7jUR7XffZ73FiUgM n7bCsxbkWCo1tjHbgiLkrKbMerdtdq6nbG|0|n9G1M2ihHkjSeTSQZtzpyoAEhzRHcs5D7Z|nNLFmTwGvLaq7ZmiGNyavRuW5kNPh12KL3|42ee265e330dc15d8d5281f3636a420c4c2dd87ac365f13503c3770fd2c84e1a

output example:

H0yx21Ilfpp6HeBrRTmrgYV2Yu/++g8IeBDBMuOjdW0LA4XrgWT9WW9+H7lAE9wly7yHnsPR8dOIS+SvB9NE7DA=

Step 4 – Register your masternode: protx register_submit

This final command will register your masternode on the blockchain. This is the command for which you will need a small transfer fee. Note that previously we needed to wait 15 confirmations for the collateral to be valid. With DIP3 masternodes, only one confirmation is enough. You will need:

  • tx: the transfer tx provided by the first command’s output
  • signature: the output of the second command

full command:

protx register_submit tx sig

example:

protx register_submit 0300010001dd351f667446b5a972c67c7c2433a17c75b982d8d17e09236e9a9becaacc5eb60100000000feffffff0121c89a3b000000001976a9141e011bdb6131764f61be5b68e0b9269ea7d9646888ac00000000d10100000000001af98c73382c0f8c3e52490186a297fcf9364d0929a1cade9eadb03d971a45380100000000000000000000000000ffff0340107c22bb304fd462ae3f6a2ede3f29a8ef85e5ca669f82358f01b548a9b33b2faef8a8356e961e917859de9ee52768206b878bb7dbce4e46a615504c5371e6e726014eb64dc6f133bfb72abd6e8acc0d654cd86e80db98231734453b00001976a9141e011bdb6131764f61be5b68e0b9269ea7d9646888ac25cae9dbc717890a556a6dbc786680f7d075192f51f0897bc740b42c7d18e2a900 H0yx21Ilfpp6HeBrRTmrgYV2Yu/++g8IeBDBMuOjdW0LA4XrgWT9WW9+H7lAE9wly7yHnsPR8dOIS+SvB9NE7DA=

output example:

6b0982389fcced5b6540262ede45ffc9cfc695474b05b90b2e73895cb24ec339

Finally

Your masternode is now registered on the blockchain and will appear on the Masternodes tab after the last protx transaction is mined to a block (one confirmation needed).

The output of this final command will be needed if you wish to update the masternode’s information, but you can easily retrieve it by right-clicking on your masternode’s info, which you can find in the wallet under the Masternodes tab (check the box “my masternodes” to find it more easily).

You may check you masternode status on your VPS by issuing the following command:

 

sparks-cli masternode status

which should yield the following information (block heights will vary):

 

{
"outpoint": "<collateralHash>-<collateralIndex>",
"service": "<ipAndPort>",
"proTxHash": "<Some value for the protx hash>",
"collateralHash": "<collateralHash>",
"collateralIndex": <collateralIndex>,
"dmnState": {
"service": "<ipAndPort>",
"registeredHeight": 916544,
"lastPaidHeight": 929161,
"PoSePenalty": 0,
"PoSeRevivedHeight": -1,
"PoSeBanHeight": -1,
"revocationReason": 0,
"ownerAddress": "<ownerKeyAddr>",
"votingAddress": "<votingKeyAddr>",
"payoutAddress": "<payoutAddress>",
"pubKeyOperator": "<operatorPubKey>"
},
"state": "READY",
"status": "Ready"
}

 

Need Help?

Join us on Discord or use the contact form