Decentralized App development on Tezos for beginners part 1

Set up your own Tezos node and learn the basics concepts

catsigma
4 min readFeb 23, 2018

Updated @ 2018.02.23 (outdated, waiting for the formal release of zeronet)

The series will cover all the essential ideas you need to know about the Dapps development based on Tezos Blockchain system.

A self-amending cryptographic ledger

Series parts

  1. Set up your own Tezos node and learn the basics concepts.
  2. Meet the Tezos smart contract language — Michelson.
  3. Use Liquidity to easily write Michelson contracts.
  4. Let’s deploy our first Michelson contract on Tezos.
  5. Build a website to interact with our Tezos contract.

NOTICE: The current version of Tezos contains two chains. One is alphanet, the other is zeronet. As I know, the zeronet will be the release chain. But since the zeronet is not stable yet, the chain we’ll talk here is based on alphanet currently. When the zeronet becomes stable, this series will be updated to zeronet.

-----------------------------------------------------------------------------

Set up Tezos(alphanet) node

1) Install Docker on your operating system.

2) Download the alphanet.sh script.

wget https://raw.githubusercontent.com/tezos/tezos/alphanet/scripts/alphanet.sh
chmod +x alphanet.sh

3) Start the node.

./alphanet.sh start

It will display something like this:

alphanet: Pulling from tezos/tezos
Digest: sha256:d8c5bb3894a453fb87dede7783f6438aab48201ef7b2ba6171b18c596991bb11
Status: Image is up to date for tezos/tezos:alphanet
The script is up to date.
Error response from daemon: No such container: tezos-alphanet
Launching the docker container...
Restoring the peer identity from '/root/.tezos-alphanet/identity.json'...
Restoring the secret keys from '/root/.tezos-alphanet/secret keys'...
Peer_id: idqxHU5wU9N1MzWpwsXVDM4eJ8Vksc. Proof of work is higher than 24.00.
Waiting for the node to initialize.... done.
Waiting for the node to synchronize with the network...
Current head: BMT9VszUSgSYih (2017-10-30T05:48:00Z)
...
... (Wait for a long time here)
...
Current head: BMHA7KDYwTvY4N (2018-02-16T12:10:50Z)
Current head: BLgxGLh4Cntwcb (2018-02-16T12:12:20Z)
Bootstrapped.
The node is now running.
The baker is now running.
The endorser is now running.

4) Now your node is ready.

Some basics concepts to know

1) How do smart contracts work?

Even if you have never developed a Blockchain project before, you may somewhat know something about how it works. In developers higher-level perspective, the Blockchain system is a bunch of decentralized back-end servers. In short, you can actually consider it as one back-end server with amounts of entry points. Initially, the server is loaded with no functionality except for the mechanism of calling a function. Here the function can be represented as a smart contract.

So in a word, smart contract works as a function in the Blockchian which works as a back-end server. Writing a smart contract is like writing a function in normal back-end server development.

2) What is the alphanet?

Alphanet is the test net of Tezos. Everyone can test the whole functionalities of it with unlimited testing XTZ coin.

3) What is the relation between Manager, Account and Contract in Tezos?

Manager is an operator. It can create Accounts and Contracts. It has an implicit default Account. So it can store XTZ. Its ID looks like this tz1TwYbKYYJxw7AyubY4A9BUm2BMCPq7moaC.

Account is a contract without functionality. It can only store XTZ and call other contracts(accounts). It has an input-type unit and return-type unit. The manager’s default Account looks like this tz1TwYbKYYJxw7AyubY4A9BUm2BMCPq7moaC. But the created Account by Manager looks like this TZ1rM3KL4aERKYgZiPf1tvZZqKggvfh9Cs9Q.

Contract is a smart contract with functionality. It can store XTZ and call other contracts(accounts) in code or by the client command. You can define custom input-type and return-type for it. Its ID looks like this TZ1gKLVeKNiZn18jEPKuKGH6fMdtCB2ZDs26.

4) What does the action call mean?

In Bitcoin, there is only one action which is commonly called as a transfer. In Tezos, a transfer is the same as a call. Transferring from one Account to another Account means the first Account call the second Account(which is a contract) with some XTZ(as an implicit parameter, more details will be told in series part 2). It’s something like Account2(Account1, number_of_XTZ, UNIT).

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Well, now you have the Tezos node ready. Before jumping into the Michelson ocean, you need to memorize some useful commands of alphanet.

1) I want to know my Manager ID

$ ./alphanet.sh client list known contracts
...
...
my_account: TZ1rM3KL4aERKYgZiPf1tvZZqKggvfh9Cs9Q
my_identity: tz1drQAWiLRFk2ffvQJsH8PgZqt7br9du1qJ <- this one

2) I want to know the balance of my Manager’s default Account

$ ./alphanet.sh client get balance for my_identity1,357,235.26 tz

3) I want to transfer XTZ (also means my_identity call my_account with 1.23 XTZ)

$ ./alphanet.sh client transfer 1.23 from my_identity to my_accountGot the source's manager keys (my_identity).
Operation successfully injected in the node.
Operation hash is 'oor5oR7PmaHqzPESqAJRZ3C6eWQdCAxgdSUZL8FTRdb3TLWxakM'.

— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —

Here comes the end of this part. Hope you enjoy it.

Donation BTC: 1L7oCqy7GHx7EiQc9SPFputCWftfaoT3kB

View the next part… Meet the Tezos smart contract language — Michelson.

--

--