How to Run a Node on the Tezos Blockchain (Part 1)16.02.20 | Mathis Selvi [SSB]
Note: This is *Part 1* of “How to Run a Node on the Tezos Blockchain” Series
To run a node building from sources, please read part 2
To run a node using a snapshot, please read part 3
Ever wondered how to run a Tezos node? Or why should you run one yourself? If yes, you’re on the right series of articles. In this first part, we’re going to run a node using Docker.
How to Run a Node on Tezos Using Docker
Why would a business run its own node?
A business should want to run its own node for a few reasons, including more trust, safety, privacy, as well as contributing to Tezos (which is super cool, right?).
– Having your own node means you can handle the transactions and make sure they will be broadcasted to the network.
– When running your own node, you greatly contribute to the Tezos network by increasing safety and decentralization (because of you adding your own node to the network).
– If you’re “baking”, you will receive full rewards for all your operations and you will be to vote yourself, and not let another “Baker” do so for you.
– Another very good reason is that by running your own node, you will be automatically up-to-date with latest upgrades, news, or technical improvements because you will have to keep an eye on them in order to successfully run your node.
First thing first, here is the environment I will be using for this tutorial:
In this first part, I will cover how to run a Tezos node using Docker.
Let’s dive into it!
To run an up-to-date node, using Docker is probably the easiest way. You can setup your own node under minutes. Let’s see how.
First, make sure you have Docker and docker-compose installed on your computer. You can check by opening your terminal and entering the following commands:
If you don’t have Docker installed, please install it here. Once it’s done, come back and check with the commands above.
If you see this, it means that Docker is working well and we are ready to go.
Let’s continue by creating a tezos-docker folder for the tutorial. Make sure to go inside it once it’s created. To do so, you can run:
$ mkdir tezos-docker && cd tezos-docker
Therefore, we can get the latest Mainnet image by doing this:
$ wget -O mainnet.sh https://gitlab.com/tezos/tezos/raw/master/scripts/alphanet.sh
$ chmod +x mainnet.sh
If you don’t have wget, install it by doing
$ brew install wget.
(Note: you see
alphanet.sh at the end of the url, which is normal. It is the script responsible for downloading the right image for each network (Mainnet, Babylonnet or Zeronet) and then running a node)
Here is what you should see if everything went well:
We’re almost there!
mainnet.sh script will download the mainnet docker image and launch 3 different services: the node, the baker and the endorser. Let’s do so:
$ ./mainnet.sh start
Here is our result:
We see a warning, let’s synchronize as advised:
$ ./mainnet.sh update_script
You should see “The script has been updated”. However, you may have to give permissions to
mainnet.sh again, by doing so:
$ chmod +x mainnet.sh
After starting again the Mainnet script, here is what we get:
Your node should be running. Here is how to check:
$ ./mainnet.sh node status
Boom! Our node is running 😉
Now, here is the thing though… Since it’s the first time you’re running a node, it will take some time to synchronize the chain. It basically starts in 2018, when Tezos was launched. If you don’t need to synchronize the whole chain, please see part 3, here.
You can also use the following command to see logs:
$ ./mainnet.sh node log
If you want to stop running your node, you can run:
$ ./mainnet.sh node stop
Alternatively, if you want to stop running all the services, run this:
$ ./mainnet.sh stop
Feel free to use the following command to check what you can do with the script:
$ ./mainnet.sh --help
This will display some help and information about the script itself.