# Spin up a Tezos baking node (DEPRECATED)

## PLEASE REFER TO: <https://opentezos.com/baking/cli-baker>

## Prerequisites

Baking blocks on the Tezos blockchain requires:

* 6,000 tez (can be achieved through delegations)&#x20;

and a dedicated machine online 24/7 with at least:

* 8 GB RAM
* 2 CPU cores
* 256 GB SSD drive

## Set up using Docker images

In this part, we will see how to install Tezos with Docker.

### Docker

<details>

<summary>Step 1 : Installation</summary>

If you don't have Docker on your machine, you can install it with the following command:&#x20;

```bash
sudo apt install docker.io
```

and follow instructions on: <https://docs.docker.com/engine/install/linux-postinstall/>

</details>

<details>

<summary>Step 2: Let's config and run!</summary>

Run the node in detached mode (`-d`), as instance on the testnet "**jakartanet**" network with the history-mode "**full**" using the following command:&#x20;

```bash
docker run --privileged -v /dev/bus/usb:/dev/bus/usb -v node-data-volume:/var/run/tezos/node -d -it -p 8732:8732 --name=tezos-public-node-full tezos/tezos:latest tezos-node --network=jakartanet --history-mode=full
```

(This command will automatically download the `tezos/tezos:latest` image)

(`--privileged` mode is only used to allow a connection with an Hardware secure module, e.g. Ledger)

(`--name` option to specify the name of the container)

(`-v /dev/bus/usb:/dev/bus/usb` allows to mount USB volumes to the specified container)

(`-v node-data-volume:/var/run/tezos/node` mount `node-data-volume` to the specified container. It is where blockchain data will be stored)

**`--network=`**<mark style="color:blue;">**`NETWORK`**</mark>  selects which network to run. Possible values are: <mark style="color:blue;">**sandbox**</mark>, <mark style="color:blue;">**mainnet**</mark>, <mark style="color:blue;">**\[testnet]**</mark> (e.g., jakartanet, kathmandunet. See current testnets [here](https://teztnets.xyz/)). **Default is mainnet.**

**`--history-mode=`**<mark style="color:blue;">**`MODE`**</mark>  lets you set the mode for the node's blockchain history storage. Possible values are <mark style="color:blue;">**archive**</mark>, <mark style="color:blue;">**full**</mark> (default), <mark style="color:blue;">**full:N**</mark>, <mark style="color:blue;">**rolling**</mark>, <mark style="color:blue;">**rolling:N**</mark>.&#x20;

* Archive mode retains all data since the genesis block.&#x20;
* Full mode only maintains block headers and operations allowing replaying of the chain since the genesis, if wanted. (full mode is recommended to bake. More information [here](https://tezos.gitlab.io/user/history_modes.html))
* Rolling mode retains only the most recent data and deletes the rest.&#x20;

For both Full and Rolling modes, it is possible to adjust the number of cycles to preserve by using the <mark style="color:blue;">**:N**</mark> annotation. The default number of preserved cycles is 5. The value experimental-rolling is deprecated but is equivalent to rolling which should be used instead.

(More information about node configuration [here](https://tezos.gitlab.io/introduction/howtouse.html#node-configuration))

After 1-2 minutes, your node identity will be generated and you will be able to check if the node is bootstrapped: &#x20;

```bash
docker exec -it tezos-public-node-full tezos-client --endpoint http://127.0.0.1:8732 bootstrapped
```

(Use **Ctrl+C** to stop logs displaying)

</details>

<details>

<summary>Step 3: Import your keys</summary>

*<mark style="color:orange;">**Option 1: Import keys from a Ledger**</mark>*&#x20;

**Prerequisites: The Ledger Nano should be configured with the Tezos wallet and Tezos baking apps.**

Access the "Tezos wallet" app on your ledger and list the connected Ledgers with the following command:

```bash
docker exec -it tezos-public-node-full sudo tezos-client --endpoint http://127.0.0.1:8732 list connected ledgers
```

Import a key from the Ledger:

```bash
docker exec tezos-public-node-full sudo tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> <ledger://path/to/the/secret/key/on/your/device>
```

You have to replace`<key_alias>` by the alias of your choice, and `<ledger://path/to/the/secret/key/on/your/device>` by the path to your secret key on your ledger (four options are available to generate either tz1, tz2 or tz3 addresses).&#x20;

(You will need to validate the public key hash displayed on the ledger to validate the key importation).

*<mark style="color:orange;">**Option 2: Import a secret key with the tezos-client**</mark>*

**⚠️⚠️⚠️ This option isn't recommended. Be careful when using your private keys unencrypted ⚠️⚠️⚠️**&#x20;

You have to replace`<key_alias>` by the alias of your choice, and provide the clear private key to the tezos-client, after the keyword "*unencrypted:"* :

```bash
docker exec tezos-public-node-full tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> unencrypted:<your_private_key>
```

</details>

<details>

<summary>Step 4: Let's register as delegate</summary>

<mark style="color:orange;">**If you have a Ledger: Setup the Ledger to bake for your address**</mark>

Access the "Tezos Baking" app on your ledger and then execute the following command:

(replace `<key_alias>` by the alias chosen in Step 3)

```bash
docker exec -it tezos-public-node-full sudo tezos-client -E http://127.0.0.1:8732 setup ledger to bake for <key_alias>
```

Validate the request on your ledger.

<mark style="color:orange;">**In both cases: Register your key as a delegate on the network**</mark>

(Replace `<key-alias>` by the alias chosen in Step 3)

```bash
docker exec tezos-public-node-full tezos-client --endpoint http://127.0.0.1:8732 register key <key_alias> as delegate
```

</details>

<details>

<summary>Step 5: Let's bake!</summary>

⚠ Since the ***Jakarta*** amendment, the `--liquidity-baking-toggle-vote <vote>` command line toggle is mandatory. `<vote>` should be replaced by `on`, `off` or `pass`. Read more about liquidity baking in the [technical documentation.](https://tezos.gitlab.io/alpha/liquidity_baking.html)

You can launch the baker with:

```bash
docker exec -it tezos-public-node-full sh 
tezos-baker-013-PtJakart --endpoint http://127.0.0.1:8732 run with local node /usr/local/bin/ --liquidity-baking-toggle-vote <vote>
```

(In the future, you may change **`tezos-baker-013-PtJakart`** by the next protocol binary)

Check baking has started by watching the logs.

</details>

#### 🎉 Congratulations on setting up a baker node! 🎉

<details>

<summary>Some useful commands</summary>

To see the manual  of commands you can use:

```bash
docker run -it tezos/tezos:latest man
```

To see the various commands and options of the tezos node, use the following command:&#x20;

```bash
docker run -it tezos/tezos:latest tezos-node --help
```

To use the client:

```bash
docker exec -it tezos-public-node-full tezos-client --help
```

</details>

### Docker-compose

One way to run those Docker images is with Docker Compose!

<details>

<summary>Step 1: Let's launch the node and the baker !</summary>

The code below launches a full node, a baker and accuser for the **Jakarta** protocol. You can adapt it to run a baker and accuser for another protocol by replacing the `PROTOCOL` environment variable, in our case `013-PtJakart,` with the desired protocol.

(full mode is recommended to bake. More information [here](https://tezos.gitlab.io/user/history_modes.html))

```yaml
version: "3.4"
volumes:
  node_data_full:
    name: mainnet-node
    external: false  
  client_data:
    name: mainnet-client
    external: false
services:
####################################################################################################################################
# You have to uncomment this section if you want to synchronize your node using a snapshot, else you can ignore or delete it.
# Replace /home/danub0/snapshot.rolling:/snapshot by the absolute path to the downloaded snapshot.
###################################################################################################################################  
#  import:
#    image: tezos/tezos:latest
#    container_name: tezos-snapshot-import
#    command: tezos-snapshot-import
#    volumes:
#      - node_data_full:/var/run/tezos/node
#      - client_data:/var/run/tezos/client
#      - "/absolute/path/to/your_snapshot.full:/snapshot"
################################################################################################
# If you want to run a node with history-mode=full, keep that "node_full" part, else delete it.
# You can change the version of the image of tezos in : image: tezos/tezos:v13.0
# You can change the --network=NETWORK option.
################################################################################################
  node_full:
    container_name: tezos-public-node-full
    image: tezos/tezos:latest
    command: tezos-node --net-addr :9732 --rpc-addr 127.0.0.1:8732 --rpc-addr 0.0.0.0:8732 --allow-all-rpc 0.0.0.0:8732 --history-mode=full --network=jakartanet
    ports:
    - '9732:9732'
    - '8732:8732'
    expose:
    - "8732"
    - "9732" 
    privileged: true
    volumes:
     - node_data_full:/var/run/tezos/node
     - client_data:/var/run/tezos/client
     - /dev/bus/usb:/dev/bus/usb
    restart: on-failure
    network_mode: "host"
################################################################################################
# If you want to run a baker, keep that "baker" part, else delete it.
# You can change the version of the image of tezos in: image: tezos/tezos:v13.0
# You can change the PROTOCOL
# You can change the vote mode between on/off/pass. pass is the mode by default
################################################################################################
  baker:
    container_name: tezos-baker
    image: tezos/tezos:latest
    environment:
     - HOME=/tmp
     - NODE_HOST=127.0.0.1
     - NODE_RPC_PORT=8732
     - PROTOCOL=013-PtJakart
    command: tezos-baker --liquidity-baking-toggle-vote pass
    volumes:
     - node_data_full:/var/run/tezos/node:ro
     - client_data:/var/run/tezos/client
     - /dev/bus/usb:/dev/bus/usb
    restart: on-failure
    network_mode: "host"
################################################################################################
# If you want to run an accuser, keep that "accuser" part, else delete it.
# You can change the version of the image of tezos in: image: tezos/tezos:v13.0
# You can change the PROTOCOL
################################################################################################
  accuser:
    container_name: tezos-accuser
    image: tezos/tezos:latest
    environment:
     - HOME=/tmp
     - NODE_HOST=127.0.0.1
     - NODE_RPC_PORT=8732
     - PROTOCOL=013-PtJakart
    command: tezos-accuser
    volumes:
     - node_data_full:/var/run/tezos/node:ro
     - client_data:/var/run/tezos/client
    restart: on-failure
    network_mode: "host"
```

Copy-paste the code above into a docker-compose.yml file, and start the node with:

```bash
docker-compose -f docker-compose.yml up -d
```

To check if the node is bootstrapped:&#x20;

```bash
docker exec -it tezos-public-node-full tezos-client --endpoint http://127.0.0.1:8732 bootstrapped
```

</details>

<details>

<summary>Step 2: Import your keys</summary>

*<mark style="color:orange;">**Option 1: Import keys from a Ledger**</mark>*&#x20;

**Prerequisites: The Ledger Nano should be configured with the Tezos wallet and Tezos baking apps.**

Open the "Tezos wallet" app on your ledger and list the connected Ledgers with the following command:

```bash
docker exec -it tezos-baker sudo tezos-client --endpoint http://127.0.0.1:8732 list connected ledgers
```

Import a key from the Ledger:

```bash
docker exec tezos-baker sudo tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> <ledger://path/to/the/secret/key/on/your/device>
```

You have to replace`<key_alias>` by the alias of your choice, and `<ledger://path/to/the/secret/key/on/your/device>` by the path to your secret key on your ledger (four options are available to generate either tz1, tz2 or tz3 addresses).&#x20;

Validate the public key hash displayed on the ledger to validate the key import.

*<mark style="color:orange;">**Option 2: Import a secret key with the tezos-client**</mark>*

**⚠️⚠️⚠️ This option isn't recommended. Be careful when using your private keys unencrypted ⚠️⚠️⚠️**&#x20;

You have to replace`<key_alias>` by the alias of your choice, and provide the clear private key to the tezos-client, after the keyword "*unencrypted:"* :

```bash
docker exec tezos-baker tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> unencrypted:<your_private_key>
```

</details>

<details>

<summary>Step 3: Let's register as delegate</summary>

<mark style="color:orange;">**If you have a Ledger: Setup the Ledger to bake for your address**</mark>

Open the "Tezos Baking" app on your ledger. Then execute the following command:

(Replace `<key_alias>` by the alias chosen earlier in Step 3)

```bash
docker exec -it tezos-baker sudo tezos-client -E http://127.0.0.1:8732 setup ledger to bake for <key_alias>
```

Validate the request on your ledger.

<mark style="color:orange;">**In both cases: Register your key as a delegate on the network**</mark>

(Replace `<key-alias>` by the alias chosen earlier in Step 3)

```bash
docker exec tezos-baker tezos-client --endpoint http://127.0.0.1:8732 register key <key_alias> as delegate
```

</details>

**🎉 Congratulations on setting up your baking node! 🎉**

<details>

<summary>Bonus: Quick synchronization from a snapshot</summary>

If you want your node to be bootstrapped quickly, you can synchronize it with the blockchain using a snapshot.

&#x20;<mark style="background-color:orange;">1:</mark> Download a .full snapshot from <https://snapshots-tezos.giganode.io/> in your current repository by replacing with `<snapshot_url>` in following command:

```
wget <snapshot_url>
```

&#x20;<mark style="background-color:orange;">2:</mark> Launch the node and baker daemons:

```bash
docker-compose stop import
docker-compose up -d node_full
docker-compose up -d baker
sudo docker exec -it tezos-public-node-full sh
sudo rm /var/run/tezos/data/lock
exit
```

<mark style="background-color:orange;">3:</mark> Stop the node, baker and accuser daemons:

```bash
docker-compose stop node_full baker accuser
```

<mark style="background-color:orange;">4:</mark> Execute these commands to clean up data and avoid duplicates:

```bash
sudo su
rm -rf /var/lib/docker/volumes/mainnet-node/_data/data/context
rm -rf /var/lib/docker/volumes/mainnet-node/_data/data/store
rm -rf /var/lib/docker/volumes/mainnet-node/_data/data/lock
```

(do **Ctrl+d** to quit `su` mode)

<mark style="background-color:orange;">5:</mark> In the .yml file presented in Step 1, replace `"/absolute/path/to/your_snapshot.full:/snapshot"` by the absolute path to the downloaded snapshot. You can use `pwd` command to know the absolute path of your current repository. (**Read the comment in the .yml file in Step 1**)

<mark style="background-color:orange;">6:</mark> Upload the snapshot into the `mainnet-node` volume:

```bash
docker-compose up import
```

You will have to wait \~1-2 hours to import a full snapshot.&#x20;

<mark style="background-color:orange;">7:</mark> Start synchro from snapshot:

```bash
docker-compose stop import
docker-compose up -d node_full baker accuser
```

</details>

## Set up using PPA with Tezos packages from [Serokell](https://github.com/serokell/tezos-packaging)&#x20;

If you’re using Ubuntu, you can install packages with Tezos binaries from a Launchpad PPA.

<details>

<summary>Step 1: Installation</summary>

In order to add the stable release PPA repository to your machine, do:

```bash
REPO="ppa:serokell/tezos"
```

Then choose the desired protocol for your baker/accuser (you probably want to replace "`013-PtJakart`" by the latest protocol version):

```bash
PROTOCOL="013-ptjakart"
```

Then, to install the binaries, run the following commands:

```bash
sudo add-apt-repository -y $REPO && sudo apt-get update
sudo apt-get install -y tezos-client
sudo apt-get install -y tezos-node
sudo apt-get install -y tezos-baker-$PROTOCOL
sudo apt-get install -y tezos-accuser-$PROTOCOL
```

</details>

<details>

<summary>Step 2: Let's config and run !</summary>

It is possible to define the directory where the data will be stored with **`--data-dir`** (by default, it is in .tezos-node).&#x20;

**`--network=`**<mark style="color:blue;">**`NETWORK`**</mark>  Select which network to run. Possible values are: <mark style="color:blue;">**sandbox**</mark>, <mark style="color:blue;">**mainnet**</mark>, <mark style="color:blue;">**\[testnet]**</mark> (e.g., jakartanet, kathmandunet. See current testnets [here](https://teztnets.xyz/)). **Default is mainnet.**

**`--history-mode=`**<mark style="color:blue;">**`MODE`**</mark>  Set the mode for the chain's data history storage. Possible values are <mark style="color:blue;">**archive**</mark>, <mark style="color:blue;">**full**</mark> (default), <mark style="color:blue;">**full:N**</mark>, <mark style="color:blue;">**rolling**</mark>, <mark style="color:blue;">**rolling:N**</mark>.&#x20;

* Archive mode retains all data since the genesis block.&#x20;
* Full mode only maintains block headers and operations allowing replaying the chain since the genesis if wanted. (full mode is recommended to bake. More information [here](https://tezos.gitlab.io/user/history_modes.html))
* Rolling mode retains only the most recent data and deletes the rest.&#x20;

For both Full and Rolling modes, it is possible to adjust the number of cycles to preserve by using the <mark style="color:blue;">**:N**</mark> annotation. The default number of preserved cycles is 5. The value experimental-rolling is deprecated but is equivalent to rolling which should be used instead.

(More information about node configuration [here](https://tezos.gitlab.io/introduction/howtouse.html#node-configuration))

For example, the following command configures the node for the **Jakartanet** Network and stores data in the specified directory **\~/tezos-ithacanet** with the **full** mode.

```bash
tezos-node config init --data-dir ~/tezos-jakartanet --network=jakartanet --history-mode=full
```

You can run the node with :

```bash
tezos-node run --rpc-addr 127.0.0.1:8732 --log-output tezos.log
```

The parameter `--rpc-addr url:port` activate the RPC interface that will allow communication with the node. By default, it runs on port `8732` so it is not mandatory to specify it. The file tezos.log will be saved in /home/user/

</details>

<details>

<summary>Step 3: Check synchronization   ✅</summary>

The Tezos client can be used to interact with the node. It can query its status or ask the node to perform some actions. For example, after starting your node, you can check if it has finished synchronizing with the following command (you can use another terminal window if you still watch the log) :&#x20;

```bash
tezos-client -E http://127.0.0.1:8732/ bootstrapped
```

(`-E` option is equal to `--endpoint` option)

When you see the message "*Node is Bootstrapped*", your Tezos node is synchronized with the blockchain, and you may now perform operations on it !

</details>

<details>

<summary>Step 4: Import your keys</summary>

*<mark style="color:orange;">**Option 1: Import keys from a Ledger**</mark>*&#x20;

**Prerequisites: The Ledger Nano should be configured with the Tezos wallet and Tezos baking apps.**

Access the "Tezos wallet" app on your ledger and list the connected Ledgers with the following command:

```bash
tezos-client --endpoint http://127.0.0.1:8732 list connected ledgers
```

Import a key from a Ledger with the following command:

```bash
tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> <ledger://path/to/the/secret/key/on/your/device>
```

You have to replace`<key_alias>` by the alias of your choice, and `<ledger://path/to/the/secret/key/on/your/device>` by the path to your secret key on your ledger (four options are available to generate either tz1, tz2 or tz3 addresses).&#x20;

Validate the public key hash displayed on the ledger to validate the key import.

*<mark style="color:orange;">**Option 2: Import a secret key with the tezos-client**</mark>*

**⚠️⚠️⚠️ This option isn't recommended. Be careful when using your private keys unencrypted ⚠️⚠️⚠️**&#x20;

You have to replace`<key_alias>` by the alias of your choice, and provide the clear private key to the tezos-client, after the keyword "*unencrypted:"* :

```bash
tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> unencrypted:<your_private_key>
```

</details>

<details>

<summary>Step 5: Let's register as delegate</summary>

<mark style="color:orange;">**If you have a Ledger: Setup the Ledger to bake for your address**</mark>

Access the "Tezos Baking" app on your ledger and then do execute the following command:

(Replace `<key_alias>` by the alias chosen in step 4)

```bash
sudo tezos-client -E http://127.0.0.1:8732 setup ledger to bake for my-key-alias <key-alias-or-ledger-uri>
```

You will need to validate the request on your ledger.

<mark style="color:orange;">**In both cases: Register your key as a delegate on the network**</mark>

(Replace `<key-alias>` by the alias chosen in step 4)

```bash
tezos-client --endpoint http://127.0.0.1:8732 register key <key_alias> as delegate
```

</details>

<details>

<summary>Step 6: Let's bake!</summary>

⚠ Since the ***Jakarta*** amendment, the `--liquidity-baking-toggle-vote <vote>` command line toggle is mandatory. `<vote>` should be replaced by `on`, `off` or `pass`. Read more about liquidity baking in the [technical documentation.](https://tezos.gitlab.io/alpha/liquidity_baking.html)

You can launch the baker with:

```bash
tezos-baker-013-PtJakart --endpoint http://127.0.0.1:8732 run with local node /home/<user>/.tezos-node --liquidity-baking-toggle-vote <vote>
```

</details>

#### 🎉 Congratulations on setting up your baking node! 🎉

<details>

<summary>Bonus: Quick synchronization from a snapshot</summary>

If you want your node to be bootstrapped quickly, you can synchronize it with the blockchain using a snapshot.

&#x20;<mark style="background-color:orange;">1:</mark> Download a .full snapshot from <https://snapshots-tezos.giganode.io/> in your current repository by replacing with `<snapshot_url>` in following command:

```
wget <snapshot_url>
```

<mark style="background-color:orange;">2:</mark> Register the current directory in a variable:

```bash
path=$(pwd)
```

<mark style="background-color:orange;">3:</mark>  Import from the snapshot !

(Replace `<name_of_snapshot_file`>)

```bash
tezos-node snapshot import $path/<name_of_snapshot_file>
```

(It is possible to define the directory where the data will be stored with `--data-dir <directory>`, by default, it is in .tezos-node)

<mark style="background-color:orange;">4:</mark> You can get some information with the following command:

```bash
tezos-node snapshot info $path/<name_of_snapshot_file>
```

</details>

## Set up by building from source

In this part, we will see how to install Tezos from source.

The easiest way to build the binaries from the source code is to use the OPAM source package manager for OCaml.

This method is recommended for advanced users as it requires basic knowledge of the OPAM package manager and the OCaml packages workflow. In particular, upgrading Tezos from release to release might require tinkering with different options of the OPAM package manager to adjust the local environment for the new dependencies.

### [From scratch](https://tezos.gitlab.io/introduction/howtoget.html#setting-up-the-development-environment-from-scratch) method

<details>

<summary>Step 1 : Install OPAM</summary>

First, you need to install the OPAM package manager, at least version 2.0, that you can get by following the install instructions.

The quickest way to get the latest opam up and working is to run this script :

```bash
bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
```

(If you have trouble with `curl`, just [download the script](https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) and run `sh install.sh`)

For the next command line, answers the prompts with 'N' then 'y'. You may also be prompted for your `sudo` password. You may encounter a "switch" error, but you can ignore it.

```bash
opam init --bare
```

</details>

<details>

<summary>Step 2 : Install Rust</summary>

Compiling Tezos requires the Rust compiler, version 1.52.1, and the Cargo package manager for Rust to be installed. If you have [rustup](https://rustup.rs/) installed, you can use [rustup](https://rustup.rs/) to install both. If you do not have `rustup`, please avoid installing it from Snapcraft; you can rather follow the simple installation process shown below:

```bash
cd $HOME
wget https://sh.rustup.rs/rustup-init.sh
chmod +x rustup-init.sh
./rustup-init.sh --profile minimal --default-toolchain 1.52.1 -y
```

Once Rust is installed, note that your `PATH` environment variable (in `.profile`) may be updated and you will need to restart your session so that changes can be taken into account. Alternatively, you can do it manually without restarting your session with the following command :

```bash
. $HOME/.cargo/env
```

</details>

<details>

<summary>Step 3 : Install Zcash Parameters</summary>

Tezos binaries require the Zcash parameter files to run. This is for shielded/confidential transactions with [Sapling](https://docs.nomadic-labs.com/nomadic-labs-knowledge-center/sapling-making-con-dential-transactions-on-tezos), that were added in the **Edo** amendment. If you compile from source and move Tezos to another location (such as `/usr/local/bin`), the Tezos binaries may prompt you to install the Zcash parameter files. The easiest way is to download and run this script:

```bash
wget https://raw.githubusercontent.com/zcash/zcash/master/zcutil/fetch-params.sh
chmod +x fetch-params.sh
./fetch-params.sh
```

</details>

<details>

<summary>Step 4 : Install Tezos dependencies</summary>

Install the libraries that Tezos is dependent on:[**​**](https://opentezos.com/deploy-a-node/installation#install-the-libraries-that-tezos-is-dependent-on)

```bash
sudo apt-get install -y rsync git m4 build-essential patch unzip wget pkg-config libgmp-dev libev-dev libhidapi-dev opam jq zlib1g-dev bc autoconf
```

Get the source code:&#x20;

```bash
git clone https://gitlab.com/tezos/tezos.git
cd tezos
git checkout latest-release
```

Install tezos dependencies :&#x20;

```bash
make build-deps
```

You may encounter a "switch" error, but you can ignore it.&#x20;

You may encounter failures in the processes of the `make build-deps` command. In that case, just re-type the command "opam init --bare" to re-initiate.

</details>

<details>

<summary>Step 5 : Compile sources</summary>

Compile sources:

```bash
eval $(opam env)
make
```

</details>

<details>

<summary>Step 6 : Check installation</summary>

To check the installation you can use the following commands:&#x20;

```bash
tezos-node --version
```

</details>

<details>

<summary>Step 7: Let's config and run !</summary>

It is possible to define the directory where the data will be stored with **`--data-dir`** (by default, it is in .tezos-node).&#x20;

**`--network=`**<mark style="color:blue;">**`NETWORK`**</mark>  Select which network to run. Possible values are: <mark style="color:blue;">**sandbox**</mark>, <mark style="color:blue;">**mainnet**</mark>, <mark style="color:blue;">**\[testnet]**</mark> (e.g., jakartanet, kathmandunet. See current testnets [here](https://teztnets.xyz/)). **Default is mainnet.**

**`--history-mode=`**<mark style="color:blue;">**`MODE`**</mark>  Set the mode for the chain's data history storage. Possible values are <mark style="color:blue;">**archive**</mark>, <mark style="color:blue;">**full**</mark> (default), <mark style="color:blue;">**full:N**</mark>, <mark style="color:blue;">**rolling**</mark>, <mark style="color:blue;">**rolling:N**</mark>.&#x20;

* Archive mode retains all data since the genesis block.&#x20;
* Full mode only maintains block headers and operations allowing replaying the chain since the genesis if wanted. (full mode is recommended to bake. More information [here](https://tezos.gitlab.io/user/history_modes.html))
* Rolling mode retains only the most recent data and deletes the rest.&#x20;

For both Full and Rolling modes, it is possible to adjust the number of cycles to preserve by using the <mark style="color:blue;">**:N**</mark> annotation. The default number of preserved cycles is 5. The value experimental-rolling is deprecated but is equivalent to rolling which should be used instead.

(More information about node configuration [here](https://tezos.gitlab.io/introduction/howtouse.html#node-configuration))

For example, the following command configure the node for the **Jakartanet** Network and stores data in the specified directory **\~/tezos-ithacanet** with the **full** mode.

```bash
tezos-node config init --data-dir ~/tezos-jakartanet --network=jakartanet --h
```

You can run the node with :

```bash
tezos-node run --rpc-addr 127.0.0.1:8732 --log-output tezos.log &
```

The parameter `--rpc-addr url:port` activate's the RPC interface that will allow communication with the node. By default, it runs on port `8732`, so it is not mandatory to specify it. The file tezos.log will be saved in /home/user/

</details>

<details>

<summary>Step 8: Check synchronization   ✅</summary>

The Tezos client can be used to interact with the node. It can query its status or ask the node to perform some actions. For example, after starting your node, you can check if it has finished synchronizing with the following command (you can use another terminal window if you still watch the log) :&#x20;

```bash
tezos-client -E http://127.0.0.1:8732/ bootstrapped
```

(`-E` option is equal to `--endpoint` option)

When you see the message "*Node is Bootstrapped*", your Tezos node is synchronized with the blockchain, and you may now perform operations on it !

</details>

<details>

<summary>Step 9: Import your keys</summary>

*<mark style="color:orange;">**Option 1: Import keys from a Ledger**</mark>*&#x20;

**Prerequisites: The Ledger Nano should be configured with the Tezos wallet and Tezos baking apps.**

Access the "Tezos wallet" app on your ledger and list the connected Ledgers with the following command:

```bash
tezos-client --endpoint http://127.0.0.1:8732 list connected ledgers
```

Import a key from a Ledger with the following command:

```bash
tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> <ledger://path/to/the/secret/key/on/your/device>
```

You have to replace`<key_alias>` by the alias of your choice, and `<ledger://path/to/the/secret/key/on/your/device>` by the path to your secret key on your ledger (four options are available to generate either tz1, tz2 or tz3 addresses).&#x20;

**V**alidate the public key hash displayed on the ledger to validate the key import.

*<mark style="color:orange;">**Option 2: Import a secret key with the tezos-client**</mark>*

**⚠️⚠️⚠️ This option is not recommended. Be careful when using your private keys unencrypted ⚠️⚠️⚠️**&#x20;

You have to replace`<key_alias>` by the alias of your choice, and provide the clear private key to the tezos-client, after the keyword "*unencrypted:"* :

```bash
tezos-client --endpoint http://127.0.0.1:8732 import secret key <key_alias> unencrypted:<your_private_key>
```

</details>

<details>

<summary>Step 10: Let's register as delegate</summary>

<mark style="color:orange;">**If you have a Ledger: Setup the Ledger to bake for your address**</mark>

Access the "Tezos Baking" app on your ledger and then do execute the following command:

(Replace `<key_alias>` by the alias chosen in step 9)

```bash
sudo tezos-client -E http://127.0.0.1:8732 setup ledger to bake for my-key-alias <key-alias-or-ledger-uri>
```

Validate the request on your ledger.

<mark style="color:orange;">**In both cases: Register your key as a delegate on the network**</mark>

(Replace `<key-alias>` by the alias chosen earlier in step 9)

```bash
tezos-client --endpoint http://127.0.0.1:8732 register key <key_alias> as delegate
```

</details>

<details>

<summary>Step 11: Let's bake !</summary>

⚠ Since the ***Jakarta*** amendment, the `--liquidity-baking-toggle-vote <vote>` command line toggle is mandatory. `<vote>` should be replaced by `on`, `off` or `pass`. Read more about liquidity baking in the [technical documentation.](https://tezos.gitlab.io/alpha/liquidity_baking.html)

You can launch the baker with:

```bash
tezos-baker-013-PtJakart --endpoint http://127.0.0.1:8732 run with local node /home/<user>/.tezos-node --liquidity-baking-toggle-vote <vote>
```

</details>

**🎉 Congratulations on setting up your baking node! 🎉**

### [Tezos OPAM packages](https://tezos.gitlab.io/introduction/howtoget.html#install-tezos-opam-packages) method

<details>

<summary>Step 1 : Install OPAM</summary>

First, you need to install the OPAM package manager, at least version 2.0, that you can get by following the install instructions.

The quickest way to get the latest opam up and working is to run this script :

```bash
bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
```

(If you have trouble with `curl`, just [download the script](https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh) and run `sh install.sh`)

For the next command line, answers the prompts with 'N' then 'y'. You may also be prompted for your `sudo` password. You may encounter a "switch" error, but you can ignore it.

```bash
opam init --bare
```

</details>

<details>

<summary>Step 2: Get an environment</summary>

```bash
wget -O latest-release:version.sh https://gitlab.com/tezos/tezos/raw/latest-release/scripts/version.sh
```

The binaries need a specific version of the OCaml compiler (see the value of variable $ocaml\_version in file /tezos/scripts/version.sh).

```
source latest-release:version.sh
opam switch create for_tezos $ocaml_version
eval $(opam env)
```

If you get a "c compiler error", run this to install some necessary tools:

```
sudo apt-get install build-essential
```

</details>

<details>

<summary>Step 3: Get dependencies</summary>

In order to get the system dependencies of the binaries, do:

```
opam depext tezos
```

</details>

<details>

<summary>Step 4: Install binaries</summary>

```
opam install tezos
```

</details>

**Now follow Steps 6-7-8-9-10-11 of "From scratch method"**

#### 🎉 Congratulations on setting up your baking node! 🎉

<details>

<summary>Bonus: Quick synchronization from a snapshot</summary>

If you want your node to be bootstrapped quickly, you can synchronize it with the blockchain using a snapshot.

&#x20;<mark style="background-color:orange;">1:</mark> Download a .full snapshot from <https://snapshots-tezos.giganode.io/> in your current repository by replacing with `<snapshot_url>` in following command:

```
wget <snapshot_url>
```

<mark style="background-color:orange;">2:</mark> Register the current directory in a variable:

```bash
path=$(pwd)
```

<mark style="background-color:orange;">3:</mark>  Import from the snapshot !

(Replace `<name_of_snapshot_file`>)

```bash
tezos-node snapshot import $path/<name_of_snapshot_file>
```

(It is possible to define the directory where the data will be stored with `--data-dir <directory>`, by default it is in .tezos-node)

<mark style="background-color:orange;">4:</mark> You can get some information with the following command:

```bash
tezos-node snapshot info $path/<name_of_snapshot_file>
```

</details>

**⚠️⚠️⚠️ Be careful when closing terminal windows because this stops the node. ⚠️⚠️⚠️ (hint: use** [**screen**](https://doc.ubuntu-fr.org/screen)**, or** [**nohup**](https://www.computerhope.com/unix/unohup.htm) **to keep the node running)**
