How to use cleos

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 Telos blockchain.


Legal disclaimer: we 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. 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. Keep your device safe. If your device is compromised, the wallet can be compromised too. Ignoring this step will highly increase the chances of your funds being lost or stolen, in which case we won’t be able to help you.
WARNING: following this tutorial means that You And Only You are Responsible For Your Security.


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

Requirements:
- Linux Ubuntu 18.04 or Windows 10 with a Linux console installed
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
Install a Linux distro on Windows

- Telos account
Those who have not an account on Telos blockchain can follow one of these procedures:
Create Telos account
or
Another way to create Telos 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.9):
wget https://github.com/EOSIO/eos/releases/download/v2.0.9/eosio_2.0.9-1-ubuntu-18.04_amd64.deb

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

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

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


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 Telos blockchain (replace YOUR_ACCOUNT_HERE twice with your account) and replace API_SERVER_HERE with a Telos API Nodes from the verified MainNet Nodes on (eg: https://api.telosfoundation.io ):
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":"vote2telosbp","producers":[]},"authorization":[{"actor":"YOUR_ACCOUNT_HERE","permission":"active"}]}]}'

Here we are, if everything went well you just performed a voting operation on the telos blockchain using the cleos command. Other tutorials to understand the use of cleos will follow shortly.

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 TELOS MainNet:
cleos -u API_SERVER_HERE get account YOUR_ACCOUNT_HERE


Next: put TLOS in stake

Last updated February 8, 2021