Getting started with Tezos
Learn how to perform basic operations in Tezos, an open-source platform, which addresses key barriers of adopting the blockchain technology.
Getting started with Tezos | Part 1 | Part 2 | Part 3
This article is the first in a series of blog posts, targeting developers who want to start building on the Tezos blockchain. In this post, we will learn how to interact with Tezos.
What is Tezos
Tezos is an open-source platform for assets and applications. In the Tezos platform, regular blockchain operations are implemented as a purely functional module abstracted into a shell, which is responsible for network operations. The Bitcoin, Ethereum, Cryptonote, and other blockchains can all be represented within Tezos by implementing a proper interface to the network layer. This addresses key barriers during blockchain adoption, such as security of smart contracts, long-term upgradability, and open participation.
Installing Tezos locally
One of the simplest ways to start working with Tezos is through the alphanet.sh script, which will download the required Docker images to run a node.
Note: In addition to the alphanet.sh script, this GitHub repository contains the mainnet.sh and zeronet.sh scripts, which enable a user to interact with the three major networks of Tezos: Mainnet, Alphanet, and Zeronet .
The alphanet.sh
script will run several containers that you can check with docker ps
.
The following commands will only download a node, which is not yet synchronized, for Tezos.
wget https://gitlab.com/tezos/tezos/raw/master/scripts/alphanet.sh
chmod +x alphanet.sh
./alphanet.sh start
There are two methods for synchronizing the node. We can start syncing our node with Alphanet by running ./alphanet.sh client bootstrapped
or we can connect to a public network that already provides a full node.
Note: If you want to synchronize your local node, it will consume a considerable amount of time and disk storage. Resources like Kiln, snapshots, and history mode can reduce the time spent on synchronizing.
Once everything is installed, we can interact with the different components of Tezos by entering the shell with the following command.
$ ./alphanet.sh shell
In the shell mode, we will have access to:
tezos-node
— a Tezos daemontezos-client
— a command-line client and basic wallettezos-admin-client
— an administration tool for the nodetezos-{baker,endorser,accuser}-alpha
— additional daemons in the Tezos networktezos-signer
— a client to remotely sign operations or blocks
You can read more about Tezos components in this documentation.
Creating wallets
We will use the tzbeta.net provider to access full nodes of Mainnet, Alphanet, and Zeronet. To interact with tzbeta
, each tezos-client
command will need two -A rpcalpha.tzbeta.net -P 443 -S
flags to indicate that we want to use an external node to run our operations.
In the first operation, we will create a wallet and assign a “test” alias.
$ tezos-client -A rpcalpha.tzbeta.net -P 443 -S gen keys test
Now, we can check if they were correctly created with the command below.
$ tezos-client -A rpcalpha.tzbeta.net -P 443 -S list known addresses
If there are no errors, it will show the alias and address created.
Faucet
Next, we need to acquire Tezos tokens — tez
. We can get tez
via the Alphanet faucet, where we can download a JSON file, containing a new wallet with some tez
. In order to import the downloaded wallet, we need to exit from the shell and copy it into the container.
First, we need to know the container name where the Tezos node is running. We can find out by running the following command.
$ docker ps
We will see something similar to what is shown in the screenshot below.
Copy the name starting with alphanet_node_1
and then run the following command.
$ docker cp tz1….json alphanet_node_1_6266c955b1ca:/home/tezos
Replace tz1….json
with the name of the file downloaded.
Enter into the shell again.
$ ./alphanet.sh shell
And then run the command below.
$ tezos-client -A rpcalpha.tzbeta.net -P 443 -S activate account test2 with “tz1….json” — force
Note: There are cases where an error occurs, but the wallet is created anyway. Before trying the command again, run tezos-client -A rpcalpha.tzbeta.net -P 443 -S list known test2
to verify that the account was activated.
This will set the wallet with tez
to the “test2” alias.
We can check the balance with the following command.
$ tezos-client -A rpcalpha.tzbeta.net -P 443 -S get balance for test2
> 28547.464315 ꜩ
Transferring funds
Now that we have some tez
, we will be able to make a transfer to another account. In this case, we will transfer tez
from the “test2” account to the “test” account.
To transfer 10,500 tez
, use the command below.
$ tezos-client -A rpcalpha.tzbeta.net -P 443 -S transfer 10500 from test2 to test — burn-cap 0.257
— burn-cap
specifies the maximum fee a user is willing to pay for this operation.
Now, we can check the balance of the “test” account.
$ tezos-client -A rpcalpha.tzbeta.net -P 443 -S get balance for test
> 10500 ꜩ
We can also check the balance of the “test2” account.
$ tezos-client -A rpcalpha.tzbeta.net -P 443 -S get balance for test2
> 18047.204865ꜩ
Finally, we have transferred funds from one account to another using lphanet through the tzbeta
service. The whole procedure can be applied to Mainnet, too.
Conclusion
We installed a local Tezos node and a CLI to interact with it. We also used a fully synchronized external node provided by the tzbeta
service.
After the initial setup, we created two accounts and assigned aliases. Next, we obtained some tez
from the Alphanet faucet and imported them to one of the accounts created.
Finally, we transferred tez
between the two accounts.
These are some of the basic operations available on the Tezos blockchain. In the upcoming blog posts, we will explain how to create a simple smart contract with LIGO and how to deploy it to the Tezos Alphanet. After that, we will see how to call the contracts and query data from it.
Technical resources about Tezos are available in the developer documentation or via the developer portal.
About the authors
Nicolás Dominguez is a Senior Software Engineer at Protofire. With 9+ years in IT, he is now focusing on blockchain-based development with a special interest in applying GraphQL to build production-grade DApps. Nicolás has experience of working as a full-stack JavaScript developer with a profound knowledge of React and Node.js. He is also enthusiastic about machine learning.
Darío Miñones is a Software Engineer at Protofire. He is a highly enthusiastic and passionate self-starter with 10+ years building awesome web and mobile apps, now focusing on DApps and blockchain-based development. Darío loves to create great software, using agile methodologies and being part of an awesome team that helps him to grow both professionally and personally.
Cristian Malfesi is a Project Manager of Blockchain at Protofire. He has extensive experience in building DApps, working with databases, enabling cloud services, etc. Cristian has worked in different positions as a full stack developer, software architect, server administrator, DevOps expert, and product owner. He likes new challenges and is always searching for continuous self-improvement.