In this chapter, the reader will learn how to install the official "tezos-client" and "tezos-admin-client" applications and run them using the Command Line Interface. These commands call on the remote procedures of a Tezos node (local or remote). There are many commands, but we'll see some examples.
The tezos-client and Tezos RPC need to connect to a Tezos node. You can connect to your own tezos node, or you can use a community node. In both cases, you can set it for the mainnet or the testnet.
You can find a list of community nodes here.
If you use a testnet, you can download a faucet file with free test's Tez here. Below is an example of such a JSON file:
RPC is a client-server protocol where the requesting program is the client and the program providing the service is the server.
Tezos nodes provide a JSON/RPC interface to interact with the Tezos network. Although it uses RPC and is JSON-based, it does not follow the JSON-RPC protocol.
This call returns all the information about a block. But the associated metadata may not be present, it depends on the history mode and block's distance from the head.
Here is an example, of how to get the block number 1400114 from the mainnet using giganode.io:
To test this call, simply click the address above (or copy-paste it, to open it in your web browser). You'll discover a pretty long JSON object. Depending on the used browser, the visualization may be better (e.g. Firefox will format the appearance to make it easier to read).
This call accesses the storage of a contract.
Example to get the storage of contract KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9 from block 1400114 on the mainnet using giganode.io:
You can test this call exactly the same way as the "GET block" call.
Tezos-client is the official client to interact with a Tezos node via RPC. Let's take a look at the installation and some examples.
Below we'll connect to a community node (https://edonet-tezos.giganode.io/) on the Edo testnet. We'll use the "
--endpoint" parameter to update the configuration of the Tezos Client on a Ubuntu system:
The result should look like the lines below:
On Ubuntu, the config file should be written in "/.tezos-client/config" under your "home" folder. For example after the last command, the all new "config" file look like this (with Nano):
Activate your account by replacing "accountName" and "faucet" below with an account name and the path to your downloaded faucet file (this can be different from "~/Downloads/"):
Example on Ubuntu with a downloaded JSON faucet file:
The resulting return:
On Ubuntu, the result would look like the following:
The full commands' list on Tezos client is available here.
To get the balance of the account use "accountName":
Example with our previously registered user "testnetEdo-User_1":
The previous response is also a way of checking if the account is activated on the testnet (first transfer).
Is a call to return the UTC of the latest downloaded block. Keep in mind, timezones may differ from your local time:
This call only lists registered implicit accounts in your Tezos client.
This call lists all registered accounts, implicit and originated in your Tezos client.
Everything is correct: We don't have any originated account and only one implicit account!
The command below transfers 42 ꜩ from the account user1 to user2 (you can use a Tezos addresses directly):
Notice that you can specify the maximum fee for this operation appending, "
--fee-cap" (defaults to 1.0). The network would determine the actual fee, lower than this cap:
You can also add "
--dry-run" or "
-D" if you want to test and display the transaction without finalizing it.
For our example, let's first activate another account with another faucet file:
Let's verify the balance (and activation):
Response (without the warning message):
Let's finally try a transfer of 10,000 ꜩ from testnetEdo-User_1 to testnetEdo-User_2 with a 2.5 ꜩ fee cap:
Response (without the warning message) should be:
Let's check both balances (testnet warning messages removed):
Everything is fine.
You can observe your actions on explorers like tzstats:
OpenTezos has a dedicated module on how to use an explorer.
The admin client allows you to interact with the peer-to-peer layer:
- to check the status of the connections
- to force connections to known peers
- to ban/un-ban peers
To use the Tezos Admin Client commands, we need a node we can administrate. In the above examples, we learned how to use remote community nodes. Let's now install a local node, we can pretend to be an administrator. This section will also be useful to follow along the "Deploy a Node" module.
For the demonstration, the installations will take place on a fresh Ubuntu 20.04 (x86_64/amd64 system minimal installation).
To avoid any shortage, install
The following command test your installation:
At this point, please save your work and reboot the system.
Thanks to Docker, the following command integrates Flextesa and will start the Tezos sandbox in the background:
Notice the port number set on 20000. After downloading images, the node should start in the background.
Let's bootstrap our new node and change our connection for it:
The sandbox also set two accounts. You can access their information with the following command:
You should get something like the following result:
To use them, we need to import them:
To check the accounts' activation, let's check their balances:
They should both have 2,000,000 ꜩ.
Let's now install the
The complete listing of commands on Tezos admin-client is available here.
We can finally try a few commands on our node.
In our example:
In our example, if we want the blocks:
We get something like:
Now, if we'd like to have more details on this particular block:
As a result, we obtain a long JSON descriptive object:
Though, in our case with the single local node, the result is not very interesting:
In this chapter, we saw how to install the CLI. We also introduced you to simple remote procedure calls for a Tezos node. Along the way, we understood how to connect to a remote community node or to a local node using a sandbox.
In the next chapter, we will learn in detail how Tezos allows on-chain decentralized governance without reliyng on the problematic hard forks.