How to stake Mina using own Mina node

How to install Linux?

To stake Mina from your command line without any intermediary entity, we recommend to install Ubuntu as one of the most user-friendly Linux distributions. You can find guides how to install Ubuntu here:
If you prefer some another Linux distribution to use for Mina staking, the steps below are similar.

How to stake Mina?

Launch terminal

Click Ctrl+Alt+T.
Linux terminal is opened. You can find a short guide of terminal commands for beginners here.

Create private key

At first, enter the following commands to install necessary packages:
1
echo "deb [trusted=yes] http://packages.o1test.net release main" | sudo tee /etc/apt/sources.list.d/mina.list
2
sudo apt-get update
3
sudo apt-get install -y curl unzip mina-mainnet=1.1.5-a42bdee
Copied!
Then install the key generator with the command:
1
sudo apt-get install mina-generate-keypair=0.2.12-718eba4
Copied!

Generate the key:

When creating keys, you will be asked to create a password.

Option 1 with a package:

1
mina-generate-keypair -privkey-path ~/keys/my-wallet
Copied!

Option 2 using docker:

1
sudo docker run --interactive --tty --rm --volume $(pwd)/keys:/keys minaprotocol/generate-keypair:0.2.12-718eba4 -privkey-path /keys/my-wallet
Copied!

Set necessary permissions:

1
chmod 700 $HOME/keys
2
chmod 600 $HOME/keys/my-wallet
Copied!

Check private key

When checking the key, you will be asked to enter the password from it.

Option 1 with a package:

1
mina-validate-keypair -privkey-path ~/keys/my-wallet
Copied!

Option 2 using docker:

1
sudo docker run --interactive --tty --rm --entrypoint=mina-validate-keypair --volume $(pwd)/keys:/keys minaprotocol/generate-keypair:0.2.12-718eba4 -privkey-path /keys/my-wallet
Copied!
In both cases, if everything is ok with your keys, you will receive a message:
1
Verified a transaction using specified keypair
Copied!
It means your keys have been verified.
Now let's write your public key to the server in the .bashrc file so that we don't export them again next time.
1
echo 'export KEYPATH=$HOME/keys/my-wallet' >> $HOME/.bashrc
2
echo 'export MINA_PUBLIC_KEY=$(cat $HOME/keys/my-wallet.pub)' >> $HOME/.bashrc
3
source ~/.bashrc
Copied!

Launch a node with Docker

Install Docker

Install and activate Docker:
1
sudo apt install docker.io curl -y \
2
&& sudo systemctl start docker \
3
&& sudo systemctl enable docker
Copied!

Firewall configuration

If your VPS server has a built-in Firewall, then you should open ports 8302 and 8303 there.
If not, then follow the commands below:
Open ports 8302 and 8303:
1
sudo iptables -A INPUT -p tcp --dport 8302:8303 -j ACCEPT
Copied!

Run a node

Variables description: --name mina - you can use any name for the container, or leave it as it is; -block-producer-password "YOUR PASS" - instead YOUR PASS enter the password for your key. $KEYPATH - path to the file with the private key my-wallet.
Optional: --coinbase-receiver B62qp... - flag to redirect block reward to another address.
1
sudo docker run --name mina -d \
2
--restart always \
3
-p 8302:8302 \
4
-p 127.0.0.1:3085:3085 \
5
-v $(pwd)/keys:$HOME/keys:ro \
6
-v $(pwd)/.mina-config:$HOME/.mina-config \
7
--env CODA_PRIVKEY_PASS='YOUR_PASS' \
8
minaprotocol/mina-daemon-baked:1.1.5-a42bdee daemon \
9
-block-producer-key $KEYPATH \
10
--peer-list-url https://storage.googleapis.com/mina-seed-lists/mainnet_seeds.txt \
11
--insecure-rest-server \
12
--open-limited-graphql-port \
13
--limited-graphql-port 3095 \
14
--file-log-level Debug \
15
-log-level Info
Copied!

Viewing logs with docker

View running containers:
1
sudo docker ps -a
Copied!
Node container logs:
1
sudo docker logs --follow mina -f --tail 1000
Copied!
Node status:
1
sudo docker exec -it mina mina client status
Copied!
Wait for the node to synchronize. The Sync status: field should say Synced (see the screenshot below). If the status says Catched, then you need to wait a little longer. After this you can start importing your keys.

Launch a node with Service

Firewall configuration

Open ports 22, 8302 and 8303 and activate the Firewall:
1
sudo ufw allow 22 \
2
&& sudo ufw allow 8302 \
3
&& sudo ufw allow 8303 \
4
&& sudo ufw enable
Copied!
We check the status of open ports with the command:
1
sudo ufw status
Copied!
If you do not have UFW installed on your server, install it using the command sudo apt install ufw

Node configuring

Downloading package Mina:
1
echo "deb [trusted=yes] http://packages.o1test.net release main" | sudo tee /etc/apt/sources.list.d/mina.list
2
sudo apt-get update
3
sudo apt-get install -y curl unzip mina-mainnet=1.1.5-a42bdee
Copied!
Download the file with peers:
1
curl https://storage.googleapis.com/mina-seed-lists/mainnet_seeds.txt > ~/peers.txt
Copied!
Setting up the mina-env file:
1
nano .mina-env
Copied!
We copy and paste the variables into the file after entering your password from the key instead of YOUR PASS FOR KEYS:
1
CODA_PRIVKEY_PASS="YOUR PASS FOR KEYS"
2
EXTRA_FLAGS=" -file-log-level Debug"
Copied!
Save ans exit: CTRL+S and CTRL+X

Start the service

1
systemctl --user daemon-reload
2
systemctl --user start mina
3
systemctl --user enable mina
4
sudo loginctl enable-linger
Copied!
Viewing logs:
1
journalctl --user-unit mina -n 1000 -f
Copied!

Importing keys

We import an account with a key with the following command:
With Service:
1
mina accounts import -privkey-path $HOME/keys/my-wallet
Copied!
With Docker:
1
sudo docker exec -it mina mina accounts import -privkey-path $HOME/keys/my-wallet
Copied!
The list of your accounts can be viewed with the command below:
1
mina accounts list
Copied!

Unlock the account

First, let's export the Public Key:
1
export MINA_PUBLIC_KEY=$(cat $HOME/keys/my-wallet.pub)
Copied!
Let's unlock the account so that you can move tokens:
With Service:
1
mina accounts unlock -public-key $MINA_PUBLIC_KEY
Copied!
With Docker:
1
sudo docker exec -it mina mina accounts unlock -public-key $MINA_PUBLIC_KEY
Copied!
In the password input field, write your password from the key and press ENTER.

Stake tokens

Use the following command template:
1
mina client delegate-stake \
2
-sender "PASTE YOUR MINA WALLET ADDRESS HERE" \
3
-receiver "PASTE VALIDATOR'S ADDRESS HERE" \
4
-fee "PASTE FEE HERE"
Copied!
Example of the command above:
With Service:
1
mina client delegate-stake \
2
-sender B62qnJHBeVJqWamtDhWDPwrX7Y5jiXKcMKTuvug9LQ8ictwNTWN7YvJ \
3
-receiver B62qqV16g8s744GHM6Dph1uhW4fggYwyvtDnVSoRUyYqNvTir3Rqqzx \
4
-fee 0.03
Copied!
With Docker:
1
sudo docker exec -it mina mina client delegate-stake \
2
-sender B62qnJHBeVJqWamtDhWDPwrX7Y5jiXKcMKTuvug9LQ8ictwNTWN7YvJ \
3
-receiver B62qqV16g8s744GHM6Dph1uhW4fggYwyvtDnVSoRUyYqNvTir3Rqqzx \
4
-fee 0.03
Copied!
Specify the following Mina fee amount depending on transaction speed you want:
    Moderate speed is 0.01
    Fast speed is 0.05
    Very fast speed is 0.1
Tokens are on the journey to stake and will be used by the staking provider soon. Just wait for your Mina rewards from now. Don't be scared that your tokens are still visible on your balance. Physically Mina tokens are not moved to the staking provider from your wallet.
The whole balance of your address will be delegated into stake to a Mina validator.
The command above sends your Mina funds to StakeTab staking provider. If you want to stake Mina with another provider, you can select one on the Mina block explorer.
After delegation, you can stop your node running. There is no need for that after successful delegation.

Resources

There are much more options to stake Mina from your own node. For example, you can use Docker, set up TMUX and Snark stopper or update your node. For details, please see the How to stake Mina using own delegating node detailed guide.
Last modified 16d ago