Use Cleos to move you into Blockchain's World!

Cleos is a powerful command line tool that interfaces with API and interacts with blockchains based on EOSIO and smart contracts.

In this tutorial we will learn how to install cleos and create a local wallet. This is a good way to start understanding how a blockchain works.
Further on, as a practical lesson for handling the tool, we will perform a simple voting command on the Proton blockchain to give your preference to the BPs, but first read the Legal disclaimer: we (Blockside.io) are not financial advisors. The tutorials in this website are not financial advices.
You can follow these tutorials at your own risk and nobody can guarantee your results. Unlike the Testnet, real money runs on the Mainnet, so be aware that cryptocurrency investment is risky, please be cautious. Different countries have different rules for cryptocurrency. It’s very important for your own security that before continuing with this tutorial you know the importance of your private key of your account and the differents between Mainnet and Testnet. These tutorials run on MainNet, but you can also use a TestNet. Keep your device safe. If your device is compromised, the wallet can be compromised too. Ignoring these steps will highly increase the chances of your cryptocurrency being lost or stolen, in which case we won’t be able to help you.



### So, let's start! ###

Requirements:

1) Linux Ubuntu 18.04
(or Windows 10 with a Linux console installed or a macOS with a Virtual Machine of Linux)
Note: in Windows 10, by enabling WSL, you can open a Linux console; to do that, first enable WSL, then launch Ubuntu 18.04 by following these procedures:
Windows 10 how to enable WSL

2) Proton account on Proton Mainnet
If you have not an account on Proton Mainnet blockchain, you can get one by following the link:
Create Proton account



Now we can start.
Open the command line and create a directory named blockchain
mkdir ~/blockchain

enter the directory
cd ~/blockchain

download latest eosio version (at time of writing version is 2.0.13):
wget https://github.com/EOSIO/eos/releases/download/v2.0.13/eosio_2.0.13-1-ubuntu-18.04_amd64.deb

change permissions:
chmod +x eosio_2.0.13-1-ubuntu-18.04_amd64.deb

install it:
sudo apt install ./eosio_2.0.13-1-ubuntu-18.04_amd64.deb

now verify the version of cleos:
cleos version client
OUTPUT:
v2.0.13


create new wallet:
cleos wallet create --to-console
OUTPUT:
PW5.........
this is the password of your wallet; keep it safe and copy in a secure place

open the wallet:
cleos wallet open

unlock the wallet:
cleos wallet unlock
now insert the password of your wallet and press enter (wallet password will not be displayed when you insert it)

Now, you can import your Active Private Key into your local wallet
in this example:
- Active Private Key of this example start with 5KJF.............................
and the relative Active Public Key of this example is EOS71G3572rLNFworZrDBZ6iCkJaGwQXB2EFQo9USBXUNXzrK6nit
(Remember: do not use your Owner Private Key (use your private Active Key); never give or show someone else your private keys!!! )

Ok, now import your Active Private Key into your local wallet:
cleos wallet import --private-key
now insert your Active Private Key and press enter (private key will not be displayed when you insert it).


Verify that the wallet contains the key:
cleos wallet keys
OUTPUT:
[ "EOS71G3572rLNFworZrDBZ6iCkJaGwQXB2EFQo9USBXUNXzrK6nit" ]

This is your Public key associated with your account. The associated private key is also in the wallet, but not displayed with this command.


Now we can use cleos to vote on the Proton blockchain (replace YOUR_ACCOUNT_HERE twice with your account) and replace API_SERVER_HERE with a Proton API Nodes from the verified MainNet Nodes on:
cleos -u API_SERVER_HERE push transaction '{"delay_sec":0,"max_cpu_usage_ms":0,"actions":[{"account":"eosio","name":"voteproducer","data":{"voter":"YOUR_ACCOUNT_HERE","proxy":"","producers":["blocksideita", "eosamsterdam", "eosbarcelona", "eosusa"]},"authorization":[{"actor":"YOUR_ACCOUNT_HERE","permission":"active"}]}]}'

Here we are; if everything is ok, you just used cleos on the command line to give your preference to the BPs indicated in the code. Votes can be reconfirmed or changed several times, as you wish, and will be stored on Proton Blockchain.

Rember to close the wallet:
cleos wallet lock_all



Rember to stop the wallet service:
cleos wallet stop

finally verify your account (replace YOUR_ACCOUNT_HERE with your account) on PROTON MainNet:
cleos -u API_SERVER_HERE get account YOUR_ACCOUNT_HERE


Next: get the balance

Last updated January 16, 2022