Hello! I am Melvin, and you may remember me for writing the guides to using Galleon and AirGap. Welcome back to the second part of the tezos-node blog post! If you have not seen the first part in which I demonstrate how to set up a tezos-node, you can see it here.

In this part, I will show you how you can use the node that you have set up to perform actions such as sending Tez tokens, baking, delegating and much more! I will also show you how you can connect your Ledger Nano S/X to your tezos-node and perform operations with it.

Here are some requirements you need to meet before you can use the tezos-node:

  • a bootstrapped tezos-node (meaning, it is updated on the blockchain. For more information, please refer to part 1 of the guide here).
  • a good internet connection
  • a Ledger Nano (optional, recommended if you are baking on Tezos)
  • basic reading skills

*Pssst, get 50% off your Nano Ledger S here! Sale ends on 17 May!

Now, we can begin!

Connecting your Ledger Nano S

If you ever do mainnet operations such as baking, it is highly recommended that you get a Ledger Nano. With a Ledger Nano, instead of storing your wallets and secret keys on your computer, they are stored separately on a secure device, providing you with the highest degree of protection for your virtual assets. Now, I will run through with you on how to set up your Ledger Nano S on the tezos-client. If you happen to use a Ledger Nano X, the set up is very similar.

1. Get a ledger nano. By design, the ledger nano is protected from any sort of tampering, but it is still important to only purchase the ledger from the official website or from a trusted distributor.

2. Set up your ledger nano. You can refer to this link: Set up as new device

3. Download the Ledger Live application. Then, connect your ledger nano (that has been set up) to your PC and open Ledger Live.

4. Go to settings.

5. Select ‘Experimental features’.

6. Enable ‘Developer Mode’.

7. Next, we have to download 2 applications on Ledger Live:

  • Tezos wallet application

This application is for you to acknowledge the operations (except for baking and endorsement) you execute on the client. You must physically press the tick button on the ledger itself in order to execute these operations successfully.

  • Tezos baking application

This application is to let your baker automatically sign any baking or endorsement operations.

**Note** You cannot sign any operations when your ledger is in the baking application, and likewise, you cannot sign baking and endorsement operations when you are in the wallet application. This is a security feature so that if someone has access to your local node, they cannot transfer out any tokens while you are on the baking application.

8. Set Udev Rules

As Ubuntu is not configured to detect a Ledger Nano, we have to install and run a configuration script. If your ledger is already connected when you run this command, you have to re-connect the ledger for changes to take place.

Run: wget -q -O - https://raw.githubusercontent.com/LedgerHQ/udev-rules/master/add_udev_rules.sh | sudo bash 

Then, connect your ledger and open the ‘Tezos Wallet’ application. Next, we need to make sure that the device is detected by the VM. On the menu above your VM, select ‘Devices’, ‘USB’, and click on the Ledger Nano S/X, ensuring that now it has a tick on its side. Then, 

Run: ./tezos-client list connected ledgers

You should see a list of 4 possible commands you can run.

Copy the one that has <ed25519/0h/0h>, and paste it,

Run: ./tezos-client import secret key <alias> “ledger://<some-random-animal-name>/ed25519/0h/0h”

With that, a new hash is generated. Verify that the hash is the same as the one displayed on your tezos-client as well as your ledger, and confirm it using your ledger. 

Next, run: ./tezos-client list known addresses

You should see the ledger that you have just connected, with ‘ledger sk known’ at the side. Note that this address is not yet revealed on the blockchain as it has not been involved in any transactions, thus you cannot find it on block explorers. To reveal it, some tokens must be sent to it.

Lastly, when you perform operations involving the ledger (delegation etc), you may need to verify the operation on the ledger physically.

Commands for managing your wallets

  • Create a new wallet:
Run: ./tezos-client gen keys <Alias>

  • Create a faucet account for testnet. This faucet account is generated with Tez tokens and is only available on testnet for you to experiment with Tezos (but you must download the faucet file from faucet.tzalpha.net first, using Firefox inside your VM):
Run: ./tezos-client activate account <alias> with ~/Downloads/faucetfilename.json

  • Transfer Tez tokens from an account to another:
Run: ./tezos-client transfer <amount> from <sender alias> to <receiver alias>

  • See the addresses that your client knows:
Run: ./tezos-client list known addresses

  • Register an existing address onto your client as an alias so that you can send Tez tokens to it more conveniently:
Run: ./tezos-client add address <alias> <hash>

  • Import the secret key of an existing address to interact with it:
Run: ./tezos-client import secret key <new alias> encrypted:<secret key>

If it does not work, try Run: ./tezos-client import secret key <new alias> unencrypted:<secret key>

The primary difference between the two is whether or not the secret key you are trying to import is encrypted. 

  • To see the hash and public key of an address:
Run: ./tezos-client show address <alias> 

If you want to see the secret key as well, add --show-secret at the end.
  • To forget an address:
Run: ./tezos-client forget address <alias>
  • Check the balance of an address:
Run: ./tezos-client get balance for <alias>

**Note** After creating a wallet, the address must be revealed on the blockchain before any other operations can be performed. This can be done by sending some Tezos tokens to it, as well as using the –burn-cap option, which is an anti-spam measure implemented by Tezos.

Commands for delegation operations

  • Delegate to yourself so that you can run a baker:
Run: ./tezos-client register key <alias> as delegate

  • Delegate to another address (baker):
Run: ./tezos-client set delegate for <delegator alias> to <baker alias>

Commands for baking operations

  • To run the baker daemon:
Run: nohup ./tezos-baker-006-PsCARTHA run with local node ~/.tezos-node/ <alias of account with at least 1 roll> > baker.out &
<baker.out> is a file that stores all the output that  <./tezos-baker-006-PsCARTHA> has generated

**It is recommended that you use a ledger for baking on the mainnet.

  • Then, make sure that the process is running in the background:

Run: ps aux | grep ./tezos

  • To check the log to see whether the baker daemon has started:
Run: tail -f baker.out

  • To run the endorser daemon:
Run: nohup ./tezos-endorser-006-PsCARTHA run <alias of account used to run the baker daemon> > endorser.out & 
<endorser.out> is a file that stores all the output that <./tezos-endorser-006-PsCARTHA> have generated 

  • Similarly, to make sure that the process is running in the background:
Run: ps aux | grep ./tezos and Run: tail -f endorser.out

**On mainnet, the commands for baking and endorsing are the same as on the Carthage testnet because both are running on the Carthage protocol.

For baking and endorsing using a Ledger account, enter the Tezos baking application, and ensure your Ledger is detected by the VM in the devices menu.

Then, run: ./tezos-client setup ledger to bake for <alias of ledger wallet>

Physically confirm the key on your ledger, and then you can run the baker and endorser daemons. Make sure your ledger is in the baking application while running the baker daemon. 

Upon the completion of 7 cycles of the blockchain (approximately 10.5 days) after you run the setup ledger command, your baker will be able to start receiving baking rights. You can either keep the node syncing for the duration of the 7 cycles, or sync up your node right before the 7 cycles are over. 

For baking and endorsing using an encrypted wallet, you will have to run the processes using a command known as <screen>. <screen> is a command that allows you to run a terminal completely in the background. This allows us to run different processes in separate terminals – all in one machine. 

We need to use <screen> to run a baker and endorser with an encrypted wallet as running the baker daemon using <nohup> will result in an error. This is because we need to input our password if we try to bake using an encrypted account, which we cannot do if we run the command using <nohup>. Hence, a good workaround would be to run it using <screen> so that we can run the processes in the background without having to use <nohup>.

After you have:

  • Generated an encrypted account,
  • Registered it as a delegate,
  • Secured slightly more than 1 roll (~8,100 XTZ) in the address (having more than 8000 XTZ is safer because when you delegate to yourself, there is a small fee for the operation, and to bake/endorse you must have a minimum balance of 8000XTZ),

You are ready to bake using your encrypted address! Before we begin, I would suggest that you stop the node syncing process (if it had already been started) and run it on a screen that we are about to make. This is so that our processes are all nicely separated on different screens, making it easier for us to know where each of the output is.

First, we need to install screen.

Run: sudo apt install screen

You will be prompted ‘Y/n’, enter ‘Y’ to confirm the installation.

Next, run: screen -S <alias of the screen>

Here, we are creating a screen for our node-syncing process. For ease of recognition, I suggest naming the alias for this screen ‘node’. Now, you should see what seemingly looks to be a brand new terminal: 

Now, we can run the node syncing process. Do note that all the processes we run in screen do not have to be nohup.

Run: ./tezos-node run --rpc-addr --net-addr<port>

To properly exit a screen (detach from a screen), press Ctrl+A, followed by ‘D’ on your keyboard.

After we have synced up our node, we can run the baker and endorser daemon. We need to create a screen each for our baker and endorser daemons, respectively.

For the baker daemon:

Run: ./tezos-baker-006-PsCARTHA run with local node ~/.tezos-node/ <alias of baker>

For the endorser daemon:

Run: ./tezos-endorser-006-PsCARTHA run <alias of endorser>

To see a list of screens that are running:

Run: screen -ls

To attach to a screen (view the process running in a screen):

Run: screen -r <screen id>

The screen ID is seen on the left-hand side of a screen when you run <screen -ls>.

To kill a screen:

Run: sudo kill <screen id>

That’s all on how to run a baker and an endorser!

Commands for smart contracts 

1. To originate a smart contract:

Run: ./tezos-client originate contract <name of contract> transferring <amount of tez> from <alias of source address> running <file for the code of the contract>

2. To transfer tokens from a contract/call the contract:

Run: ./tezos-client transfer <amount> from <alias of source contract> to <alias of destination address>

3. To call a contract (not involving the transfer of tokens):

Run: ./tezos-client call from <alias of source contract> to <alias of destination address>

4. To add a contract address to the wallet:

Run: ./tezos-client remember contract <alias of contract> <contract public hash>

Miscellaneous commands

  • Many commands require su privileges to run. If you encounter an error saying that ‘you do not have permission to perform the function’, try adding sudo before the command and running it again
  • Remove a file or folder, run: rm -r <file/folder name>
  • Create a directory, run: sudo mkdir <filename>
  • To change directory, run: cd <directory>, if you are going back to the previous directory, use cd ..
  • Copy a file, run: sudo cp <filename> <destination directory>
  • To view processes running on nohup, run: tail -f nohup.out and then press Ctrl+C to exit the log file
  • To view all processes that are running (for the tezos-client), run: ps aux | grep ./tez
  • To kill a process, run: kill -15 <process number>
  • To view the manual for yourself which has more commands and their purposes, run: ./tezos-client man

That’s all for my guide to using the tezos-client! Hopefully, you now have a better grasp on understanding how the tezos-client works as well as how to use it! 

If you have any enquiries or require any assistance, feel free to contact our friendly developers at [email protected]. Please help to share this blog post with your fellow developers!

Get Involved!
Join our mailing list for updates on our events, meet-ups, workshops & more!
By clicking the button:
1) It confirms you are a genius.
2) We promise that your privacy is respected and will not be shared.
3) You will not be spammed.
Get Involved!
Join our mailing list for updates on our events, meet-ups, workshops & more!
By clicking the button:
1) It confirms you are a genius.
2) We promise that your privacy is respected and will not be shared.
3) You will not be spammed.

Leave a Reply