Table of contents
- Setup
- Generating your address and keys
- Building your configuration file
- Run the client
- Set up RPC client
- Becoming a validator
- Addendum
1. Setup
1.1 Prerequisites
You must install several software packages before compiling the rust code.
Debian:
sudo apt install build-essential libssl-dev clang cmake
Fedora:
sudo dnf install openssl-devel clang cmake
1.2 Install Rust
To install the Rust compiler and its package manager Cargo, see the installation instructions on this page: https://www.rust-lang.org/learn/get-started
Then install the stable
version of Rust and make it the default by running:
rustup install stable
rustup default stable
1.3 Clone the repo
Clone the Albatross source code from GitHub:
git clone [email protected]:nimiq/core-rs-albatross.git
git clone https://github.com/nimiq/core-rs-albatross.git
Change to the repository directory with cd core-rs-albatross
and run the above command to install and compile all the necessary dependencies so you can build your Nimiq Client. This might take a while and will use your full CPU.
cargo build --release
2. Generating your address and keys
To become a validator, you need to generate your address and keys. You need to generate 3 different Schnorr signatures and 1 BLS signature. They will serve you as your address and keys. You need to store them, as you will need to paste them in a subsequent step. In your command line, run the following command three times as each one will print a different signature:
cargo run --bin nimiq-address
At first, it will generate a Schnorr signature that will be your address, which should look like this:
Address: NQ79 UK7F PTB4 HMG6 742P RCJN 09UQ F4KE B6SE
Address (raw): e4cefbed448d60839057cb256027987926e59b4e
The second Schnorr signature to be generated will print your fee key:
Public Key: d363823e1744d92fa47f0a6fa9aad489eb331d11a426c63f42a507e032b14eca
And the third time you run the command, it will generate the Schnorr signature which will be your signing key:
Private Key: 732ff75b7c28282a8808ab7148187d884cb47d81740f3db2589b0788bff0d8c
Then, you have to generate a BLS signature which will be your voting key:
cargo run --bin nimiq-bls
It should result as the example below:
# Public Key: 80e85cfdf068082b451e030bc5f7731de7a5c72175b5bc671070c5209a941fdc24f4a4c23311f689bffbbc7033853ce66442c40599c2c11f4855c823417602fd9f3f00fad1f0a2881cd0bc3cb29935cfbf6d0802a29876163af4b9de40142e017282a50f10772aaeb1139457ac1326faa505086ef64d3c687489aca492be6e3ef7c4520bcac0604c9ef2b04a4dfec221632d87c7b90b7b2795e2f85957203147a0307f57239435efded7b0cd5cc08bcf97f14bdaf205ea7a5cd4458311dc019f4f0fa09191d07a52f894582f6b18dddcc40ef570cc9c4bd5857740b49f6f9060335d1dffb70f1bdd2316ab6d5d7a2c45c3ad700aa67279173a6bbac9fefbbfc050a33841f3a1f129e957e96b0b48ed0f8cabb270e2a88d90b54c32c48b
# Secret Key:
6465ecd32f2e329b0b7a5fd21a7cd8bc84b53262689e0c901c0600a11be4617f217f4eed6a2d9892c575f6a1265a211a8824ec04926f2be2d073075d38c8a2e30b3c288ffed599437b7a5827926636209c44605d21986205e6922b7201490110
# Proof Of Knowledge:
80e25119328c328513c147d106e6c0dc49b724277c045bc66d392d8161c96900821f93046a81907340c23d4f4b5dc94d1a82c91aa97fac5b27fc4d1f19927a7f86f03d9b852f0f24af4be8dd5d1e8a9437805ba097f36ad55294021ff20ffd
Disclaimer: the address and correspondent keys are for example purposes only. Please don’t use this as yours as they are invalid results.
3. Building your configuration file
In the directory repository, create a .toml
file and edit it with your address and keys, according to this sample:
[network]
peer_key_file = "peer_key.dat"
listen_addresses = ["/ip4/127.0.0.1/tcp/9443/ws"]
seed_nodes = [
{ address = "/dns4/seed1.v2.nimiq-testnet.com/tcp/8443/wss" }
]
[log]
level = "debug"
timestamps = true
[rpc-server]
bind = "127.0.0.1"
port = 8\648
[validator]
validator_address = "NQ94 RK3K TADJ XVAB TU0M 4GKL FQYG JEF0 TLL5"
voting_key = "176b8265f6e107d007961231bbbc47208151bad4f46829b143b6eb0ce27b85f604ad85f1e14b6b374d6b65bb4040267b848bcd57f29e8278ba23269cb5fad08cd61b76ca05f9d22fb2fe7c93f5a480de0997b0de64b2a2db95369be41e610000"
voting_key_file = "voting_key.dat"
signing_key_file = "signing_key.dat"
signing_key = "e29526df970e2eb0bae91e88eb6f655021885d432f79107c547761253353175d"
fee_key_file = "fee_key.dat"
fee_key = "43dd962feb8a4df3fae3a46e709c85f9a152e691e36f15bd6e33a7b3e03bde7b"
automatic_reactivate = true
- Is recommended to change the
listen_address
to your public IP. - In the validator part, paste the address and private keys you generated in step 2. The address must be quoted as the example above.
- We strongly recommend turning the
automatic_reactivate
astrue
.
4. Run the client
After edit your .toml
file with your address and keys, run cargo run --release --bin nimiq-client -- -c client.toml
. This will launch your client and connect you to the Nimiq network, reaching consensus by syncing. Mind that the .toml
file is the one generated in step 3 of this guide. Only the history sync is currently available, so this will download all the micro and macro blocks from the Genesis Block to the current state. This also can take a while.
5. Set up the RPC client
5.1. RPC client using arpl
Clone the following repository:
git clone [email protected]:nimiq/core-rs-albatross.git
git clone https://github.com/sisou/arpl.git
Change the directory with cd arpl
and build all the files from the repository with npm build
.
5.2 Connecting to the server
From this point on, to attach via RPC to the node and connect you to the server for remote management for Nimiq Albatross nodes, run bin/run repl -u ws://127.0.0.1:8648/ws
and this will print options to guide you through the server. You need to use the same IP address and port specified in the rpc-server
section of the configuration file generated in step 3 in order to connect to the server. By setting up the RPC server, you have enabled the way to communicate with the network.
Connected to RPC-Websocket:ws://localhost:8648/ws
localhost > help
Straight-forward remote management for Nimiq Albatross nodes
VERSION
@sisou/albatross-remote/0.7.2 linux-x64 node-v14.18.1
USAGE
$ arpl [COMMAND]
CONNECTION OPTIONS
-u, --url The URL of the RPC server, overwrites host and port options (default: [http|ws]://localhost:8648[/ws])
-h, --host Hostname of the RPC server (default: localhost)
-p, --port Port of the RPC server (default: 8648)
-a, --auth <username:password> for RPC authorization (default: none)
REQUEST OPTIONS
-t, --timeout Timeout for request in ms, set to 0 to disable (default: 5000)
TOPICS
account Manage accounts stored in the node
block Fetch blocks and follow the chain live
peer Fetch information about your peers
stake Manage your stake(s)
transaction Send and fetch transactions
validator Manage your validator
COMMANDS
help display help for arpl
raw Run a raw Nimiq JSON-RPC command
repl Open an interactive REPL session to run commands
status Show the current status of the node
Before attaching your node to a validator, check if you reached consensus by running status
in the command line. Below is a realistic example of what should be printed.
Consensus: established
Height: 78688
Epoch: 615
Peers: 24
You can become a validator only if you reach consensus first. If you haven’t established consensus yet, you must wait until it’s established.
6. Becoming a validator
To become a validator, you need to deposit at least 10 000 NIM in your account to use as stake. This amount will be returned to your account once you stop being a validator. Mind that, when sending transactions to the staking contract, you must add your address quoted.
Using the data of your .toml
file, you can now become a validator with the following transactions (your address must be quoted):
# Import your validator account:
localhost > account:import <validator address private key>
Account imported: validator address (locked)
# Unlock account:
localhost > account:unlock "validator address"
Account unlocked: validator address
# Send the create validator transaction:
localhost > validator:new "validator address" "signing secret key" "voting secret key"
Transaction sent: 13aefb1484f02fd931b5474cbf5035490b431f410b63f6b659f0c0b974276b47
Follows an example of how the transactions should look like:
# Import your validator account:
account:import "a732bf75b7c28282a8708ab7148187d884cb47d81740f3db2589b0788bff0d8c"
# Unlock account:
account:unlock "NQ79 UK7F PTB4 HMG6 742P RCJN 09UQ F4KE B6SE"
# Send the create validator transaction:
validator:new "NQ79 UK7F PTA4 HMG6 742P RCJN 09UQ F4KE B6SE" a732bf75b7c28282a8808ab7148187d884cb47d81740f3db2589b0788bfc0d8c 6465ecd32f2e329b0b7a5fd21a7cd8bc84b53262689e0c901c0600a11be4617f217f4eed6a2d9892c575f6a1265a211a8824ec04926f2be2d073075d48c8a2e30b3c288ffed599437b7a5827926636209c44605d21986205e6922b7201490100
Transaction sent: 13aefb1484f02fd931b5484cbf5035490b431f410b63f6b659f0c0b974276b47
You are now a Nimiq validator! Once the current epoch ends, your address will be posted in our validator stats tool at https://albatross.nimiq.tools/validators
7. Addendum
You can also stake on behalf of a validator which doesn’t require a minimum amount. A validator can also want to stake to increase its stake. If you don’t want to become a validator and prefer to become a staker, jump from step 5 of this guide and run the following command:
localhost > stake:start "staker address" "validator address" 5000000
This will print the hash of the transaction. You can see an example of the transaction below.
localhost > stake:start "NQ23 N3RP 97QB KC4R L5NY 7AFS 5C9Y BRKQ 4E54" "NQ81 VM1U CBF5 8N9T LXCG LEFL FRC3 6G8C JHPX" 5000000
Transaction sent: f770992253475cdf93b13155b51e60958d383271e2e0ac14de57c8ce4666a0bb
You are now a staker in the Nimiq blockchain!