> Agents can also search and read this documentation through its [MCP server](https://docs.nomadic-labs.com/nomadic-labs-knowledge-center/~gitbook/mcp).

# Introduction

🐙 Welcome to Nomadic Labs knowledge center. Here you will find all the necessary documentation to help you understand the main concepts and tools to build successfully on Tezos. Enjoy the read!

![Coarse-grained architecture of Tezos](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2nedRL0KKE9D0F2pD%2F-Mk2oJfxIUv44hBFZuZn%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2017-26-33.png?alt=media\&token=63fc594d-f6ad-46d2-84ea-5a5207449c51)

*Please note this knowledge center is a dynamic documentation subject to regular changes. If you think something is missing kindly report it at:* [*support@nomadic-labs.com*](mailto:support@nomadic-labs.com)


# Baking - Creating blocks on the Tezos blockchain (DEPRECATED)

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

## Introduction

The following characteristics set the Tezos blockchain apart from other blockchains:

1. **On-chain governance**, making it possible for the protocol to evolve by upgrading itself through successive amendments.
2. **The Liquid Proof-of-Stake** (LPoS) **consensus,** ensuring a low-carbon footprint and a coin delegation mechanism (explained [below](#liquid-proof-of-stake-and-delegation)).
3. The **Michelson development language** used for smart contracts, providing a solid basis for formal verification.

This document provides a detailed introduction to:

* the consensus algorithm, and
* the mechanism for creating blocks -- or *baking*, as it is known on Tezos.&#x20;

## Definition of the main concepts

**Block:** A set of operations for validation. A block contains, besides operations, information such as the current block number, information about the previous block, and also the time at which it was validated.

**Baking:** Creation of new blocks on the Tezos blockchain by participants known as **bakers**, who are given a reward for each block that they bake. A baker may also be referred to as a **delegate**.

**Preendorsement**/**Endorsement:** In addition to creating new blocks, bakers may approve blocks made by other bakers. They are known as **preendorsements** (1st approval phase) and **endorsements** (2nd approval phase) of a block.

**Delegation:** Every Tez holder (XTZ or <img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line">) can transfer the baking and voting rights associated with their Tez to a baker. The holder always retains control of their funds and may change delegate at any time.

**Stake:** To have the right to be recognized as a baker in a network, a Tez holder must possess at least 6,000<img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line"> in their staking balance (own balance + delegated balance). Voting rights are also indexed to the staking balance.

**Cycle:** Period of time during which 8,192 blocks are created on the Tezos blockchain. Also used as a unit of time. It corresponds to roughly 2 days, 20 hours, and 16 minutes (based on 30 seconds per block created if no baker has missed their baking slots).

**Fitness:** Score representing the quality of the chain up to a given block. In the current protocol, the fitness includes its version (currently 2. Version 0 was used by Emmy, and version 1 by Emmy+ and Emmy\*), the level of the current block as the third component, the round at which a preendorsement quorum was observed by the baker, the opposite of predecessor block’s round as the forth component (the predecessor is taken for technical reasons), and finally the block’s round (as the fifth component).

**Slot:** A slot is a position available for a block creation or an endorsement: each cycle has 8,192 baking slots and 2,097,152 endorsement slots. At the start of each cycle, the protocol assigns a list of bakers to each slot using a uniform law weighted by staking balance. The first baker on the list is tasked with baking or endorsing as appropriate. If they don't, the next baker is given the task, etc.

**Round**: A period of time (made up of 3 phases) during which a given validator (selected to produce a block) proposes a block, obtains preendorsements, and then endorsements. If, for certain reasons it fails, we go to another round, and so on.

[**Node**](http://tezos.gitlab.io/user/history_modes.html)**:** A Tezos node is a peer (a machine) on the peer-to-peer network. It keeps a copy of the current state and propagates the blocks baked and operations performed to the other peers. A node is not necessarily a baker, but a baker is always associated with one or more nodes. Nodes are running in one of the following three modes, with respect to how they keep the chain history:

* In **archive** mode, they keep the whole history of the chain. As of year-end 2020, an archive node takes up around 80GB.
* In **rolling** mode, they keep the minimum data required to operate the chain, with the oldest information being deleted regularly.
* In **full** mode (the default mode), they keep all the information in a rolling mode, plus the minimum data required to reconstitute the entire chain from the genesis block. Thus, the full mode combines elements of the archive and rolling modes.

## Contents of a block

A *blockchain* is made up of a series of blocks. Each block consists of a header and a list of operations. The header contains key data related to the block's validity, such as:

* The block-level or the block height in the chain
* The round at which the block has been created
* The block predecessor's hash, which is used to chain the blocks together
* The block's timestamp
* The signature of the baker that produced the block
* The block's fitness, assigning a score to the chain up to the current block

The block's body then contains a list of various operations (transfer of Tez, deployment of smart contracts, etc.) up to the maximum size permitted under the protocol (currently 512KB per block).

## Liquid Proof-of-Stake and delegation

Baking rights are attributed on Tezos randomly but proportionally to the staking balance (own balance + delegated balance). A Tez holder may:

* become a baker if they possess at least 6,000<img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line"> in their own funds or by delegation
* delegate their Tez to a baker, to participate in the consensus

In practice, certain bakers may pass on some of the rewards they receive to the individuals who delegated their Tez to them. This distribution may encourage others to delegate their Tez, thereby increasing the delegated balance of these bakers and so their staking balance, i.e. their chance of baking/endorsing.

**Liquid Proof-of-Stake** (LPoS) provides the option for a Tez holder to retain ownership of their funds while delegating their associated (voting, baking) rights to a baker. This principle differs from the delegated Proof-of-Stake (DPoS) of other blockchains, in which participants vote for a restricted number of block validators.

## Baking

In Tezos we call participants in the block validation process **delegates**. Each delegate can:

* act as a baker, creating and signing blocks, and/or
* act as an endorser, approving blocks by issuing an endorsement operation (endorsements visible at the block level `n + 1` relate to the block level `n`).

Baking and endorsement rights are attributed at random, several cycles in advance. To deter dishonest behavior (e.g. double baking or double endorsement), **each delegate must place a fixed quantity of Tez as a security deposit for a limited time** (five cycles), which will be confiscated if they attempt to compromise the chain.

Prospective bakers must meet the following requirements:

* Server available round the clock and stable internet connection
* At least 8GB of RAM
* SSD disk (preferably with more than 100GB storage)
* At least 6,000<img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line">

## Endorsement

Among the bakers, a list of endorsers is drawn up for each block. Their role is to approve the blocks created by the baker -- i.e. to officially approve the block.

To approve a block at level n, the endorsers each add a signature operation that is included in the `n + 1`-level block. Once the block `n + 1` is baked, no more endorsement operations are accepted for block `n`.

Each block has 7,000 endorsement slots. There is no obligation for a baker to include  endorsements with endorsing power more than 4,667 but the baker will receive a bonus  proportional to the extra endorsing power of the endorsements included.

An endorser may obtain several endorsement slots for a given block. They will then be rewarded for each endorsement slot completed (i.e. for each slot validated).

## Options for baking

In practice, blocks are baked and endorsed automatically. There are several options for setting up a baker, each with its own advantages and disadvantages. Here are some baking options, with links to more information:

* Kiln and Ledger Nano: <https://gitlab.com/tezos-kiln/kiln>. An intuitive plug-and-use method for setting up a node and baker.
* BakeBuddy and Ledger Nano: <https://www.bakebuddy.xyz/>. An intuitive plug-and-use method for setting up a node and baker.
* Remote Signer and Ledger Nano: <https://github.com/obsidiansystems/ledger-app-tezos>.
* Remote Signer via the Cloud: <https://www.ecadlabs.com/signatory>.

The following links provide information on how to set up a baker:&#x20;

* <https://github.com/tzConnectBerlin/baking-support>
* [Tezos Node Setup & Maintenance by BakingBenjamins](https://docs.bakingbenjamins.com/baking/tezos-baking-node-setup)

## Remote signing

**Remote signing software** is one way to reduce the exposure of private keys during baking operations. In the block validation process (baking/endorsement), the software interacts with a private key management system (e.g. Ledger Nano S, a remote machine communicating via a secure channel).

Remote signing involves physically separating baking/endorsement requests originating from the network and intended for a given delegate, from that delegate's signing operation. The Tezos client implements several built-in signing mechanisms (unix, tcp, http, and https) that use different communication channels to send signing requests for the baker.

The following events occur during a remote signing operation:

1. The node sends a signing request to the remote signing software that interacts with the private key management system.
2. The remote signing software verifies what the operation involves − usually the creation of a block or an endorsement (The third, rarer option is a nonce revelation.) − then sends it to the key management system, which signs the operation.
3. The signature is then validated by the remote signing software and sent back to the Tezos node, which propagates the operation to the network.

The key should preferably be **held in a hardware vault** so it is never directly accessible on the network. Moreover, it is more secure to ensure that the hardware vault authorizes only block signing rather than the signing of just any transaction (i.e. such as not to create a blind signing mechanism).

For example: Ledger Nano S together with Kiln meets these two conditions.

## Baker selection

In each cycle `n`, baking/endorsement rights at cycle `n + 5` are randomly attributed as follows.&#x20;

A **stake snapshot** is a picture of the status of the stake of each network participant in cycle `n - 2`.

A random seed is generated at cycle `n` based on certain information contained in the previous blocks. This seed is then used to select the validators (from those in the stake snapshot) to which baking/endorsement rights are attributed at cycle `n + 5`.

Rights are allocated using the following mechanism:

* For each block, a list is drawn up, setting an order of priority for bakers and endorsers.

Once listed, a baker, therefore, has to wait for at least seven cycles before being eligible for selection. Bakers are thus aware of their baking/endorsing rights at least seven cycles in advance.

## Rewards for bakers and endorsers

Bakers are crucial because they operate the chain by creating blocks and checking the integrity of the data they contain. Each baked block leads to the creation of new Tez to incentivize the bakers to perform baking and endorsing operations.

There are up to 20 Tez paid in *baking* rewards, and 20 Tez paid in *endorsing* rewards per block (for a total of 40 Tez per block). Block rewards are split into two parts: a fixed part (10 Tez for the payload producer who selects the transactions to be included in the block and the first authorized to propose a block with that payload, and at most 10 Tez as a bonus for the block producer who proposes the block. In case of re-proposal, the payload producer might be different from the block proposer. Otherwise, it should be the same), and a variable part which is a bonus for the block producer, depending on the number of endorsements included (beyond the 4,667 endorsements threshold).&#x20;

Baking rewards (fixed and variable) on each block are paid immediately, whereas endorsements rewards are paid at the end of each cycle, under the conditions of participating in the consensus (performing endorsement operations) more than 2/3 of its expected number of slots; and if they reveal their nonces.\
\
Baking and endorsement rewards follow the formulas below:

&#x20; $$\begin{equation}  baking \ rewards  =   10 \ + \  e \ ∗ \ 0.004286 \end{equation}$$

where $$e$$$$\in$$`[0; 2,333]` = the number of extra endorsements slots beyond the threshold of 4,667.

The baking rewards are 20 Tez at most, for a fully endorsed block (not counting the transaction fees).

$$\begin{equation}  endorsement \ rewards  =  s  \ ∗ \ 0.002857 \end{equation}$$

where$$s$$ = number of endorser’s slots.

An endorser may have several slots among the 7,000 slots available in a given block, depending on its stake. The more stake a baker has, the more slots it gets per block.

## Issuing new Tez

As stated above, each time a block is created and validated, new Tez are created.

The per-block reward can be used to estimate that a block produces a maximum of 40 Tez. Extending this per-block reward to the number of blocks baked per annum at a rate of two blocks per minute (105,120 per annum excepting leap years), then the number of Tez increases by at most 5.51% in year 1 (in 2018). Since the rewards are fixed, this percentage declines over the years.

The growth in the "money supply" does not apply solely to bakers. If a Tez holder delegates them to a baker who passes on a portion of their rewards, that Tez holder will also benefit from the new money created.

Several phenomena independent of the baker can lead to fluctuations in their return:

* Not all Tez might be active in the baking process, increasing annual return.
* The time interval between blocks could be more than 30 seconds, decreasing the annual return.
* The full 7,000 endorsements might not have been gained, decreasing annual return.

A holder delegating their Tez may wish to select a reliable baker who pays them interest. The estimated return can be observed based on the amount of Tez delegated:

* <https://www.stakingrewards.com/earn/tezos>

## Modeling a baker's gains (Deprecated)

With the following assumptions:

* Number of active rolls in the year one = 84,156 (correct at the time of writing)
* One block baked per minute
* 7,000 endorsements for each block

…a baker possessing one roll (= 6,000<img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line">) will create on average one block per month, and will endorse around 7,000 blocks per month. This is close to 480 Tez earned per annum on average, or a return of approximately 6%. This value is slightly higher than the 5.51% stated above because we assume here that there are inactive rolls, which means active rolls earn more revenue than in a situation where all rolls are active.

A baker also receives fees for the transactions they include in any blocks they create. These fees depend on supply and demand, but the gains are currently well below the reward for creating the block itself (≈ 0.1% of the baker's gains in 2019).

Continuing the assumptions above, here is an example showing what a baker who retains their baking rewards can earn in a year, according to how many <img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line"> they hold: &#x20;

![Modeling table of rewards, assuming that 673248k Tez are in circulation  ](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MiwaA7fIY8lunDyOKjM%2F-Miwbjz1ab3yxLdop3io%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-06%2021-38-41.png?alt=media\&token=43f76319-348d-45b4-a893-98e5df6a395c)

Alice has only 1 roll at the outset and Bob has 10. After ten years, Alice is still baking with a single roll whereas Bob has five more. This reveals the **critical mass** applicable to bakers. Unlike smaller bakers, larger ones earn a linear increase in the number of rolls they hold over time.

#### These results are simulations based on assumptions, and so a baker's actual revenue may not be the same as the figures shown in this table.

## Security deposits and penalties

To discourage double **baking**/**endorsement**¹ a security deposit is required.

**The security deposit remains physically in the account but is locked up for a period of five cycles** (around two weeks). The corresponding Tez are always taken into account when calculating slots, but they cannot be spent or used as a new security deposit until they have been released again.

All security deposits are frozen when rights for a cycle are being drawn. On mainnet, rights for a cycle are determined 5 cycles in advance, and a delegate has a speciﬁc deposit associated to each cycle. **We only retain one deposit:** the highest deposit of all cycles in a timeframe of 7 cycles, so that we are always able to punish proportionally to the capacity to harm in this timeframe. If a validator double signs (it double bakes or it double (pre)endorses (which means voting on two different proposals at the same round), the frozen deposit is slashed). The slashed amount for double baking is `DOUBLE_BAKING_PUNISHMENT = 640 Tez`. The slashed amount for double (pre)endorsing is a fixed percentage `RATIO_OF_FROZEN_DEPOSITS_SLASHED_PER_DOUBLE_ENDORSEMENT = 1/2` of the frozen deposit. \
\
**Bakers are advised to hold at least 10% of the total number of Tez used for baking purposes.** By default, the required deposits are automatically determined to maximize the active stake. **However, no baking/endorsements slots will be assigned to a delegator who has not enough security deposit.**

When a double baking/endorsement is observed, an accusing baker may provide evidence in a block for a period of five cycles starting from the fake operation. As a reward for the accuser, half the culpable baker's deposit goes to the accuser. The other half of the deposit is destroyed.

**\[1]:** *Double baking (or double (pre)endorsement) means baking ((pre)endorsing) two different blocks at the same level and round, with the same key, which may temporarily cause the chain to fork.*

## Actions prejudicial to the network

The following actions result in the punitive seizure of the security deposit:

* **Double baking**: A dishonest baker may try to bake two blocks at the same block height in the chain. However, to be able to do this, they would have been drawn at random and then deposit 640 Tez per block baked.
* **Double endorsement**: A dishonest endorser could attempt to endorse two blocks at the same block height in the chain. Half of the total deposit is forfeited.&#x20;
* **Seed slash**: a baker is asked to provide random seeds to feed into the baker selection algorithm. To avoid the algorithm being deterministic, the seeds are given in a hashed form. The baker undertakes to deliver in the following cycle the seeds corresponding to the hashes sent. If they do not do so, they do not earn a reward but may still get back the associated deposit.

The protocol allows a window of five cycles during which an **accuser** may demonstrate evidence of double baking or double endorsement (several times if necessary). The dishonest baker will then lose the security deposit(s) placed for the fake operation up to the latest point in the cycle (which may be costly, especially if the baker has done a lot of baking/endorsing over the relevant period).

## Minimum time delay before baking a block

The minimum time delay between two blocks is 30 seconds, reached if the baker is of priority 0 and has gathered at least 66.7% of the endorsements. If the priority 0 baker fails to bake, the priority 1 baker may then bake after a certain time, defined by a so-called round duration function.

To be able to bake as rapidly as possible, the baker must gain enough endorsements (66.7%, that is, endrosements with endrosing power of at least 4,667 out of 7,000). Rounds follow the structure below:

$$round \_ duration(0)=minimal \_ block \_ delay\round \_ duration(r+1)=round \_ duration(r)+delay \_ increment \_ per \_ round  =minimal \_ block \_ delay+(r+1)∗delay \_ increment \_ per \_round$$

Round duration thus increases linearly with `DELAY_INCREMENT_PER_ROUND = 15s`, `MINIMAL_BLOCK_DELAY = 30s`,`r = round`.

Any block baked ahead of the minimum time delay is automatically rejected under the protocol's rules.

## Over-delegation

A security deposit is required to bake and endorse properly. This amount remains locked up over a timeframe of seven cycles. In addition, a baker cannot spend Tez that have been delegated to them or use them as security deposits.

#### A baker is said to be over-delegated when they do not have sufficient funds themselves relative to their stake. However, they do not miss slots because of a lack of security deposit and thus will not slow down the chain anymore².&#x20;

The over-delegated baker will not maximize its staking power, since more Tez are delegated compared to what it should own (10% of the total staking balance).

\
To keep a portion of its balance spendable, a baker can set a deposit limit:

`tezos-client set deposit limit for <delegate> to <deposit_limit>`

, and unset this limit with the command:

`tezos-client unset deposit limit for <delegate>`&#x20;

**\[2]:** *Before Ithaca amendment, over-delegated bakers could end up losing slots (thus not gaining the associated rewards) because they hadn't sufficient funds to cover the security deposits for all their attributed slots.*

## Inactivity

A baker who refuses or is unable to bake or endorse for five cycles will be treated as inactive by the chain, and can no longer be picked as a baker/endorser.

The inactive baker must wait for seven cycles after reactivating their account, before they can bake again.

This mechanism is designed to ensure that a baker who is no longer active, does not slow down the chain.

## Attacks

The attacks potentially targeting a baker include:

* **DoS (denial of service attack):** Suppose Bob knows that Alice is about to bake a block with priority 0. He may decide to launch a DoS attack to prevent Alice from publishing her block correctly, thus damaging Alice's reputation. If the attack is sustained, and if Bob appears toward the top of the list of potential bakers (especially if he has priority 1), then he may also be able to steal Alice's block.
* **Theft or loss of a private key:** Holding the private key is the only way to gain access to the associated Tez and to sign various operations. Thus it is vital to keep the private key safe and secure (e.g. in a hardware wallet).
* **Eclipse attack:** An attacker can try to cut off (or take control of) the connection between the baker and the network nodes to which they are connected. Thus, the attacker could send the isolated baker blocks that are not part of the consensus.

## Summary diagram

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FRC2vyAx5Y03ZMUORkbry%2FCopie%20de%20Baking.drawio.png?alt=media\&token=4f7a4656-d5f4-433e-b6dd-5ae49235a8e7)


# Nodes in the Tezos blockchain (DEPRECATED)

## PLEASE REFER TO: <https://opentezos.com/tezos-basics/nodes>

### Introduction

Blockchain is a peer-to-peer network in which every peer is a node ensuring a set of diverse functions within the distributed software. In this document, we will explore the notion of nodes in Tezos, focusing on their role as well as their features and limitations.

### Deﬁnition

Within a blockchain, nodes are the main components in order to keep the network alive and decentralized.

A node is a physical machine that stores a copy of the current state of the blockchain and updates it with the information it receives from other nodes (also known as peers). Therefore, a node is connected in a peer-to-peer way to plenty of other ones.

A node systematically communicates the information it receives to nodes it is connected to, in order to, later on, allow them to transmit this information to their own peers. This ensures that every node from the Tezos network stores the same information.

The particularity of public blockchains lies in the fact that anyone can launch a node. The chain is therefore expected to have a large number of nodes, thus reducing the risks associated with the potential failure of an important actor of the network.

Once launched, a node connects itself to other peers (an average of forty) in the network, establishing communication channels and thus allowing the interested parties to exchange information (blocks, operations, etc).

By mid-2020, the Tezos blockchain had more than 1,000 active nodes on the [network](https://medium.com/coinmonks/inspecting-tezos-decentralization-200-public-nodes-1000-in-total-6ef0761caac9).

### Peer-to-peer network

The Tezos network implements a gossip protocol whose main operations are linked to:

* **A read / write scheduling mechanism** allowing to control the bandwidth.
* **An encrypted communication service** to establish a secure connection with other peers.
* **Black, gray, and whitelisting services** to establish or refuse connections requested by certain peers.

### Differences between a node and a baker

On the Tezos blockchain, **bakers** are entities taking up the role of block creators (they are the equivalent of miners on Bitcoin). A node is therefore not necessarily attached to a baker. However, it is mandatory for a baker to be linked to a node in order to monitor the arrival of new operations, retrieve pending transactions, and thus create and distribute its own blocks when it is selected by the network.

Bakers usually have their own nodes, however, the concepts of ‘bakers’ and ‘nodes’ are distinct. Thus, while a baker always needs to interact with at least one node, a node is independent of a baker and can run by itself.

### The different types of nodes

When launching a Tezos node, several conﬁgurations allow it to synchronize with other peers of the network. Each node type leads to synchronization, but the synchronization speed varies as well as the data availability. Below are the 3 modes of a node conﬁguration:

* **Archive mode**: a node in archive mode stores the entire blockchain state. A node launched on the Tezos blockchain in the archive mode will download the entire chain history since the launch of the network. As of early 2021, the entire blockchain takes about 145*GB*.
* **Full mode** (default mode): a node storing the entire blockchain, without storing the ‘context’ (the blockchain state containing information such as: "Alice's account owns 5") below a certain level called ***savepoint***. It is possible to rebuild an Archive Node from a full snapshot**¹**.
* **Rolling Mode**: the lightest existing node mode, which stores a fragment of the chain, and removes anything before that fragment (blocks, operations, archived contexts).

It is possible to use a *snapshot* to speed up node synchronization. Snapshots can be used to initialize full and rolling nodes. It is also possible to switch between [the different types of nodes](https://tezos.gitlab.io/user/history_modes.html).

**\[1]:** A copy of the blockchain’s state at a given moment in time.

### Node conﬁguration

The different types of nodes previously introduced allow users to choose the most suitable one depending on the amount of information needed. An *indexer* (tool allowing to monitor blocks creation, transactions,...), for example, will most likely need an archive node, while a user who wants to experiment with basic nodes deployment may simply use a rolling version.

Launching a node in one of the different modes:

* ```
  $ tezos−node run −−history−mode [archive|full|experimental-rolling]
  ```

  Importing a full / rolling snapshot with the corresponding extension (*.roll* or *.full*):
* ```
  $ tezos−node import snapshot path/to/snapshot
  ```

**Getting snapshots:**&#x20;

To get freshly exported snapshots of the Tezos mainnet and testnet, It is possible to rely on public node services:

* [https://snapshots.tulip.tools/#/](https://snapshots.tulip.tools/%23/)
* <https://snapshots-tezos.giganode.io/>
* <https://xtz-shots.io/>

### Possible actions with a node

In a blockchain, a node acts as an interface between the user and the peer-to-peer network. The node has two main functions:

* **Information storage**: since a node keeps a real-time copy of the current state of the blockchain, it allows fetching information (by using the `tezos-client` binary) about what is happening in real time. This function, for example, allows feeding indexers, which retrieve information from the nodes and process it to make it more humanly readable.
* **Information transmission**: user-initiated transactions go through the nodes before being included in the blockchain. Nodes are thus an entry point for operations intended to be validated by bakers.

Generally, these functions are complementary. For example, a user might often need to check the contents of the chain to verify that what he is sending is not immediately rejected by a node.

A baker will use a node and therefore both of the aforementioned aspects to operating. Indeed, it will have to read the pending operations provided by the node, then read the context in order to ensure that the operations are applicable before validating them and including them in a block that will be transmitted to the entire network.

### Communicating with a node

As seen in the previous slide, communicating with a node allows access to the peer-to-peer network. Bakers automatically communicate with the nodes they are connected to, but it can be useful for a user to being able to interact directly with his own node, in case he would like to inquire the chain’s status or push operations by himself.

Direct communication with a node happens through the use of Remote Processing Calls ([RPC](http://tezos.gitlab.io/developer/rpc.html)).

It is also possible to use a dedicated user interfaces such as a [client](http://tezos.gitlab.io/introduction/howtouse.html#client), [indexer](https://wiki.tezosagora.org/build/blockchain-indexers), or [wallets](https://tezos.com/learn/store-and-use/). However, in practice, indexers are the most practical tools for a user to access on-chain information.

### Advantages offered by a node

For operational purposes, an entity might want to have control over its own Tezos nodes. Such control helps to avoid dependency on a third party that could be failing. Firstly, this means independence from a unique node that could be prone to failure, and in addition, it helps to increase the chain resiliency and decentralization by contributing to the peer-to-peer network.  The larger is the number of nodes, the more decentralized and robust a blockchain tends to be.

Owning a node means that one can manage his own transactions and ensure that they are broadcast to the entire network.

Becoming a baker on the Tezos blockchain usually involves controlling a node, while providing certain beneﬁts. Indeed, any baker in the network receives rewards in return for his work of validating blocks and securing the network. In particular, a baker can include its own transactions without paying any fees. Added to this, there is the attribution of voting rights relative to the [amendments](https://docs.nomadic-labs.com/nomadic-labs-knowledge-center/amendment-process) proposed by the chain participants.

### Possible node attacks

A blockchain node can suffer from different types of attacks inherent to all software that are based on a peer-to-peer network. It is usually recommended for a node to secure its communication channels and to store its private keys (if it has any) in a cold wallet **²**.

**Denial of service:**

The denial of service attack (or DoS) is a computer attack that makes a service unavailable. In the case of a Tezos node, this would mean attacking a particular node by sending it very resource-intensive requests. It can make the attacked node unavailable because of a lack of resources required to respond to the said request.

The node must therefore make sure to limit access to these types of requests. As this is a very classical attack on the Internet, the usual preventions can [apply](https://en.wikipedia.org/wiki/Denial-of-service_attack) to a node infrastructure.

**Sybil attack:**

This is an attack that consists in creating a large number of identities on the peer-to-peer network with the aim of isolating one or more nodes from the rest of the network and feeding them with wrong information. In Tezos, this attack consists in generating a large number of nodes, in order to isolate one or more targeted nodes to which the attacker would communicate compromised information (erroneous blocks for example).

To prevent this kind of attack, the Tezos node algorithm allows changing peers regularly and automatically, in order to make sure that the attacker cannot maintain a long enough grip for the chain to be affected.

In addition, creating a node identity costs a certain amount of computing time**³**. Therefore, generating a node takes a few seconds, but generating enough nodes to split the network would take a long time, even with a powerful machine.

Finally, if attacks are observed on the network, it would be possible to increase the level of work required by peers and regenerate all identities to prevent the attack and to contain it completely if all peers do so.\
\
**\[2]:** Key storage technic which uses a hardware material not connected to the internet (examples: [Ledger](https://www.ledger.com/) and [Trezor](https://trezor.io/) products).

**\[3]:** To create an address, it must be given a certain level of ”work” ranging from 0 to 255. This level corresponds to the number of zeros in front of the hash of its identity. When creating an identity, the program generates different versions until it finds one with a sufficient level. One can then choose to refuse to connect to peers whose identity is lower than a certain value. By default, this value is set to 26.


# Tezos Amendment Process (DEPRECATED)

## PLEASE REFER TO: <https://opentezos.com/tezos-basics/history-of-amendments>

## Introduction

The aim of this document is to offer a detailed view of the Tezos on-chain governance model by going through the process used to consider protocol amendments.

## Definitions of main concepts

**Baking:** The creation of new blocks on the Tezos blockchain by its validators (also known as bakers or delegates), who receive compensation for each block produced.

**Endorsement:** Each baked block is validated by a set of bakers who have not baked the block, but are selected to endorse it. They are known as endorsers of the block, and receive compensation for each endorsement realized.

**Delegation:** All Tez holders can delegate their baking and voting rights to a “delegate”, while still maintaining control over their funds.

**Stake:** To have the right to be recognized as a baker in a network, a Tez holder must possess at least 6,000<img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line"> in their staking balance (own balance + delegated balance). Voting rights are also indexed to the staking balance.

**Cycle:** The time required for 8,192 blocks to be created on the Tezos blockchain. It lasts around 2 days, 20 hours, and 16 minutes (or 30 seconds. per block, if all bakers cooperate effectively)

**Proposal:** A request for addition, adjustment, or removal of features of the protocol.

## Amendment process

On Tezos, any baker can submit a proposal to amend the protocol.

The proposal/voting process then takes place entirely on-chain and is known as the **amendment process**.

This process involves 5 stages:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywEhXL4_etDtXAc%2F9.png?generation=1631954138285699\&alt=media)

As each period lasts **5 cycles (approx. 14 days)**, a complete amendment process requires **25 cycles**, or around **2 months and 10 days** to be adopted and merged with the main network.

## First period: Proposal

### ![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywHMVdcE1kYL1g-%2F12.png?generation=1631954138279739\&alt=media) First period - Proposal (Cycles 1-5)

During this period, users can submit **up to 20 amendment proposals** which are then subjected, over subsequent periods, to voting and testing.

Proposals can relate to a variety of features, for example:

* The threshold to register as a baker
* The gas consumption process
* Aspects/features of the smart contract language
* and so on...

Bakers across the network then proceed to vote (in the form of up-voting). The most highly voted proposal then moves on to the **Exploration** period.

## Second period - Exploration

### ![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywKwvVUx-Pq2by3%2F15.png?generation=1631954138295379\&alt=media)Second period - Exploration Vote (Cycles 6-10)&#x20;

During this period, all voters must decide whether or not the proposal brought forward will proceed to the next period: **the cooldown period**. Unlike in the previous period, Tezos uses **the concepts of Quorum and supermajority vote** – or qualified majority vote – to decide whether or not to send it to the cooldown period.

What we mean by these terms :

* **Quorum**: the representation weight required for a vote to actually take place.
* **A supermajority vote** or qualified majority vote – establishes a minimum percentage of positive expressed votes needed (80% for Tezos) for a decision to be taken.

In order to move to the next period, a proposal must have a greater Voter Turnout than the Quorum and a greater percentage of positive votes than the supermajority.

### Voting during the Exploration period (Cycle 6-10)

#### Calculating the Quorum:

When the Tezos Mainnet was launched, the Quorum was set at 80% and updated at the end of each vote which was successfully approved, based on the Voter Turnout.

The Babylon amendment introduced two major changes to the calculation of the Quorum:

* The calculation now takes into account the exponential moving average (EMA) of the Voter Turnout
* The Quorum is now bounded between 30% and 70%

The following formula is used to calculate the Quorum:

$$Quorum = 0.3 + MME\_t ∗ (0.7 − 0.3)$$&#x20;

The following formula is then used to update the moving average for the next vote:

$$MME\_{t+1} = 0.8 \* MME\_t + 0.2 \* Participation\_t$$

#### Voting system :

There are 3 possible ways to vote :

* **Yay** (Y): For
* **Nay** (N): Against
* **Pass** (A): Neutral

To vote, each active baker on the network must have at least 6,000<img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Miw3anzlxMy8cARSNa6%2F-Miw3tS7qysA_iYmsCgb%2F48.png?generation=1630948008044107&amp;alt=media" alt="" data-size="line">. Each holder of the tez cryptocurrency can delegate their “associated voting right” to a baker, while retaining control over their funds.

The weight of a baker’s vote is determined on a pro-rata basis by the size of their staking balance.

#### The more tez a baker has, the greater the weight of his vote.

### Voting example 1/2

To illustrate this process, let us assume a total of 100 active voting rigths managed by bakers and a Voter Turnout EMA of 75%, and then 90 votes (Yay, Nay, and Pass) during the Exploration period.

#### Exemple 1 :

1\. Quorum = &#x30;*.*&#x33; + 75% ∗ (&#x30;*.*&#x37; − &#x30;*.*&#x33;) = 60%

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywOhNXUEKlhOORJ%2F19.png?generation=1631954138279814\&alt=media)

2\. Update of the Exponential Moving Average

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywQu6WZBXUkPdnz%2F21.png?generation=1631954138268544\&alt=media)

3\. Positive voter turnout: = 88%

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywPqeX-xTFe8ZI-%2F20.png?generation=1631954138262977\&alt=media)

4\. Proposal approved

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywRfPQxQ5xrI1WR%2F22.png?generation=1631954138290049\&alt=media)

### Voting example 2/2

To illustrate this process, let us assume a total of 100 active voting rigths managed by bakers and a Voter Turnout EMA of 75%, and then 55 votes (Yay, Nay, and Pass) during the Exploration period.

#### Example 2 :

1\. Quorum = &#x30;*.*&#x33; + 75% \* (&#x30;*.*&#x37; - &#x30;*.*&#x33;) = 60% <br>

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywTsp6F1O77E_2Z%2F24.png?generation=1631954138293402\&alt=media)

2\. Update of the Exponential Moving Average

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywUhiVcAiWVK9ZQ%2F25.png?generation=1631954138265549\&alt=media)

3\. Proposal rejected: Although the Yays have reached the number required for a supermajority, the proposal is rejected as the Quorum has not been reached. We must therefore go back to the initial proposals stage.

## Third period - Cooldown

### ![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywXj62bOaMdECy5%2F28.png?generation=1631954138265400\&alt=media)Third period - Cooldown (Cycles 11-15)

If a proposal is accepted by a supermajority during the Exploration period, the Cooldown period starts. This period replaces the previous Testing period that was underused since most of the testing happens on a dedicated testnest.

## Fourth period - Promotion

### ![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1yw_or5uAYF3Ikh3%2F31.png?generation=1631954138342087\&alt=media)Fourth period - Promotion (Cycles 16-20

At the end of the Cooldown period, the network decides whether or not to adopt the amendment proposal, based on off-chain discussions and its behavior on the test network.

The same concepts of both the Quorum and the supermajority are applied here. After the vote, the Voter Turnout moving average is updated again.

The version of the protocol integrating the amendment is then disseminated by the network and transmitted to the nodes which are automatically and openly updated.

## Fifth period – Adoption

### ![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywdqfMZszidBP4R%2F35.png?generation=1631954138273879\&alt=media) Fifth period – Adoption (Cycles 21-25)

During the adoption period, bakers update their infrastructure. At the end of this period, the new protocol will be adopted. This period is dedicated to helping validators to migrate on the new Mainnet version.

## End of process

At the end of the Adoption period, a new Proposal period starts.

The person whose proposal is ultimately adopted as a protocol amendment has the merit of having evolved the Tezos blockchain, and **is compensated in tez by an amount determined beforehand in the source code of their proposal**.

## Record of amendments

1. May 2019, **Athens** amendment :
   * Reduced roll size for bakers (from 10,000 to 8,000 tez)
   * Increased gas limit per operation and per block
2. October 2019, **Babylon** amendment:
   * Adjusted “emmy+” consensus algorithm
   * New features in a low-level language (Michelson) for smart contracts, adjusted cost of gas
   * Adjusted formula for updating Quorum (30% *≤* Quorum *≤* 70%)
3. March 2020, **Carthage** amendment:
   * Increased gas limit per operation and per block
   * Improved formula for calculating compensation for baking
4. November 2020, **Delphi** amendment:
   * Reduced storage costs by 4
   * General recomputation of the gas costs
5. February 2021, **Edo** amendment:
   * Inclusion of Sapling protocol
   * New Michelson data structure: tickets
   * New Michelson functions, especially hash functions SHA3 and Keccak
   * Updating of the amendment protocol :
     * A fifth period to allow bakers to update their infrastructure: The adoption period
     * Reduction of the overall time of each period, from 8 to 5 cycles
6. May 2021, **Florence** amendment:
   * Increase maximum operation data size
   * Depth-First execution order
   * Performance optimization
   * Updating of the amendment protocol: testing period is now replaced by a cooldown period
7. August 2021, **Granada** amendment:
   * Emmy \*, new consensus algorithm:
     * smaller block times
     * faster finality
   * Liquidity Baking, a small amount of tez from each block issued to provide liquidity to the tez/tzBTC pair
   * Decrease in gas consumption
8. December 2021, **Hangzhou** amendment:
   * Timelock&#x20;
   * Michelson on-chain views
   * Global Constants&#x20;
   * Cache Context storage flattening
9. April 2022, **Ithaca2** amendment:&#x20;
   * Tenderbake, a new consensus algorithm
   * Backend storage improvements
   * Reduction of the amount of Tez required to become a baker (from 8,000 to 6,000 Tez + no more notion of rolls)&#x20;
10. September 2022, **Kathmandu** amendment:
    * Smart contract optimistic rollups (SCORU) enabled on bleeding edge testnets (Mondaynet and Dailynet).
    * Pipelined validation of manager operations, increasing throughput, without compromising the network’s safety. This ongoing project reduces the need to fully execute time-expensive operations (like smart contract calls), before they reach a baker, resulting in a faster propagation of new blocks and operations across the network.
    * Improved randomness with integration of Verifiable Delay Functions (VDF) into the protocol’s random seed generation, reinforcing the security of the rights allocation mechanism.
    * Support for tailored governance for permanent testnets will reduce the need for user-activated upgrades in Ghostnet. After a protocol proposal is elected in the Promotion period on Mainnet, the Oxhead Alpha team will be able to centrally upgrade Ghostnet.
    * Event logging in Michelson smart contracts enabling DApps developers to send on-chain custom messages in order to trigger effects in off-chain applications (wallets, explorers, etc.).
    * A new operation for increasing paid storage of a smart contract allowing DApps developers to pay the storage fees on behalf of their users.

## On-chain governance reduces the risks of hard forks

The development of Bitcoin has shown that hard forks are often necessary in order to make changes to a protocol.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywmIxKqxAd2wjCl%2F44.jpeg?generation=1631954138357026\&alt=media)

There are risks involved here, as two chains can co-exist if a consensus cannot be reached within the community, which can then lead to operational risks for some blockchain projects.

However, whenever a critical bug is found, the protocol must be updated urgently – for Tezos just as for Bitcoin. However, on the Tezos blockchain, this type of situation has never led to a chain splitting into two, as this type of change is always driven by consensus.

## How to vote?

It is possible to vote by using the Tezos client :

To know the current period :&#x20;

`$ tezos−client show voting period`

To vote for the proposal whose hash is ***\<proposal >*** with the address ***\<delegate >***:

`$ tezos−client submit ballot for <delegate> <proposal > <yay | nay | pass>`&#x20;

## Summary diagram of the amendment process

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mjs1DdKC4I-GmjEmwlj%2F-Mjs1ywrbkdT6H2UxriY%2F49.png?generation=1631954138408732\&alt=media)


# Tickets (DEPRECATED)

## PLEASE REFER TO: <https://opentezos.com/tezos-basics/tickets>

### Introduction

The Edo Amendment, adopted by the community in February 2021 introduced an improvement to the Michelson smart contract language, a new data type: **tickets**.

A speciﬁc feature of tickets is that they contain the address of the contract they come from - this information is immutable and cannot be duplicated; this ensures that a contract never has more tickets bearing its address than those it has created itself.

A ticket contains three elements in its structure:

1. **A source**: the address of the contract it comes from.
2. **An identiﬁer**: an element of any comparable type. This can be used to manage several types of tokens or to store information.
3. **A value**: this value is equivalent to a quantity that distinguishes fungible and non-fungible tokens. In the case of fungible tokens, this value is greater than 1, but divisible into single units. In the case of non-fungible tokens, this value is always equal to **1***.*

Tickets allow many use cases, in particular, it helps to simplify tokenization contracts by providing token materialization. It also ensures that access rights can be transferred simply outside of a given contract, i.e. without calling it or changing its storage.

## Instructions

There are four Michelson instructions that enable interactions with tickets:

* **`TICKET`**: to create a ticket with an identiﬁer and a value; the source address is that of the contract that initiated the creation.
* **`READ_TICKET`**: shows information about a ticket (address, identiﬁer, and value), while preserving it on the Michelson stack¹.
* **`JOIN_TICKETS`**: combines two tickets with the same source and identiﬁer into a new ticket; its value will be the sum of the values of the original tickets.
* **`SPLIT_TICKET`**: reverse of the `JOIN_TICKETS` operation; splits one ticket into two tickets with the same identiﬁer such that the sum of their values is equal to the value of the original ticket.

**\[1]:** Please note that the majority of Michelson functions destroy the elements that they use on top of the stack, that's why you must first duplicate them (with th&#x65;**`DUP`**&#x69;nstruction). `READ_TICKET` is an exception to this rule as it is not possible to duplicate a ticket.

## Identiﬁers

In a Ticket structure, the ﬁeld called identiﬁer is not only useful to identify a ticket; it can also be used to store information that may be used by the contracts that will read the ticket.

For example, we can:

* manage an arbitrary number of different tickets on the same contract by changing the identiﬁer;
* have a piece of data that are veriﬁed by a contract in the same way that signatures are;
* give a piece of data used as a date or, alternatively, an activation date thanks to a timestamp.

By extending comparable types, it is possible to aggregate or combine these uses.

It is important to consider that the identifier type depends on the use that will be made of the ticket, and that two tickets of the same type will not necessarily have the same functions depending on the contracts in which they will be used.

Please note that since the Edo protocol, comparable types are pairs of two comparable types, optional comparable types, and unions of two comparable types.

## Use cases

### Tokenization

**Tickets enable tokens of a tokenization contract to be materialized.** In this way, they can be manipulated outside the original contract; this allows them to be exchanged against other tickets coming from different contracts.

In some cases, tokens may be stored entirely in the form of tickets and circulate outside of the contract. This works for fungible or non-fungible assets. This is particularly the case when tokens are used for delivery versus payment, and where it is not necessary to know who holds the tokens until they are sent back to the contract to be destroyed, and for all legal intents and purposes.

Other contracts will be hybrid. This is the case for contracts representing video game items: Given that it is necessary to be able to know at any time whether a player holds an item, the contract must keep the information within its own data. **However, it is possible to allow a player to withdraw one of their items temporarily, for example, to exchange them or prove to another contract that they have it.**

### Privilege management

**Tickets also enable a usage privilege to be granted to a user.** We can thus ensure that this user is the only one able to use certain properties. Unless this user decides to transfer his token, we can therefore consider that by giving them (or selling them) the ticket, they are also selling the contract and associated privileges. This can facilitate cases where contracts are exchanged or sold.

Privilege management by ticket also enables users to choose the way in which they retain their ticket. For example, they can use a multi-signature contract such that the contract is controlled by several users.

We can also consider that this contract has tickets to access several contracts.

#### It is therefore possible to transfer or acquire access rights to a contract, such that a new user can choose the way he wishes to keep his ticket.

### Votes

#### Tickets can also allow voters to make decisions or to validate transactions.

A contract could ensure that transfers are performed according to the votes of a committee: Each time a transaction is proposed, members vote with their tickets.

It, therefore, becomes possible to consider cases of proportional voting in which participants do not have the same weighting (according to the number of tickets held).

Members can then sell all or some of their rights or, on the other hand, buy more units.

#### It is possible in this context to organize voting for a purpose external to the blockchain, such as elections or business decisions.

### Authentication

Authentication by using tickets entails allowing each user to choose their protection method. They just need to register the contract address they use to generate authentication tickets, and validate transactions that concern them, provided that they have a ticket from this contract as if this was a signature.

The main benefit of this system is that the contract may have its own ticket-issue management and may, for example, be a multi-signature wallet, a time-based contract, or a manager contract. Furthermore, the same contract may be used to generate the authentication tickets of several other contracts. It will also be possible to make a suitable contract that does not associate the same security with different functionalities.

Lastly, the main advantage of this method lies in its non-replicability. Indeed, if we request a ticket with a value of 1 and this ticket is used at the time in another application, this ticket cannot be reused. This enables several tickets to be issued without having to worry about the order in which they will be executed.

It is also possible for the authentication contract to create a ticket with a value greater than 1. This value will actually set the maximum number of uses for this authentication.


# Sapling - Make conﬁdential transactions on Tezos (DEPRECATED)

## PLEASE REFER TO: <https://opentezos.com/tezos-basics/sapling>

## Introduction

The majority of public blockchains allow anyone with access to the Internet to monitor all operations on the chain.

Moreover, by knowing a user’s address (from a payment, for example), anyone can:

* read the balance of his account
* see incoming and outgoing transactions since the account creation, as well as the amounts sent and recipients.

These aspects may be [incompatible](https://www.eublockchainforum.eu/sites/default/files/reports/20181016_report_gdpr.pdf) with the protection of users’ privacy **¹**, as well as the right to be forgotten **²**.

To remedy this situation, Tezos offers contracts based on the **Sapling** protocol. This protocol provides both **the protection of users’ privacy and transparency with regard to the regulators**.

**\[1]:** On this subject, in the European Union, the [GDPR](https://eur-lex.europa.eu/eli/reg/2016/679/oj/fra) regulates the protection of natural persons with regard to the processing of personal data and the free circulation of such data.

**\[2]:**  The [right to be forgotten](https://www.cnil.fr/fr/le-droit-leffacement-supprimer-vos-donnees-en-ligne) allows an individual to request the removal of information about them and that may harm them.

## Deﬁnition of the main concepts

* **Shielded transaction:** A transaction is said to be shielded when an external observer cannot ﬁnd out any data from it (including the amount, the recipient, and the sender - In practice, an external observer can see the sender if they call the contract.).
* **Transparent transaction:** A transaction is said to be transparent when it is not shielded.
* **Shielded pool:** A shielded pool is a set of tokens whose number can be ﬁnd out, but whose internal transactions are shielded.
* **Smart-contract:** A smart contract is a computer program whose interactions are described by code and data. It is possible to call a smart contract - its code determines its behavior, depending on the functions called within the contract.

## Key management

Sapling is a cryptographic protocol that allows shielded transactions to be conducted, while ensuring that trusted third parties can view the transactions. Three elements need to be identiﬁed for this to happen:

* The **expense** key, which should be kept secret and is used to sign transfers.
* The **viewing** key, which is derived from the expense key and allows transactions issued or received to be viewed (it is possible to create viewing keys that allow only transactions issued or transactions received to be viewed).
* Addresses that are used to receive transactions are all derived from the **expense** key. We can derive as many addresses as we want, so, two different users will not be able to know whether or not they are making a transfer to the same person.

Sapling is a cryptographic protocol that uses elliptic curves ([Bls 12-381](https://eprint.iacr.org/2016/1102.pdf) and [jubjub](https://bitzecbzc.github.io/technology/jubjub/index.html)).

## Demonstration

### Example without monitoring of the transaction by a third party

In this example, Alice wants to send 8 tez to Bob, without anyone else knowing.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2a2mh9rhPrMKWxWRM%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-24-26.png?alt=media\&token=feac4763-d3c5-4632-9597-8e25ad6cd010)

1\. Alice begins by creating tokens in the shielded pool, sending 8 to the contract.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2aJv2slMoiZ-GcLCE%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-24-56.png?alt=media\&token=602038d1-99d4-47bd-abba-971ddb1003db)

2\. Bob derives an address from his view key and sends it to Alice.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2afVIpuJDrkhmpyf0%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-26-59.png?alt=media\&token=bd7d0091-313a-4401-acf7-8298a6571a07)

3\. Alice sends Bob the tokens through the shielded pool.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2b2Jqe1ScA4ehZrcW%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-28-19.png?alt=media\&token=6836d82f-9ae8-45e8-afc1-9161649a940f)

4\. Bob can then claim the tokens that he has received.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2bFpYzIw394mlXtA2%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-29-41.png?alt=media\&token=dc15d2c7-66d3-431e-8784-0757eefb4ece)

5\. The contract itself then sends 8 tez and withdraws the corresponding tokens from the shielded pool.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2bZ7hFRIEmKEwIVJ7%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-30-57.png?alt=media\&token=7b985f91-adad-4d74-a713-4f43f3c8c5b7)

In this scenario, someone could notice that Alice is sending 8 tez and that Bob is also withdrawing 8 tez. This might make it possible to guess that there has been a transaction between the two, especially if the deposit and the withdrawal are temporally close.

Ideally, Bob should not withdraw his tokens and should use them to pay transactions.

To increase his anonymity, Bob can ensure that he never interacts with the contract to deposit or withdraw tez. This example is a simple case of the use of Sapling.

It is also possible to allow a third party, a regulator for example, to control all transactions of the Sapling contract.

### Example with monitoring of the transaction by a third party

In this scenario, only Chris’ address can send transactions (apart from deposits and withdrawals) to the shielded pool:

1\. Alice and Bob identify themselves to Chris and send him their respective viewing keys. (This may have been done before the current transaction.)

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2cgXJ_afUMzGfmU4g%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-35-57.png?alt=media\&token=33e72beb-3d1a-4c40-bb58-1dc343d8def6)

2\. Alice creates tokens in the shielded pool, sending 8 tez to the contract.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2d33AmTBB1YRvkuAK%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-37-35.png?alt=media\&token=9bf3d382-9ed0-403f-819f-3a2edcc7bca4)

&#x20;3\. Bob derives an address from his viewing key and sends it to Alice (Alice could also address it to Chris because he has access to Bob’s key and so may also be able to derive an address from it.).

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2dsDFZutXueoQqQVF%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-41-10.png?alt=media\&token=a0015d4e-22d0-4190-a632-9a982ebb8d0c)

4\. Alice forges a transaction of 8 tez to Bob and sends it to Chris.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2ePgUZOnPl8LH2oFx%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-43-32.png?alt=media\&token=0d8a8db3-1541-4fc8-8070-023e93c14c28)

5\. Chris notes, from Alice’s keys, that it relates to a transaction coming from Alice to an address.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2e_PcUhPEydaakW5X%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-44-10.png?alt=media\&token=b42dbe6d-0c3d-445e-951d-936619f0ad43)

6\. Chris can then verify, using Bob’s key, that this address is derived from Bob’s key.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2el9yKoE16v1jsy75%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-45-03.png?alt=media\&token=26e21d23-0dec-4c70-8497-53edcb920331)

7\. Both keys show Chris the amount. He then knows that it relates to a transaction of 8 tokens from Alice to Bob.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2eyrbbSgCZH02ewmB%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-45-59.png?alt=media\&token=0de3e61f-a49c-43f4-a77c-54dfbbcc1b82)

8\. He decides that this transaction is lawful and sends the transaction to the contract.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2fEY5BWzv9Pwj2nqj%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-47-10.png?alt=media\&token=494660c5-77a9-4119-bdb2-973714c4a4e9)

9\. Bob can then claim the tokens that he has received and receive his 8 tez.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2fRUXQf977Gdz-x7J%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-48-00.png?alt=media\&token=c1803369-c17f-4950-88f2-5a204dd71a13)

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2Y2AXjfya_eVIjnHx%2F-Mk2fh-zaqzzzSz_PFKa%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-49-00.png?alt=media\&token=8622683c-21de-429e-ba6a-967f504aa6e6)

This example shows the case where Chris deals with validating the compliance of operations, potentially because he is answerable for what happens in the contract, or even because he is responsible for protecting Alice (and the other members of the contract) against potentially fraudulent transactions. Furthermore, if he decides that an operation is not valid, he may decide to contact Alice to tell her about it and ask her for more information regarding this transaction, or simply to verify that she has not had her wallet stolen and that she is indeed the originator of this transaction.

Chris is not necessarily a human; he may also be a simple secure oracle**³** that has viewing keys and automatically conducts transactions where the parties are known.

In both examples, we have assumed that the tokens represented tez. This is not mandatory and we might suppose that the tokens represented any other fungible asset (ﬁnancial assets, raw materials, etc.). In this case, the regulator could also manage the deposits and withdrawals. There would no longer be any direct interaction between the current asset and its representation on the contract (as we could do with tez). The contract **might then have an evidential value** in a dispute.\
\
**\[3]:** An oracle is a program external to the blockchain, generally standalone, the role of which is to make calls to a smart contract to give it orders according to parameters that the smart contract cannot or does not need to control.


# Formal Verification

## Introduction

The Tezos blockchain was designed to ensure the required security and compliance of the code, particularly for high-value use cases such as the issue and management of ***Security Tokens*** ***¹***, ***stablecoins*** **²**, or even for the freezing of funds in a context such as ***liquidity pools*** **³**.

**Michelson**, the native smart contract language of the Tezos blockchain, facilitates **formal verification** by providing guarantees; this is a methodology currently used in critical environments such as the aerospace, nuclear, and semi-conductor industries. This methodology consists in defining the specifications of a computer code and in proving that its execution indeed does what it was designed to do.

Any contract deployed on a public blockchain is almost impossible to rewrite or remove from the chain history. Consequently, for certain applications, unit tests are insufficient for ensuring that they have the desired operation. It is therefore essential to prove the correct operation of these contracts via formal verification.

In this document, we shall explain what formal verification of smart contracts is and illustrate it with Mi-Cho-Coq, the formal verification tool developed by Nomadic Labs.

From that point, it may no longer transfer its funds. Nevertheless, it receives LP tokens, which represent its part of the pool. It may, when it decides to do so, recover its funds. It also receives the exchange fees paid by the service users.

**\[1]:** A security token is the representation of a financial security (for example, a company share or real estate asset) by a token.

**\[2]:** A stablecoin is a digital asset class that is designed to offer price stability compared to another asset, often a fiat currency (euro, dollar, etc.). [**LUGH**](https://fr.lugh.io/) project is the first euro stablecoin based on the Tezos blockchain. Different price stabilization mechanisms are used depending on the project, such as fund escrow or algorithmic stabilization, etc.

**\[3]:** A Liquidity Pool (LP) is a smart contract in which two or more tokens are gathered, with the aim of allowing exchanges between the different assets present inside the pool. A **liquidity provider** is a token holder that sends its funds to the pool in order to provide liquidity.

## Definition of the main concepts

**Smart Contract:** a computer program that is deployed on the blockchain. On Tezos, these programs are written or (when they are written in a different language from Michelson) compiled down in a language proprietary to Tezos: Michelson. This language was designed to facilitate the application of formal verification methods.

**Specifications of a code:** Description of tasks that a computer code has to implement in a particular environment. They bring together all requirements to be met for this code, such as its behavior and the results expected when it is executed.

**Unit tests:** Process that, by a succession of tests, verifies the correct operation of a computer program. It compares the specification of a code with its output results, for a certain amount of data provided as input.

**Formal logic:** Deductive mathematical verification that calls on a so-called mathematical logical reasoning, which uses a vocabulary and particular symbols as well as logical connectors.

[**Coq**](https://coq.inria.fr/)**:** Formal proof assistant that provides a formal language for writing mathematical definitions, executable algorithms, and theorems with a semi-interactive environment for developing proof verification. A prominent tool that is well established in code verification, particularly in critical areas.

**Mi-Cho-Coq:** Formal verification library for smart contracts written in Michelson. It enables a Michelson script to be modelled in a mathematical model on which the reasoning that establishes its compliance with a specification is possible.

## Motivations

During the design of smart contracts, it is important to ensure that they are doing what they were designed to do.

Owing to the data that they handle and because, once deployed, you can no longer simply change the code, it is necessary to have guarantees for the security of the code: in other words, that its execution behaves as predicted by the specifications.

In fact, in certain areas where there is a low margin for error, a code that reacts unpredictably may be very costly and incur heavy human and financial consequences.

Ensuring that a smart contract is behaving correctly is not a trivial task. A standardized good practice is to carry out unit tests. In reality, such tests only cover a finite number of cases. Consequently, how do we ensure that a program matches its specification and is mathematically correct?

This is where formal verification comes in. All methods and tools that address this issue constitute formal methods. It involves methods based on a mathematical representation of a program that allows reasoning about it. They are ranked according to the level of guarantees that they provide: from bug detection (tests, PBT testing, model-checking, etc.) to code correction and even the generation of correct code by construction.

The idea then is to find a mean of **translating these smart contracts** into a language **that will be used in a proof assistant** (this is where Coq comes in). Before their deployment, certain smart contracts may be considered critical, requiring a detailed audit. In this case, in addition to unit tests, they can be formally proven, using the Coq proof assistant.

It should be noted that there are other tools for verifying smart contracts on the Tezos blockchain. The main ones include:

* [Why3](http://why3.lri.fr/): a program verification platform that consists in generating a series of proof obligations for each property of the specification. This tool is particularly used by the [Archetype](https://archetype-lang.org/) smart contract language.
* [K-Michelson](https://runtimeverification.com/blog/formal-verification-framework-for-michelson/): Michelson interpreter developed by Runtime Verification, which develops a generic language specification tool, [K-framework](https://kframework.org/).

## Some syntactical elements of the Coq language

#### Coq language:

* Boolean type definition:

&#x20;`Inductive  bool : Type :=` \
&#x20;    `| true`\
&#x20;    `| false.`

* Definition of a function that returns the denial of a Boolean:

`Definition negb (b:bool) : bool :=` \
&#x20;    `match b with`\
&#x20;    `| true => false`\
&#x20;    `| false => true`\
&#x20;    `end.`

### A few syntactical elements of the Coq language

Here is an example of proof that may be implemented:

`Example test_orb1: (orb true false) = true.` \
`Proof.`\
`simpl. (* ===> true = true *)`\
`reflexivity. (* ===> no more subgoals *)`\
`Qed.⁴`

In the example above, it involves showing that *true or false* equals *true*. The first line matches the one that we want to demonstrate. The lines between the *Proof* and *Qed* keywords constitute the proof.

All words between Proof and Qed are called **tactics**. These are functions that allow us to make our demonstration step by step.

All tactics are referenced at: [https://coq.inria.fr/refman/proof-engine/tactics.html#coq:tacv.destruct-eqn](https://coq.inria.fr/refman/proof-engine/tactics.html#coq%3Atacv.destruct-eqn)

**\[4]: QED** = quod erat demonstrandum; what was to be shown (in Latin).

## Proof creation using Mi-Cho-Coq

As Coq is a proof software that has its own syntax; the difficulty has been in finding a way to translate the Michelson code into Coq.&#x20;

Mi-Cho-Coq is the library that allows you to do this. When you wish to prove a smart contract written or compiled down in Michelson, you must use this library and import the code that you wish to formally prove. The syntax to be used at the start of the file containing the proof is as follows:

`Require Import Michocoq.macros. Import syntax.`\
`Require Import Michocoq.semantics. Require Import Michocoq.util.`\
`Import error.`

For a more technical understanding of the operation of Mi-Cho-Coq, this tutorial can be viewed: [https://](https://gitlab.com/nomadic-labs/mi-cho-coq/)[gitlab.com/nomadic-labs/mi-cho-coq/](https://gitlab.com/nomadic-labs/mi-cho-coq/)

## Execution of a simple proof using Coq software

We shall execute the proof of: **Example test\_orb2** (Example keyword below) using the Coq proof assistant.

![Proof execution with the Coq software 1/3](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mk2glTNNTC6CfRHCiky%2F-Mk2hDY32dZNb80Udwat%2F18.jpeg?generation=1632149761249139\&alt=media)

![Proof execution with the Coq software 2/3](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mk2glTNNTC6CfRHCiky%2F-Mk2hDY5iLj2QLX83w03%2F20.jpeg?generation=1632149761247898\&alt=media)

![Proof execution with the Coq software 3/3](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mk2glTNNTC6CfRHCiky%2F-Mk2hDY77uEyCC9eEemC%2F22.jpeg?generation=1632149761252313\&alt=media)

End of proof.

## Limitations

Here are the main limitations of formal logic:

Limitation of a general nature:

* It is **difficult to formally define the expected behavior of a contract**, and a proof depends on the quality of the formal definitions associated with it. Consequently, a poorly defined contract may, even if it has been formally proven, have undesirable behaviors.

Limitations specific to Mi-Cho-Coq:

* A formal proof of a smart contract **does not evaluate possible problems related to its Gas consumption** (Unit of measurement of the cost of executing a smart contract in time and computer resources. A price in tez will correspond to a quantity of Gas.). Consequently, a dedicated assessment to evaluate the cost of a smart contract is relevant to complement the formal logic proofs.
* Mi-Cho-Coq allows you to show a contract’s calls but **not on a series of several independent calls**. However, other tools allow you to do this; this is, for example, the case of [Concert](https://github.com/AU-COBRA/ConCert) (Certification tool for smart contracts in Coq.).

## Conclusion

Mi-Cho-Coq is a tool that allows you to obtain certain guarantees with regard to the execution of a smart contract deployed on the Tezos blockchain. In fact, when it involves creating and deploying smart contracts, it is essential to verify that the code meets the specification that characterizes it.

Nowadays, many smart contracts deployed with prior audit and unit tests have shown serious flaws, particularly in the context of ***DeFi*** **⁵**, which increases the risks of financial losses if a flaw is detected. During the creation of smart contracts, in addition to unit tests, formally verifying the program created, using a proof software helps to reduce considerably the possibility of vulnerabilities and undesirable behaviors of the code.&#x20;

The Tezos blockchain and its code were designed and developed in order to obtain a high level of code security guarantees, either through technological choices or its architecture. In particular, its native Michelson smart contract language facilitates formal verification. This is why it is generally easier to formally prove contracts on the Tezos blockchain, compared to other blockchains whose smart contract languages do not facilitate formal verification.

Mi-Cho-Coq has, in particular, helped to formally verify the standard of [FA1.2](https://gitlab.com/tzip/tzip/-/blob/master/proposals/tzip-7/tzip-7.md) tokens on Tezos, Dexter 2 (version 2 of the decentralized Dexter exchange platform), [Liquidity Baking](https://midl-dev.medium.com/liquidity-baking-in-granadanet-how-it-works-e60c82bee6f1) (a single-asset decentralized exchange offered by the Granada amendment), or even the [multisignature contract](https://gitlab.com/tezos/tezos/-/blob/master/tests_python/contracts_010/mini_scenarios/generic_multisig.tz) used by the Tezos client.\
\
**\[5]:** Decentralized Finance - All financial applications based on smart contracts. Some of these application cases are similar to so-called traditional finance such as loans.


# Spin up a Tezos baking node (DEPRECATED)

This module will guide you through the complete installation and setup of your own Tezos baker on Linux, using Docker images, PPA packages, or by building from source.

## 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)**


# Prepare your baker for Ithaca2 (DEPRECATED)

Ithaca2 is one of the most important amendments so far. To continue baking after activation, bakers need to upgrade their infrastructure before the end of the adoption period.

This tutorial provides practical commands to successfully upgrade a baker's infrastructure. As a reminder, we recently wrote an [**article**](https://research-development.nomadic-labs.com/all-hands-on-deck-for-tenderbake.html) describing the breaking changes regarding Ithaca2 (<mark style="color:red;">`Psithaca2`</mark>) and its new consensus algorithm: [**Tenderbake**](https://research-development.nomadic-labs.com/tenderbake-has-been-injected.html).&#x20;

*After Ithaca2 is activated, it will be technically impossible to bake without `Octez v12.2` or later.*&#x20;

This version contains all binaries (baker and accuser) necessary for Ithaca2 and the associated testnet.&#x20;

### **Changes regarding the baker's signing scheme**

With Tenderbake, endorsement operations now consist of a level, a round, a slot, and a payload hash. A Baker can emit **at most one endorsement per round, but it is allowed to emit more endorsements per level**. The former high-water mark mechanism used by the signer has been adapted accordingly.\
\
The [tezos-signer](https://tezos.gitlab.io/user/key-management.html#signer) for previous protocols signed messages with the following format:

&#x20;`<magic_byte><chain_id><block|endorsement>`

&#x20;Now, they have the following shape:

`<magic_byte><chain_id><block|preendorsement|endorsement>`,

where the magic byte has changed from `0x01` (for blocks) and `0x02` (for endorsements), to `0x11` (for blocks), `0x12` (for preendorsements), `0x13` (for endorsements).

The signer is authorized to sign whenever the level is strictly higher than the previous level, or the level is the same, but the round is strictly higher.\
\
Octez v12.2 contains the updated signer. **Bakers using a Ledger Nano must upgrade their Ledger's software** (see [instructions](#upgrading-the-ledger-nano)).  Any other custom solution must be adapted to the signing logic.&#x20;

Likewise, if you use `tezos-signer`don't forget to update, and relaunch it.

### **Upgrading to v12.2 using released binaries**

See our official technical documentation [here](https://tezos.gitlab.io/introduction/howtoget.html#installing-binaries).&#x20;

### **Upgrading to v12.2** using Docker

#### *Without* Docker Compose

If you launch your node with a simple docker command, you should use the v12.2 image and the following image to run your node:

```bash
docker run -d --name container_name tezos/tezos:v12.2 tezos-node --rpc-addr 127.0.0.1:8732
```

Then you can, for example, access the created container and launch your Ithaca2 daemons:&#x20;

```bash
docker exec -it container_name sh
#import your baking key

#The baking daemon
tezos-baker-012-Psithaca --endpoint http://127.0.0.1:8732 run with local node /run/tezos/node/data/

#The accuser daemon
tezos-accuser-012-Psithaca --endpoint http://127.0.0.1:8732 run


```

#### ***With*****&#x20;Docker Compose**

Docker Compose users only need to change the docker image and relaunch the containers to update Octez:

`...`\
`services:`\
&#x20; `[type]-node:`\
&#x20;   `image: tezos/tezos:v12.2`\
`...`

Afterward, launch your baking/accuser daemons as you normally do.

### **Upgrading to v12.2  building from sources**

**Note:** it requires basic knowledge of the OPAM package manager and the OCaml packages workflow.

*Step 1:* Access your tezos repository and execute the following commands:

```bash
git fetch
git checkout v12.2
rm -rf _opam _build
make build-deps
eval $(opam env)
make
```

*Step 2:* Launch the binaries

Note, that there is no endorser daemon anymore. The baker daemon performs both baking and endorsement operations.\
\
Launch your baker:

```bash
tezos-baker-012-Psithaca run  #with optional arguments
Global options:
  -d --base-dir <path>: client data directory (absent: TEZOS_CLIENT_DIR env)
  -c --config-file <path>: configuration file
  -t --timings: show RPC request times
  --chain <hash|tag>: chain on which to apply contextual commands (possible tags are 'main' and 'test')
  -b --block <hash|tag>: block on which to apply contextual commands (possible tags are 'head' and 'genesis')
  -w --wait <none|<int>>: how many confirmation blocks before to consider an operation as included
  -p --protocol <hash>: use commands of a specific protocol
  -l --log-requests: log all requests to the node
  -A --addr <IP addr|host>: [DEPRECATED: use --endpoint instead] IP address of the node
  -P --port <number>: [DEPRECATED: use --endpoint instead] RPC port of the node
  -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node.
  -m --media-type <json, binary, any or default>: Sets the "media-type" value for the "accept" header for RPC requests t

```

And the accuser:

```bash
tezos-accuser-012-Psithaca run
```

*Bakers using a Ledger hardware wallet for operation signing will need to upgrade the Tezos Baking app to v.2.2.15 or later. See instructions below.*

### **Upgrading&#x20;*****Ledger Nano software***

:warning: *Only the Tezos Baking app `v2.2.15` or later is compatible with Ithaca2 (due to the changes imposed by the adoption of the Tenderbake consensus algorithm). It is however also compatible with the current protocol version, so it is safe (and advisable) to upgrade now.*

Henceforth, this is the list of tags supported by the Ledger apps:

```
EMMY_BLOCK                     0x01
EMMY_ENDORSEMENT               0x02
TRANSFER                       0x03
TENDERBAKE_BLOCK               0x11
TENDERBAKE_PREENDORSEMENT      0x12
TENDERBAKE_ENDORSEMENT         0x13
```

To upgrade, bakers will need to

* Exit the Tezos Baking app;
* Upgrade the Tezos Wallet and Tezos Baking apps using the Ledger Live application;
* Authorize the Ledger to bake for their specific key;
* Relaunch the Baking App.

*To avoid missing assigned baking/endorsing slots, owning a second Ledger Nano can be useful for signing operations while the first Ledger Nano is being upgraded.*

The following example uses a Ledger Nano S.

**Step 1:** Exit *Tezos Baking* application and launch Ledger Live.&#x20;

On the bar at the bottom left, access the *Manager* section and search for Tezos. Upgrade both the **Tezos Wallet** and **Tezos Baking** applications to <mark style="color:red;">`version 2.2.15`</mark>.

*If you don't see the Tezos Baking app, you may need to activate Ledger Live's* [*developer mode*](https://developers.ledger.com/docs/live-app/developer-mode/)*.*

![Ledger Live application](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2F3gPrQGsYjYPtX4oauCyD%2FCapture%20d%E2%80%99%C3%A9cran%20de%202022-03-09%2016-36-30.png?alt=media\&token=939f0584-0b6d-415b-9bfd-fcf3b8b45552)

\
**Step 2:** Import your Tezos baking address by clicking on *Add account*, and follow the steps to add your Tezos account.

![Add account](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2Fwlvt3gdR09u3rQ4y2kft%2FCapture%20d%E2%80%99%C3%A9cran%20de%202022-03-09%2016-46-59.png?alt=media\&token=5b39719e-dd75-46f9-8ef8-aaf93b4f750c)

![Choose an account to import](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FCrpaTF2kjWCFbLDsPH8e%2FCapture%20d%E2%80%99%C3%A9cran%20de%202022-03-09%2016-47-24.png?alt=media\&token=d327957b-28cb-42f3-988c-2663b8186e16)

![Account successfully added](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FhlUmf7lWhTxVDALXvXVr%2FCapture%20d%E2%80%99%C3%A9cran%20de%202022-03-09%2016-47-34.png?alt=media\&token=dea44f1c-b85c-4763-939f-8a8389afff6e)

\
**Step 3:** Before launching the baker and accuser daemons, you need to re-authorize your Ledger to bake for your baking key.

```
tezos-client setup ledger to bake for <account-alias-or-ledger-uri> #it is possible to provide a watermark with --main-hwm <HWM>
```

**Step 4:** Your Nano S is now upgraded, and you are ready to bake on Ithaca2. Don't forget to launch the Tezos Baking app!\
\
Happy baking!


# Run a persistent baking node (DEPRECATED)

Want to make your baking infrastructure more resilient to electricity and internet cut-offs? Let's use Linux service files to keep those Tezos binaries running.

## **PLEASE REFER TO:** [**https://opentezos.com/baking/persistent-baker**](https://opentezos.com/baking/persistent-baker)

Running a Tezos baking node is quite simple and [we have different options available](https://docs.nomadic-labs.com/nomadic-labs-knowledge-center/baking-creating-blocks-on-the-tezos-blockchain#options-for-baking).

But how can we make sure that our infrastructure is persistent and resilient enough so that electricity or internet cut-offs wouldn't have too much impact on our setup?&#x20;

The following tutorial deep dives into the subject and shows how to create persistent Tezos services.

## Running Tezos binaries as services

One advantage of setting up the node and baker daemons as services is that it can automatically relaunch the daemons if they stop working, or when the machine restarts. No additional action is needed from the user side.

*(Note that systems relying on a Ledger hardware wallet will need to have the PIN input again after a power failure. In these cases only using a* [*UPS*](https://en.wikipedia.org/wiki/Uninterruptible_power_supply) *can ensure a truly persistent system.)*

Systemd is a set of system software components necessary for Linux operation. In particular, it exposes  a set of daemons: `systemd`, `journald`, `networkd`,  and`logind`. For each system, a set of utilities and commands are available to the user like `systemctl`, `journalctl`, `loginctl`, etc.\
In our case, we will take advantage of this powerful Linux tool to build Tezos binaries that keep running over time.\
\
**Pre-requisites:** Install and compile the Tezos Octez suite from scratch (see: <https://tezos.gitlab.io/introduction/howtoget.html#setting-up-the-development-environment-from-scratch>). It is also possible to use service files otherwise, but we will only cover the *From scratch approach* in this tutorial.

### **Creation of the Octez Tezos node service**

Create the following file (named `tezos-node.service`) in *`/etc/systemd/system/`*.

```
# The Tezos Node service (part of systemd)
# file: /etc/systemd/system/tezos-node.service 

[Unit]
Description     = Tezos Node Service
Documentation   = http://tezos.gitlab.io/
Wants           = network-online.target
After           = network-online.target

[Service]
User            = <user> 
Group           = <user>
WorkingDirectory= /home/<user>/tezos/
ExecStart       = /home/<user>/tezos/tezos-node run --rpc-addr 127.0.0.1:8732 --data-dir ~/.tezos-node
Restart         = on-failure

[Install]
WantedBy        = multi-user.target
RequiredBy      = tezos-baker.service tezos-accuser.service
```

### **Creation of the baker service**

Create the following file (named `tezos-baker.service`) in *`/etc/systemd/system/`*.\
\
:warning: Don't forget to import your baking key on the tezos-client with: `tezos-client import secret key baker_alias <path_to_baker_secret_key>` (compatible with clear, encrypted and HSM key).\
\
:warning: Since the ***Jakarta*** amendment, the `--liquidity-baking-toggle-vote <vote>`command line switch becomes now mandatory. `<vote>` should be replaced by `on`, `off` or `pass`.

```
# The Tezos Baker service (part of systemd)
# file: /etc/systemd/system/tezos-baker.service 

[Unit]
Description     = Tezos baker Service
Documentation   = http://tezos.gitlab.io/
Wants           = network-online.target
Requires        = tezos-node.service

[Service]
User            = <user>
Group           = <user>
Environment     = "TEZOS_LOG=* -> debug"
WorkingDirectory= /home/<user>/tezos/
ExecStart       = /home/<user>/tezos/tezos-baker-013-PtJakart --endpoint http://127.0.0.1:8732 run with local node /home/<user>/.tezos-node --liquidity-baking-toggle-vote <vote>
Restart         = on-failure

[Install]
WantedBy        = multi-user.target
```

### **Creation of the accuser service**

Create the following file (named `tezos-accuser.service`) in *`/etc/systemd/system/`*.

```
# The Tezos Accuser service (part of systemd)
# file: /etc/systemd/system/tezos-accuser.service 

[Unit]
Description     = Tezos accuser Service
Documentation   = http://tezos.gitlab.io/
Wants           = network-online.target
Requires        = tezos-node.service

[Service]
User            = <user>
Group           = <user>
WorkingDirectory= /home/<user>/tezos/
ExecStart       = /home/<user>/tezos/tezos-accuser-013-PtJakart --endpoint http://127.0.0.1:8732 run 
Restart         = on-failure

[Install]
WantedBy        = multi-user.target
```

### Enable and start service files

Once `tezos-node.service`, `tezos-baker.service`, and `tezos-accuser.service` are created, continue with these steps:

1. Enable the services using `sudo systemctl enable tezos-node.service tezos-baker.service tezos-accuser.service`
2. Finally, start the services using `sudo systemctl start tezos-node.service tezos-baker.service tezos-accuser.service`

### Useful commands

#### Monitor your services

`sudo systemctl status tezos-node.service tezos-baker.service tezos-accuser.service`

#### Stop your services

`sudo systemctl stop tezos-node.service tezos-baker.service tezos-accuser.service`\
\
**Reload or restart a service**

`sudo systemctl reload-or-restart tezos-*.service` (\* being node, baker or accuser)

### **Displaying service logs**

When launching node, baker, and accuser services, we ideally want to be able to leanly monitor the behaviour of the daemons by keeping track of their logs.  Using services has the advantage of being able to rely on `journalctl`  to handle and organize logs for you - including rotating logs so that they don't take a lot of space (verbose modes can get large quite quickly).

Moreover, `journalctl` support querying and exporting concrete snapshots of the logs.  Here follow a few examples on how to use `--since` and `--until` to refine the logs around particular time windows.

#### Follow live the logs of the node/baker/accuser services&#x20;

`journalctl --follow --unit=tezos-node.service`

`journalctl --follow --unit=tezos-baker.service`

`journalctl --follow --unit=tezos-accuser.service`

**Hint:** *you might want to run each of them on separate terminal windows (and defining a handy* `alias`*es for them).*

#### Export node logs since yesterday

`journalctl --follow --unit=tezos-node.service --since yesterday`

#### Export baker logs since 8 am today

`journalctl --follow --unit=tezos-baker.service --since 08:00`

#### Export node logs since a week ago until one hour ago

`journalctl --follow --unit=tezos-node.service --since "1 week ago" --until "1 hour ago"`

#### Export baker logs between two specific timestamps

`journalctl --follow --unit=tezos-baker.service --since "2022-05-09 00:00:00" --until "2022-05-09 00:00:02"`

#### Export interleaved node/baker/accuser logs around a specific window

`journalctl --follow --unit=tezos-*.service --since "2 minutes ago" --until "60 seconds ago"`

**Hint:** good for debugging connection issues between node and baker.&#x20;

## **Running a remote signer as a service**

To secure their baking infrastructure, some bakers use a remote signer. This setup consists in:

* Running the node and baker on a first machine, e.g. a remote node running on a VPS in the cloud.
* Storing the key on a second machine, typically a local system (perhaps using a Ledger/HSM), and running a signing daemon to perform signing operations requested by the remote node running on the first machine.

### **Setup a remote signer using a .service file**

**Prerequisites:**

First make sure you have setup a remote machine on which your node will be running, and a *"home"* machine on which your baking keys will be stored (or that is connected to a Ledger/HSM).

Setup the remote signer following[ the procedure](https://tezos.gitlab.io/user/key-management.html#signer) here.&#x20;

On the home machine, create and launch the following service:

```
# The Tezos Signer service (part of systemd)
# file: /etc/systemd/system/tezos-signer.service 

[Unit]
Description     = Tezos Signer Service
Documentation   = http://tezos.gitlab.io/
Wants           = network-online.target
Requires        = tezos-node.service

[Service]
User            = <user>
Group           = <user>
WorkingDirectory= /home/<user>/tezos/
ExecStart       = /home/<user>/tezos/tezos-signer launch http signer
Restart         = on-failure

[Install]
WantedBy        = multi-user.target
```

To launch your signing service, follow the same steps as in the "[Enable and start service files](https://app.gitbook.com/o/-MbC5DmdpeQLrHfBLgaW/s/-Meeg1UVEGFWXkuXBJ17/~/changes/hcPOhWgbltBOr3ebOARZ/how-to/running-a-persistent-baking-node#enable-and-start-service-files)" section above.

\
**Happy (Steady) Baking!**


# Select a public node (DEPRECATED)

Below, you will find the public nodes run by our community members.

## PLEASE REFER TO: <https://tezostaquito.io/docs/rpc_nodes/>

**List of community-run nodes:**

* ECAD Labs nodes:
  * Mainnet: [https://mainnet.api.tez.ie](https://mainnet.api.tez.ie/)
  * Granadanet: [https://granadanet.api.tez.ie](https://granadanet.api.tez.ie/)
  * Hangzhounet: <https://hangzhounet.api.tez.ie/>
  * Florencenet: [https://florencenet.api.tez.ie](https://florencenet.api.tez.ie/)
* Tezos Giga Node from Tezos Ukraine:
  * Mainnet: [https://mainnet-tezos.giganode.io](https://mainnet-tezos.giganode.io/)
  * Granada testnet: <https://testnet-tezos.giganode.io/>
* SmartPy nodes:
  * Mainnet: [https://mainnet.smartpy.io](https://mainnet.smartpy.io/)
  * Granadanet: <https://granadanet.smartpy.io/>
* Nodes operated by Blockscale on behalf of the Tezos Foundation:
  * Mainnet: <https://rpc.tzbeta.net/>
  * Granadanet: <https://rpczero.tzbeta.net/>
* Teznode from LetzBake!:
  * Mainnet: [https://teznode.letzbake.com](https://teznode.letzbake.com/)


# Run a Tezos node (DEPRECATED)

Best practices on running Tezos nodes

## PLEASE REFER TO: <https://opentezos.com/deploy-a-node/installation>

An alternative to using the services of a public node, you can run your own node.

This document presents a series of recommended practices for running Tezos nodes. It chiefly concerns the configuration of nodes for baking, but more largely applies to running the nodes in other contexts. Conversely, some other practices are signaled as being potentially dangerous; it is advisable to avoid them unless you really know what you are doing.

The discussion is centered on the Octez implementation of the Tezos, although some aspects may apply to Tezos nodes in general.

### Context

Public blockchains are security-sensitive platforms. Indeed, given the high economic values at stake, such platforms are frequently targets of various kinds of attacks, such as denial of service (DOS), unforeseen and malicious uses of APIs, etc.

The Tezos mainnet is no exception to this general situation. This is why the Octez implementation of the Tezos blockchain (see [https://tezos.gitlab.io](https://tezos.gitlab.io/)) comes with a number of built-in protection mechanisms. For flexibility reasons, these mechanisms can be disabled or reconfigured by advanced users, but this implies mastering the associated risks.

For instance, the RPC interface offered by the Octez "tezos-node" binary is disabled by default, as a first protection mechanism, and must be explicitly enabled for the clients to communicate with the node. However, it is dangerous to make the whole node interface publicly accessible on the internet, for example, because many RPC calls are costly, and can thus be used for DOS attacks. For this reason, a second protection mechanism allows configuring the RPC interface using access control lists to enable only specific RPC calls. Thus, advanced users may disable the first protection mechanism and configure the RPC interface at a fine grain, according to their own expertise, and at their own risks. Still, the recommended practice is to open the RPC interface only on localhost.

Besides protecting against attacks, the configuration of a node is also important for: preventing resource exhaustion (disk, RAM, ...), optimizing the performance of each node or of the network as a whole, optimizing rewards for bakers (e.g., by avoiding missed endorsements), etc.

The rest of this document is structured around different aspects of the Octez node configuration, and for each such aspect recommends best practices or warns about dangerous practices.

### RPC interface

The Tezos node offers an RPC programming interface, that is used by clients such as a wallet or a baker. This is a rich API providing many features (see <https://tezos.gitlab.io/shell/rpc.html>). Some of these RPC are sensitive in terms of security:

* either because they perform sensitive operations that shouldn't be available to untrusted peers, such as banning/trusting a peer, configuring the operations filtered out by the node mempool, etc.
* or because they perform costly operations that could serve for denial of service (DOS) attacks.

As a concrete example (in the second category), there are two RPC calls to estimate baking and endorsing rights for the next cycles (GET endorsing\_rights and GET baking\_rights). Calling these RPCs repeatedly with no limitation by remote nodes can stall a node, preventing it to do any useful work.

For this reasons, the Octez implementation of the Tezos nodes contains three built-in protection mechanisms:

1. When running a node, the RPC interface is **disabled by default**. It has to be explicitly enabled using option `--rpc-addr`.
2. The RPC interface can be configured at a fine grain in the node configuration file using an **ACL** (access control list) mechanism, by listing either the calls that are enabled (whitelist) or disabled (blacklist).
3. A contextual policy is provided for configuring the RPC interface in the form of a **default ACL**. For the localhost interface, all RPCs are enabled by default. For other network interfaces of the current host, a subset of RPCs considered usually safe are enabled, while RPCs considered sensitive and costly are disabled. However, **the default list for remote hosts should only be considered as a base for customizing an ACL under your own responsibility**.

See <http://tezos.gitlab.io/user/node-configuration.html#default-acl-for-rpc> for more details on the default ACLs and some examples.

Advanced users may also establish more complex configurations using the proxy server (see <https://tezos.gitlab.io/user/proxy-server.html>), under their responsibility.

RECOMMENDATION

Based on these protection mechanisms, the recommended practice is to enable the RPC interface only on the localhost interface, thus only serving local binaries such as `tezos-client` and `tezos-baker`.

DANGER

Advanced users choosing to open the RPC interface for remote hosts do this at their own risks, and should carefully use the ACL mechanism for fine-grain configuration.

### History modes

The Octez node is configurable to keep more or less of the blockchain history. Different trade-offs between the required storage space and the possible queries on the history, are available in the form of three "history modes" called: Archive, Full, and Rolling (see <https://tezos.gitlab.io/user/history_modes.html>). These modes are suitable for different applications. For instance, the Archive mode stores all the blockchain history of balances since the genesis, and thus has the heaviest storage needs. It is suitable for applications such as indexers and block explorers. The lightest mode in storage consumption is the Rolling mode. The Full mode is an intermediate tradeoff (where everything is recomputable but only recent history is stored), generally suitable for bakers.

The Rolling mode is also compatible with baking, when used with caution. Specifically, as bakers are responsible, among others, of revealing nonces of blocks they produced during the previous cycle, they must proceed carefully when importing a snapshot. Indeed, a baker importing a snapshot in Rolling mode between the production of some block B and the revelation of the corresponding nonce, may lose information about block B, and fail to reveal its nonce, if the cycles reconstituted after the snapshot was imported are not including block B. (As a consequence, the baker would also lose the endorsing rewards for the cycle when they failed to reveal the nonce). For example, if the baker must reveal a nonce for block B at level L, the imported snapshot must record level L or lower.

These history modes also exhibit different CPU performance characteristics, which are worth taking into account. Specifically, nodes in Full mode are quicker in validating blocks than nodes in Archive mode (because in the latter case, data are searched in a larger file). This is especially true when nodes in Full mode have been restarted recently from a snapshot, and keep thus a limited history.

RECOMMENDATION

It is a recommended practice to use the Full mode for baking, and to regularly restart the baker from a recent snapshot, in order to ensure quick block validation.&#x20;

WARNING

It is not advised to set bakers in Archive mode, unless you have specific reasons to do so, as this typically slows down block validation. It is not advised to set bakers in Rolling mode either (even when it is not required to help other nodes to bootstrap), to always be able to reveal the nonce of the blocks they produced.

### Connections

In order to participate to the P2P network underlying the blockchain, the Tezos node establishes connections to different peers. The number of such connections is highly configurable, using options such as `--connections`, `--min-connections`, --`max-connections`, etc.

Being connected to more peers increases the chances of rapidly having up-to-date information about proposed operations and blocks, which is a very important consideration for bakers. On the other hand, having too many connections (e.g. hundreds) may incur an unacceptable overhead of communicating and synchronizing with all these peers. Therefore, it is advisable to configure a node to establish a reasonable number of connections. By default, the Tezos node currently targets 50 connections.

WARNING

It is advised not to configure a node to target too many connections (hundreds or so), as this could incur an unreasonable communication and synchronization overhead for the node. The default number of connections provides a reasonable base for defining an appropriate value for most cases.

### Disk space

Running a Tezos node requires providing enough disk space for its storage requirements. Indeed, if a node runs out of disk space, it shuts down and thus discontinues its service.

The disk space consumed by a node depends on its history mode, as explained above. But it is also important to know that, independendently of the archive mode, the disk space consumption varies in time. Thus, at regular intervals (about every 8 hours), disk space consumption increases temporarily, as the node re-orgranizes its storage. During this operation, the node keeps a copy of the old storage index, which explains why this temporary increase can typically add around 20G of disk space that are freed soon afterwards. More precisely, the extra space corresponds to the temporary copy of the`<node-dir>/context/index` subdirectory, where `<node-dir>` is the node's data directory.

RECOMMENDATION

Prior to running a node, make sure that it has not only enough disk space for its regular functioning (which may depend on its history mode and other options), but also extra available space for a copy of its index (typically around 20G extra space).

WARNING

Not allocating enough disk space for a node, including for its dynamic variations, incurs the risk of seeing the node regularly stopped.

### Memory space

Running a Tezos node requires providing enough memory space (RAM) for its functioning. Indeed, if a node runs out of RAM, it shuts down and thus discontinues its service.

The memory consumption of the node varies in time for the same reason as its disk space consumption: the node regularly reorganizes its storage (about every 8 hours). During normal operation, a node can typically work with 4G of RAM. During the storage reorganization operation, the node can consume twice as memory (up to 8G), but as each such operation is rather short-lived, it is safe to allocate the extra space as swap space on the disk.

RECOMMENDATION

Prior to running a node, make sure that enough RAM is available (typically 4GB), and also enough swap space on disk (typically 4GB).

### Performance

Ensuring a good performance level for a node requires allocating enough resources of different kinds (RAM, disk, CPUs) for its typical and peek needs. Currently, the central performance bottleneck of a Tezos node is constituted by disk bandwidth for read/write operations. For this reason, when dimensioning a machine for running a node, it is important to ensure sufficient disk bandwidth. This implies that increasing the number of CPUs machine and the RAM size of a machine to run several nodes on it does not scale well: the disk bandwidth will be the limiting factor. Rather, it is more resource-effective to run single nodes on moderately powerful machines.

RECOMMENDATION

When dimensioning machines for running Tezos nodes, it is advised to ensure a good disk bandwidth, such as those offered by SSD disks (and ideally, SSD/NVE disks). Running several nodes on the same machine should be considered with caution: pay attention not to saturate the disk bandwidth.

WARNING

Running several nodes on a multi-CPU machine will likely lead to suboptimal performance, because the disk bandwith will probably constitute the main bottleneck.

### Delayed endorsement

When a block is created and propagated on the network, nodes that have endorsing rights at that time slot can verify the validity of the block and emit an endorsement operation, which can be seen as a vote for including that block. Missing endorsement opportunities can result in missed rewards, but also has negative consequences on the network, such as slowing down the network and making the chain more susceptible to forks.

One possible reason for missing an endorsement opportunity is when the endorsement operation arrives too late, after the block has been created. Thus, it is important for bakers to emit endorsement operations as soon as possible.

RECOMMENDATION

Make sure that your baker process is not patched to delay endorsements, in order to avoid missed endorsements. So, if you are running an endorser with `--endorsement-delay <seconds>`, we suggest that you restart your endorser without it.

WARNING

Delaying endorsements, for historical reasons or for any reasons, incurs the risk of the endorsements arriving too late to be considered by block creators, hence resulting in missed reward opportunities.


# Demonstrate ownership of a tz address (DEPRECATED)

## PLEASE REFER TO: <https://opentezos.com/tezos-basics/cli-and-rpc#demonstrate-ownership-of-a-tz-address>

To ask someone to prove that he owns a specific address, you have several options.

## Option 1:

Ask the wallet owner to send a transaction to your wallet with a random amount of your choice.

The risk of this method is that the verification will happen on-chain, publicly. Malicious actors could find a way to attack and exploit this process.

Another drawback of this method is that it will cost some XTZ tokens for transaction fees.

## Option 2:

### Choosing the data to sign

In the situation where sending a transaction is not possible, you can use the `tezos-client` for that. The first step is to pick the data we want the buyer owning the wallet to sign, it could be the ID of a Hic et Nunc NFT he owns, for example: `OBJKT#63886`

### Converting the data to hexadecimal for the tezos-client

We now need to transform the ID in hexadecimal, for that we can use websites like: <https://www.convertstring.com/>

or the following script in linux:

```
#!/bin/bash

echo '0x'"`echo $1 | hexdump -vC |  awk 'BEGIN {IFS="\t"} {$1=""; print }' | awk '{sub(/\|.*/,"")}1'  | tr -d '\n' | tr -d ' '`" | rev | cut -c 3- | rev
```

Usage:

```
# We called our script string-to-hex.sh
> chmod +x string-to-hex.sh
> ./string-to-hex.sh OBJKT#63886
0x4f424a4b542332333438
```

### Signing the data with the tezos-client

The owner will have to sign the transaction with the `tezos-client`.

```
> tezos-client sign bytes 0x4f424a4b542332333438 for <YOUR_ADDRESS_ALIAS>                                                                                      

Signature: edsigtmihaqxqsbT5DRM39PaofMD9ibfNQgtVZFAmno1EtmFo8Co51nu9udgsepbSHhZNuntvpSGTCjksF3pssFvmRvPR3msEwi
```

### Verifying the signature

#### Finding the public key

To be able to verify the owner's signature, you need to retrieve its public key. For that you have two options:

* either ask the owner directly if he knows how to find it,&#x20;
* or retrieve it yourself from an explorer by looking for the "Reveal key" operation on the owner address.

To find the key on Tzkt, it would look like this:

* Go to the wallet page (example: <https://edo2net.tzkt.io/tz1cCG4Af5qkgBr2zGkG9W54mfCJ2s5Ltmyq/operations/>), and look for one of the first operations called "Reveal key" as in the example below. Once you find it, click on the brackets highlighted on the screenshot below, located at the top right of the page

* Once you opened the JSON you should be able to see the public key like in the screenshot below

![RPC JSON View](https://i.imgur.com/Bg12qO5.png)

![Reveal public key operation](https://i.imgur.com/u7h7qr7.png)

#### Importing owner's public key in the client

You now need to import the owner's public key in your `tezos-client` with the following command:

```
# We need to set an alias for the key, here we used the ID of the Hic et Nunc object with the "_BUYER" suffix
> tezos-client import public key OBJKT#63886_SIGNER unencrypted:edpkutsvRtP75QQaYAfyhyw52u8Rt4ZkuTgfhYSKeVkTEh8bQAZ8er
```

#### Verifying the signature

The final step will be to verify that the signature matches the public key of the buyer:

```
> tezos-client check that 0x4f424a4b542332333438 was signed by OBJKT#63886_SIGNER to produce edsigtmihaqxqsbT5DRM39PaofMD9ibfNQgtVZFAmno1EtmFo8Co51nu9udgsepbSHhZNuntvpSGTCjksF3pssFvmRvPR3msEwi

Signature check successful.
```


# Submit transactions to a specific baker (DEPRECATED)

This document aims at explaining how operations issuers can filtrate access to their mempool of operations, using a dedicated server. This feature is scheduled for the Octez v11 release.

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

## Bakers selection and authentication

Using **--operations-pool** argument when launching the baking software, bakers are able to fetch a mempool from a private server in addition to the mempool of any public Tezos node. By controlling which bakers can access the server (the baker's address is known), users can manage those who can bake their transactions. Thus, bakers must pass a KYC to enter the set of allowed bakers but we will not discuss this part in this document. Once bakers have been validated, the server must be able to authenticate them. The authentication mechanism needs to be determined.

## User authentication

Possibilities :

* with the URL directly: <http://username:password@example.com>
* with the credentials in the HTTP headers.

It really depends on how the server wants to proceed.

## Server specification

Besides authentication, the server needs to perform multiple checks on the operation sent by the user:

* It may only accept manager operations (i.e. transactions, revelation, origination, delegations)
* The server must perform a `dry-run`**`¹`** of the operation on its own node (public nodes could be malicious) to verify the validity of the operation and estimate its gas consumption

If one of these checks fails, the server responds back with an appropriate error message. If all is correct, the transaction is added to the pending queue of the server and the server sends back a confirmation that the transaction is waiting to be included in the estimated amount of time.

**\[1]**: A dry-run is a simulation performed with the `tezos-client`.

## Open questions users may address to use this tool

* Who hosts the server?
* Does the server need to send a confirmation that the transaction was baked or is it the user's responsibility to verify it?
* Should the server deliver the mempool only if the baker is going to bake soon?


# Estimate Tezos performances (DEPRECATED)

## NFT transfer performances

At the time of writing (February 2022, Hangzhou):&#x20;

* a typical NFT transfer on Tezos consumes**¹** 2,691 gas units per transaction,&#x20;
* the Tezos maximum block gas limit is 5,200,000 gas units,&#x20;
* the block time is 30 seconds.&#x20;

To maximize throughput, we can use batching - grouping several transactions into a single block.&#x20;

We performed experiments and measured how gas consumption varies depending on how many NFT transfers we group into a single batch of transactions, as presented in the following experimental values table:

| Batch size | Gas consumed |
| ---------- | ------------ |
| 1          | 2,691        |
| 10         | 9,601        |
| 100        | 78,709       |
| 240        | 186,213      |
| 300        | 232,285      |
| 400        | 309,074      |
| 500        | 385,863      |
| 600        | 462,653      |
| 650        | 501,048      |

We had to stop at 650, because we had reached the operation size limit imposed by the protocol. Thus, the largest batch we can use is 650. Now we estimate how many batches we can have in a block, considering that the max block gas limit is 5,200,000 gas units:

$$
\text{Max batches} = \frac{5,200,000}{501,048} \approx 10
$$

We now need to process the leftover gas:

$$
\text{Leftover gas} = 5,200,000 - (10 \times
501,048) \approx 189,520
$$

By taking this value and comparing it to our experimental values table we can see that we can add an extra batch of 240 NFT transfers approximately.

That would make the total of NFT transfers per block equal to:

$$
\text{Max NFT
transfers per block} = (10 \times 650) + (1 \times 240) = 6,740
$$

Since we have two blocks per minute, the number of transactions per second would be:

$$
\frac{6,740}{30} \approx 224 \ \text{NFT transfer/second}
$$

## Standard Tez transfer performances

For standard tez transfers, we can process the performance of the Tezos blockchain with the following formula:

$$
\frac{\text{max gas per block}}{\text{tx gas consumption} \times \text{time per
block}} = \text{tx/second}
$$

In that scenario, the gas consumption is 1,420 gas units, and we will keep the same values as in the previous calculation:

* Tezos maximum block gas limit: 5,200,000 gas units&#x20;
* Block time: 30 seconds.

$$
\frac{5,200,000}{1,420 \times 30} \approx 122\ \text{tx/second}
$$

Performance should improve further with the planned Tezos upgrade to adopt the Tenderbake consensus algorithm **²**, and the Hangzhou amendment.

**\[1]:** With the minimal contract implementing the FA2 standard.

**\[2]:** <https://blog.nomadic-labs.com/a-look-ahead-to-tenderbake.html>


# Estimate transaction cost (DEPRECATED)

To measure the cost of a transaction in fiat currency, we calculate as follows

$$
\frac{\text{gas consumed} \times \text{median gas cost} \times \text{tez price}}
{1,000,000} = \text{tx price}
$$

We take as an example the median gas cost**¹**, and the tez price on October 7, 2021:

* median gas cost: 0.1 / gas unit&#x20;
* tez price: 6.7

We use the following values for the gas usage:&#x20;

$$\begin{array}{l@{\ }c@{\ }l}   \text{tez transfer cost} &=& \frac{1,500 \times 0.1 \times 6.7}{1,000,000} \approx 0.001005\ EUR \\\[2ex] \text{NFT transfer cost} &=& \frac{123,000 \times 0.1 \times 6.7}{1,000,000} \approx 0.08241\ EUR \\\[2ex] \text{Mint NFT cost} &=& \frac{94,000 \times 0.1 \times 6.7}{1,000,000} \approx 0.06298\ EUR \end{array}$$​

* Hic et Nunc NFT minting: [94,000 gas units](https://better-call.dev/mainnet/opg/oopxYaUWMAs8iCG55YVytiuzqCF3AzQ8svZV17cp95vYUQPiVsQ/contents)&#x20;
* Hic et Nunc NFT transfer: [123,000 gas units](https://better-call.dev/mainnet/opg/onui6v8SQJUNmPBsmvMaDxiAbBNn8r85pmAifrHWcP2KNRSGvEu/contents)&#x20;
* tez transfer: [1,500 gas units](https://tzkt.io/onedAYdnpGG37aDmACc6qiJz1BPTSqPMNBxGwJstwZsNiAPz2D1)

This cost calculation is indicative only. It’s not absolute nor guaranteed; it’s a cost estimate based on figures which are valid at one particular moment.

**\[1]:** We took the median value in a range of 13 gas cost values.


# DeFi on the Tezos blockchain

Decentralized Finance (DeFi) is a ﬁnancial innovation brought by blockchain technology. By relying on smart contract technology—algorithms deployed on blockchains to ensure the execution of certain predeﬁned tasks—DeFi aims to create a new ﬁnancial system that is open to everyone and reduces the need for trusted third parties.

This document gives an overview of state-of-the-art DeFi applications available on the Tezos blockchain at the time of writing.

## Automated Market Makers: Decentralized Exchanges

AMMs (automated market makers) are applications that allow users to exchange tokens without the use of traditional market makers and order-book models.

No central entity is required to gather buyers and sellers or to ensure successful transactions. AMMs rely on a set of smart contracts whose main components are **liquidity pools ¹**. Liquidity pools allow users to seamlessly swap tokens

on-chain—that is, exchange one asset for another on the blockchain—thanks to decentralized and non-custodial smart contract codes. In such pools, **liquidity providers ²** earn rewards corresponding to trading fees charged for each transaction. This amount is proportional to their contribution to the pool.

The most successful decentralized exchanges use the constant product market maker (CPMM) formula to ensure tokens’ parity within the pool over time:

&#x20;                                                                         $$x \* y = c$$    &#x20;

where$$x$$ is the amount of a given token A, and $$y$$ the amount of a given token B. $$c$$is a constant, which always remains the same and ensures the stability of the pool. When users interact with a liquidity pool, the product of$$x \* y$$ remains the same. However, if a price discrepancy appears between a centralized exchange (external from the blockchain) and the pool of tokens, arbitrageurs3 can exploit such an opportunity to rebalance the pool with the market prices. Arbitrageurs may then take a proﬁt.

Using liquidity pools involves certain risks. Apart from omitting the risk of smart contracts being hacked, which can be achieved with careful audits, a well-known risk of liquidity pools is **impermanent loss**. This is the diﬀerence in earnings between introducing liquidity into a given pool and simply holding the assets.

When a price discrepancy occurs, for example, one of the tokens within the pool increases in price, and arbitrageurs exploit such an opportunity and rebalance the pool. However, if the liquidity providers simply held the same assets, they could entirely beneﬁt from the price increase.

Therefore, the more assets are correlated in terms of price to one another, the less impermanent loss is likely to occur as price movements are almost the same.

\[1]: A liquidity pool is a pool of tokens locked in a smart contract that allows external users to swap assets within the pool.

\[2]: People who bring liquidity to the pools to enable exchanges.

\[3]: An arbitrageur is a type of investor who attempts to proﬁt from market ineﬃciencies (e.g., price discrepancies).

### Dexter

Dexter is the ﬁrst Tezos AMM decentralized exchange (DEX) launched in Q4 2020. The main features of Dexter are:

* Exchange token↔tez and token↔token.
* Provide liquidity in token/tez pools and earn exchange fees.
* Earn tez rewards, which are distributed by bakers of the diﬀerent pools.

The project’s V1 has been [reviewed and audited by Trail of Bits,](https://github.com/trailofbits/publications/blob/master/reviews/dexter.pdf) and the V2, [Formally veriﬁed by Runtime Veriﬁcation](https://runtimeverification.com/blog/dexter-2-s-formal-verification/)[.](https://github.com/trailofbits/publications/blob/master/reviews/dexter.pdf)

### Plenty DeFi

[Plenty](https://www.plentydefi.com/) is a decentralized [yield-farming](#yield-farming)/AMM set of smart contracts on Tezos that focuses on bringing more liquidity and users to the Tezos DeFi ecosystem.

Plenty introduced a **$PLENTY** token to reward users for providing liquidity on speciﬁc pools **⁸**. $PLENTY tokens will also play a key role in Plenty’s future applications as a governance token. Liquidity providers are rewarded in $PLENTY tokens in their yield-farming application.

Plenty team recently deployed its AMM and is gradually adding new pairs to allow users to stake assets, provide liquidity, and exchange various token pairs.

In the future, Plenty aims to provide additional tools to enable interactions and create synergy within the existing ecosystem by providing:

* A lottery.
* A governance process and tokenomics.
* A prediction market.
* IFO (initial farm oﬀering), a new way of ﬁnancing projects by raising funds using the PLENTY-XTZ liquidity pool.

**\[8]:** PLENTY, ETHtz, hDAO, USDtz, wLINK, and wMATIC (as of August 2021).

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdroCYBYbTxu8UFE%2F28.jpeg?generation=1632834594964613\&alt=media)

&#x20;                                                                        **Figure:** Plenty’s AMM.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrp8266J5YLYA6f%2F29.jpeg?generation=1632834595020606\&alt=media)

&#x20;                                                       **Figure:** Some of the Plenty liquidity pools.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrqroZy1ZJi_w5L%2F30.jpeg?generation=1632834594990984\&alt=media)

&#x20;                                                                 **Figure:** Plenty’s farm pools.

This project has been [reviewed and audited by Apriorit](https://github.com/Plenty-DeFi/security-audit/blob/main/PLENTYDEFI_SECURITY_AUDIT_APRIORIT.pdf).

### QuipuSwap

[QuipuSwap](https://quipuswap.com/swap) is a decentralized exchange working with the constant product market maker (CPMM) formula. It oﬀers additional governance features compared to Dexter, including:

* * Users can add new token pairs.
  * Users can vote for delegates of a liquidity pool or ban a “bad” delegate who doesn’t do the job.
  * Provide liquidity in token/tez pools and earn exchange fees.
  * Earn tez rewards distributed by bakers to the liquidity pools.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrQW1J2qKwKW_Y6%2F3.jpeg?generation=1632834594959554\&alt=media)

&#x20;                                                                   **Figure:** [**QuipuSwap's**](https://quipuswap.com/swap) interface.

QuipuSwap recently launched its governance token ⁴ $QUIPU. Early users of the platform received $QUIPU airdrops to reward them for their participation. $QUIPU will be used in platform governance and in a liquidity-mining program.

In the future, QuipuSwap aims at providing further tools:

* Token-to-token pools.
* A smart “router” service to help pick the optimal swap path.
* A new front-end for a better user experience.
* Public token listings as an alternative to the current white-listing procedure.
* New enhanced smart contracts version.

This project has been [reviewed and audited by Least Authority](https://leastauthority.com/blog/audit-of-quipuswap-smart-contracts-for-tezos-foundation/).

\[4]: Governance tokens are associated with voting power on a blockchain project. With governance tokens, one can create and vote on governance proposals over a set of smart contracts that control an organization called a Decentralized Autonomous Organization or DAO.

### Liquidity Baking

[Liquidity Baking](https://gitlab.com/tzip/tzip/-/blob/master/drafts/current/draft-liquidity_baking.md) is a **tez**↔**tzBTC** single pair AMM voted through the [Granada](https://forum.tezosagora.org/t/announcing-granada/3183) amendment.

The motivation behind such a contract—brought for the ﬁrst time by an amendment instead of an independent set of smart contracts built separately from the protocol—is to increase the overall tez liquidity along with tzBTC, a wrapped ⁵ version of Bitcoin (BTC) on Tezos. How this DEX works is quite innovative:

* A **subsidy** of 2.5 tez is minted and brought to the **tez/tzBTC** pool at each block. It increases tez volume in the Liquidity Baking contract over time.
* Liquidity providers receive fees plus freshly minted tez proportionally to their share of the liquidity pool.
* Bakers can vote to stop the Liquidity Baking contract from a protocol point of view.
* An emergency escape hatch is provided if something goes wrong.

The smart contract used for Liquidity Baking is not speciﬁc to tzBTC and can be used for any arbitrary tez↔token Tezos pool.

This project has been [reviewed, and formally veriﬁed by Nomadic Labs](https://blog.nomadic-labs.com/progress-report-on-the-verification-of-liquidity-baking-smart-contracts.html).

\[5]: A wrapped token is a token pegged to the value of another cryptocurrency. The original asset is put in a wrapper (represented by a digital escrow contract) that allows the issuance of the wrapped representation. It allows users to beneﬁt from other blockchain features (scalability, security, etc.).

## Decentralized Fundraising

Decentralized fundraising is a new ﬁnancing method allowing project creators to raise funds in a decentralized manner. In the same way that start-ups receive capital before launching, projects using the decentralized fundraising process can receive funds both from institutional and individual investors. Unlike an initial public oﬀering (IPO), investors never own any equity in the project. A major diﬀerence compared to classic fundraising is much lighter legal requirements, which makes the whole process easier.

By participating in decentralized fundraising, investors receive tokens proportionally to their investment. These tokens play a key role in the new applications and protocols built.

### 1. Initial DEX offerings

An initial DEX oﬀering (IDO) is a fundraising process whose purpose is to ﬁnance DeFi projects using decentralized exchanges as an alternative to centralized exchanges that involve heavy and permissioned fundraising processes.

IDOs oﬀer new projects the opportunity to create and list their token to ﬁnance their future business.

To perform an IDO, projects create a public [coin](https://coinmarketcap.com/alexandria/glossary/coin) on a DEX and receive funds from various investors. IDOs are the decentralized versions of initial exchange oﬀerings (IEOs) where crypto projects launch their token and raise funds via a centralized exchange.

#### Rocket launchpad

[Rocket](https://rocketlaunchpad.io/) is a decentralized IDO platform that allows project creators to ﬁnance their business and investors to participate in future successful fundraising.

Rocket uses a system based on $RCKT (Rocket token) holding to allow users to participate in presales of new Tezos-based projects and stake their tokens.

All projects are vetted through a submission process to ensure the best projects launch.

To ensure the most decentralized approach possible, smart contracts are used so Rocket never handles any funds.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrRKISJVCBAGLjp%2F4.jpeg?generation=1632834594991652\&alt=media)

&#x20;                                                               **Figure:** Rocket’s launchpad interface.

This project is currently being reviewed and audited.

#### Instaraise

[Instaraise](https://instaraise.io/) is the ﬁrst decentralized IDO platform built on the Tezos blockchain.

The platform allows token-based projects to raise funds by setting up a swap pool based on a ﬁxed purchase rate. These so-called “Fixed Swap Pools” have many advantages for token sale investors over traditional fundraising models like initial coin oﬀerings (ICOs), IEOs, and IDOs (Initial DEX Oﬀerings). Fixed Swap Pools will maintain the token price throughout the sale until the initial supply is bought.

With Instaraise, Tezos projects will be able to raise and exchange capital cheaply and quickly, and users will be able to participate in a secure and compliant environment. Instant liquidity provisioning (in QuipuSwap) is facilitated securely thanks to smart contracts.

Anyone can use the presale infrastructure and the owner console to start their presale. Instaraise deployed the $INSTA token to allow presale facilitation and create beneﬁts for users such as liquidity mining (a program that rewards users of a given service), staking rewards, discounted sales with white-listed addresses, and airdrops.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrSY67JXpUmEBPx%2F5.jpeg?generation=1632834594984561\&alt=media)

&#x20;                                                                **Figure:** Instaraise’s interface.

This project has not been audited as of August 2021.

## Hybrid Cross-Chain Exchange

A cross-chain exchange is a type of decentralized exchange where people can trade assets from diﬀerent chains using a technology called an **atomic swap**.

An atomic swap is an exchange of assets occurring in a decentralized manner, without any central authority needed to ensure the exchange’s success. It is called “atomic” because either the entire exchange occurs or nothing happens and both parties involved get their assets back. It is useful to:

* Swap two diﬀerent tokens from a single blockchain.
* Swap two assets from two diﬀerent blockchains.

### Atomex

[Atomex](https://atomex.me/) is a multicurrency wallet allowing cross-chain atomic swaps whose features include:

* Cross-chain swaps between Tezos (tez), BTC, Ethereum (ETH), Tether (USDT), WBTC, TBTC.
* On-chain swaps between Tezos, KUSD (kUSD), TZBTC (tzBTC).
* Cryptocurrency purchases by card.
* Portfolio monitoring.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrTeQAhyLZ7i2xk%2F6.jpeg?generation=1632834595027894\&alt=media)

&#x20;                                              **Figure:** Atomex wallet—cross-chain exchange interface.

This project has been reviewed and audited by Least Authority [here](https://leastauthority.com/static/publications/LeastAuthority_Tezos_foundation_Atomex_Smart_Contracts_Audit_Report.pdf) and [there](https://leastauthority.com/static/publications/LeastAuthority_Tezos_Foundation_Atomex_Core_Library_and_Desktop_Client_Audit_Report.pdf).

## Tokens

Blockchains allow digital assets representation through tokens, deﬁned by smart contract standards. These assets can be exchanged in the same way that *native* tokens ⁶ are. Token standards facilitate the tokenization of applications in a blockchain.

In this section, we will focus on a small sample of tokens deployed on the Tezos blockchain so far (for more detailed information, visit <https://teztools.io/>).

On the Tezos blockchain, token standards are written in the **Tezos Interoperability Proposal** (TZIP) format. To understand the current state of token standards in Tezos, let’s look at the three main standard proposals:

* [TZIP #5](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-5/tzip-5.md): Financial Application 1 (FA1)—Abstract ledger (fungible tokens).
* [TZIP #7](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-7/tzip-7.md): Financial Application 1.2 (FA1.2)—Approvable ledger to represent fungible tokens with speciﬁc rules (maximum supply of the token, issuance conditions, etc.).
* [TZIP #12](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-12/tzip-12.md): Financial Application 2 (FA2)—Multi-asset interface to represent fungible and non-fungible tokens (NFTs).

\[6]: A native token is the unit of account of a given blockchain, such as BTC for Bitcoin, tez for Tezos, etc.

### Stablecoins

A stablecoin is an asset class that attempts to oﬀer price stability. It represents an asset, and its price is supposed to replicate its underlying value. Stablecoins have gained traction as they oﬀer almost instant processing, security, privacy of payments, and a volatility-free valuation of ﬁat currencies.

Of all the kinds of stablecoins, three are the most widespread:

* **Fiat-backed stablecoins**: The most widespread type of stablecoin, they rely on a reserve of the underlying ﬁat currency. For each stablecoin issued on the blockchain, the issuer claims to hold the equivalent amount in ﬁat currency in a corresponding bank account (e.g., US dollar (USD) Coin [USDC](https://www.coinbase.com/usdc) for USD).
* **Crypto-backed stablecoins**: In most cases, to issue such a stablecoin, a cryptocurrency is put in an escrow smart contract as collateral. The use of such collateral relies on a game theory design and the exploitation of arbitrage opportunities to incentivize participants to keep the price stable.
* **Algorithmic stablecoins**: These rely on algorithms and smart contracts to manage the supply of the stablecoin and thus maintain the peg to the underlying asset (e.g., USD, euro, etc.) by creating incentives to either buy or sell the stable token.

#### Kolibri: kUSD

Created by [Hover Engineering](https://hover.engineering/), kUSD is the ﬁrst crypto-backed stablecoin issued on the Tezos blockchain. It uses a collateralized mechanism and a price liquidation option to guarantee the price stability of the kUSD.

To get kUSD, users owning tez can create [ovens](https://kolibri.finance/), escrow tez, and borrow kUSD with respect to a limit enforced by the protocol. It is also possible to swap tez (or other tokens) for kUSD on a decentralized exchange (e.g., [Quipuswap XTZ/kUSD pool](https://quipuswap.com/swap?from=tez\&to=KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV)). kUSD complies with FA1.2 standard.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrUzlfXlCAhTfHq%2F7.jpeg?generation=1632834595006140\&alt=media)

&#x20;                                                               **Figure:** Kolibri’s stablecoin web interface.

A dedicated liquidity pool has been created recently to prevent under-collateralization. Users pool kUSD and get 1% rewards on each liquidation performed.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrVNblqpo5hLc4s%2F8.jpeg?generation=1632834594961931\&alt=media)

&#x20;                                                                  **Figure:** kUSD liquidation pool.

kUSD governance is expected to be fully managed soon by the [Kolibri DAO](https://kolibri-xtz.medium.com/announcing-kolibri-dao-6687eb528cb) (Decentralized Autonomous Organization, deﬁned below), and its governance token kDAO.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrW9WqRJnURXh_U%2F9.jpeg?generation=1632834594963303\&alt=media)

&#x20;                           **Figure:** Example of swap between wrapped UNI and kUSD on QuipuSwap.

#### USDtez

[USDtez](https://usdtz.com/) (symbol: USDtz or USDTZ) is a USD-pegged stablecoin based on a fungible Tezos community standard—the FA1.2 token standard—created and issued by [Stabletez](https://stabletez.com/). USDtez is pegged to a formally veriﬁable measure (USDtez reserve is audited monthly by Armanino LLP) of value (1:1 parity) between itself and the USD. It provides a solvent and scalable source of liquidity that allows low-fee Tezos-based asset trading.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrXTlIseIIrmVrf%2F10.jpeg?generation=1632834594963296\&alt=media)

&#x20;                                                                            **Figure:** USDtez logo.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrYIEuscEpbbV23%2F11.jpeg?generation=1632834594963787\&alt=media)

&#x20;                                                               **Figure:** Buy USDtez on QuipuSwap.

#### USDS

USDS is a stablecoin created by [Stably](https://www.stably.io/), built on the FA2 token standard, and issued by [Prime Trust](https://www.primetrust.com/), a Nevada-chartered trust company that is also the regulated administrator for USDS. One of the particularities of USDS is that it allows fee-less transfers thanks to [TZIP-17](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-17/tzip-17.md) implementation. Thus, the token transfer fee can be taken over by another account.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrZC9jFStSO1Diz%2F12.jpeg?generation=1632834594895946\&alt=media)

&#x20;                                                                          **Figure:** Stably’s logo.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdr_JboyTftsD5Qa%2F13.jpeg?generation=1632834594967489\&alt=media)

&#x20;                                                               **Figure:** Buy USDS on QuipuSwap.

### Some other assets

**Wrapped BTC: tzBTC**

[tzBTC](https://tzbtc.io/) brings BTC liquidity to the Tezos ecosystem, enabling BTC-backed use cases on Tezos.

Developers on Tezos can use tzBTC to enable novel ﬁnancial applications on the Tezos blockchain. It replicates the value of the BTC on the Tezos blockchain. For each BTC sent to a speciﬁc smart contract, the equivalent in tzBTC is issued on the Tezos blockchain.

The [Bitcoin Association Switzerland](https://www.bitcoinassociation.ch/) acts as a third party and mediator key holder, accountable for the 1:1 parity between tzBTC and BTC. The association agrees to use a standard contract for its role in the tzBTC ecosystem.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdran0QMo5GAQgdA%2F14.jpeg?generation=1632834594898075\&alt=media)

&#x20;                                                                               **Figure:** tzBTC logo.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrb20TLFi-KpanI%2F15.jpeg?generation=1632834594970177\&alt=media)

&#x20;                                                               **Figure:** Buy tzBTC on QuipuSwap.

#### Wrapped ETH: ETHtz

[ETHtz](https://ethtz.io/) is a token from Stabletez. [Stabletez](https://stabletez.com/) (Tezos Stablecoins) is a family of stablecoins that runs on the Tezos blockchain and adheres to the Tezos FA token standard, which is the universal Tezos token standard.

ETHtz replicates the value of the ETH on the Tezos blockchain. For each ETH sent to a speciﬁc escrow smart contract, the equivalent in ETHtz is issued on the Tezos blockchain.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrcgmAoG7x6MWsU%2F16.png?generation=1632834594971143\&alt=media)

&#x20;                                                                           **Figure:** ETHtz logo.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrdvV_rR2cY4u1i%2F17.jpeg?generation=1632834594963746\&alt=media)

&#x20;                                                               **Figure:** Buy ETHtz on QuipuSwap.

#### Wrapped Tezos: wXTZ

Wrapped Tezos (wXTZ) is a fully collateralized representation of XTZ initiated by [StakerDAO](https://www.stakerdao.com/) (presented below) and conforming to the FA1.2 token standard—a collateralized staking position that unlocks the power of DeFi.

The idea is to combine XTZ staking with the possibility of trading the representation of the underlying asset. To mint wXTZ, users need to send XTZ to a vault. In return, they will receive a proportional amount of wXTZ. If they want to get their XTZ back, they need to send the wXTZ to the originated contract, which will burn the wrapped tokens and release the XTZ escrowed.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdre7LZ2iBY8gTkP%2F18.png?generation=1632834594970246\&alt=media)

&#x20;                                                                          **Figure:** wXTZ logo.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrfd0SgNFJ7wRse%2F19.jpeg?generation=1632834594961517\&alt=media)

&#x20;                                                               **Figure:** Buy wXTZ on QuipuSwap.

## Oracles

A blockchain oracle is a tool that connects blockchains with oﬀ-chain data (i.e., unavailable on the blockchain).

Blockchains, by their decentralized nature, allow the sharing of data across a network. But what about dealing with oﬀ-chain data?

Let’s imagine an application where people can bet on sports results. In that case, poor data can lead to a poor ﬂow of funds.

The challenge is to feed actual and authentic external data representing the ﬁnal sports results into the blockchain such that it becomes possible to execute particular actions using on-chain smart contracts.

That’s where blockchain oracles come into place: They aggregate data from diﬀerent external sources (oﬀ-chain) to ensure that the most accurate information is brought on-chain.

### Harbinger

[Harbinger](https://github.com/tacoinfra/harbinger) is a signed price feed on the Tezos blockchain, inspired by Compound oracle infrastructure.

Harbinger’s inner functioning requires separate entities to provide signed and post-price updates on-chain. The more entities participate in the price feed, the more decentralized the solution is. Harbinger gathers a set of smart contracts dedicated to receive price updates from a speciﬁc exchange of cryptocurrencies. The price feeds are normalized and then posted on-chain.

Harbinger stores information of price about assets under “candles” representation. Each asset in Harbinger price oracle contains:

* start time
* end time
* open price
* highest price
* lowest price
* close price
* volume.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrgAbGwSyDp09XU%2F20.jpeg?generation=1632834594966194\&alt=media)

&#x20;                                                               **Figure:** Harbinger infrastructure.

This project has not been audited as of August 2021.

### Kaiko

[Kaiko price oracle](https://www.kaiko.com/) is a cryptocurrency market data provider that provides live tez price feeds on-chain.

Kaiko writes historical and live tez/USD and tez/Swiss franc exchange rates to each new Tezos block. The price from Kaiko price oracle is derived from Kaiko’s exchange rates data, which aggregates tez price data from dozens of exchanges.

Kaiko is also running its own Tezos node.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrhyY2zQP30z9Ha%2F21.jpeg?generation=1632834594895953\&alt=media)

&#x20;                                                               **Figure:** [**Kaiko Price Oracle**](https://tzkt.io/KT19kgnqC5VWoxktLRdRUERbyUPku9YioE8W/entrypoints) on Tzkt.

This project has not been audited as of August 2021.

### Ubinetic

[Ubinetic](https://ubinetic.com/) is a Swiss company that builds tools dedicated to the support and creation of synthetic assets.

Ubinetic’s oracle application fetches prices from liquid markets, checks whether the source data is accurate, timely, and complete, and signs the data to ensure that manipulation can be detected.

To guarantee that the application runs independently, so-called *data transmitters* run the mobile devices that are responsible for collecting the data from various exchanges.

<div align="center"><img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdriN_nUoxPVPiB-%2F22.jpeg?generation=1632834594980604&amp;alt=media" alt=""></div>

&#x20;                                 **Figure:** Ubinetic oracle architecture (Youves is a DeFi protocol; more here).

The process of collecting and posting data is as follows:

1. An application on several mobile phones run by several independent data transmitters fetches data from liquid markets (e.g., Coinbase, Binance, etc.).
2. At the same time, the application checks whether the source of the data is accurate, timely, and complete, and signs the data to ensure that manipulation can be detected. The combination of [certiﬁcate](https://www.digicert.com/dc/blog/certificate-pinning-what-is-certificate-pinning/) [pinning](https://www.digicert.com/dc/blog/certificate-pinning-what-is-certificate-pinning/) and a veriﬁable tamper-proof execution of the speciﬁc application allows the data transmitter to conﬁrm data accuracy.
3. The application periodically posts the data to the Ubinetic Aggregator, which veriﬁes and stores the attestations, collects signed data for an interval, and publishes the data to the Tezos smart contract. The data normalization smart contract calculates the volume-weighted averages of the data from the diﬀerent exchanges.

This project has not been audited as of August 2021.

## Decentralized Autonomous Organization

A DAO is an organization that uses open-source smart contract codes to automate and facilitate decision-making.

Using a DAO may help prevent human error or manipulation since the decision power is no longer in the hands of a few trusted people. Rather, it is automated distributively and written as an immutable code deployed on the blockchain.

Using a DAO is not risk-free: Recall [the DAO project where coding errors led to $50 million of funds being lost](https://www.coindesk.com/understanding-dao-hack-journalists).

### StakerDAO

[StakerDAO](https://www.stakerdao.com/) is a DAO governed by a community of blockchain and ﬁnance enthusiasts who vote to make decisions and govern to build cross-chain ﬁnancial assets. The process of governance is as follows:

* New ideas for products and features are proposed on the [StakerDAO](https://forum.stakerdao.com/) [forum](https://forum.stakerdao.com/).

StakerDAO’s ecosystem comprises Staker Politicians (individuals involved with governance—a requirement is to hold 1% of $STKR, StakerDAO’s token—and qualiﬁed to submit proposals), STKR token holders, and the Staker development team.

* STKR holders vote on proposals on the [StakerDAO platform](https://gov2.stakerdao.com/overview) with their wallets. The ones that reach the quorum of “yes” votes are approved.
* Approved proposals are built and deployed by community members.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrjEfrkmSX8JHG0%2F23.jpeg?generation=1632834595083431\&alt=media)

&#x20;                                          **Figure:** An overview of StakerDAO’s governance platform.

This project has been [reviewed and audited by Runtime Veriﬁcation](https://github.com/runtimeverification/publications/blob/main/reports/smart-contracts/StakerDAO.pdf).

## Cross-Blockchain Bridges

A cross-blockchain bridge is a connection that allows the transfer of tokens from one chain to another. The particularity is that both chains usually have diﬀerent protocols, and the bridge provides a way for them to interoperate.

To create a bridge between two blockchains in practice, we need to create a set of smart contracts that will allow users to escrow funds on one side and mint the equivalent token amount on the other side. It is possible to operate on one or the other chain, depending on users’ needs.

A cross-chain bridge is indistinguishable from the concept of wrapped tokens. Indeed, as users need back-and-forth interaction, tokens must be wrapped on one side in an escrow smart contract to guarantee that the newly minted tokens represent existing assets. When a particular user decides to go back on the original chain, they can burn the wrapped tokens and thus unwrap their initial stake.

### Bender Labs bridge

[Bender Labs](https://www.benderlabs.io/) is a wrapping protocol that created a bridge between Ethereum and Tezos. The protocol supports ERC20 and ERC721 token wrapping. At the time of writing, it is possible to wrap the following tokens:

* Binance USD (BUSD) into **wBUSD**.
* Bitﬁnex LEO token (LEO) into **wLEO**.
* Celsius Network (CEL) into **wCEL**.
* ChainLink token (LINK) into **wLINK**.
* Compound (COMP) into **wCOMP**.
* Crypto.Com coin (CRO) into **wCRO**.
* Dai Stablecoin (DAI) into **wDAI**.
* FTX token (FTT) into **wFTT**.
* HUSD (HUSD) into **wHUSD**.
* Huobi token (HT) into **wHT**.
* Maker (MKR) into **wMKR**.
* Matic token (MATIC) into **wMATIC**.
* OKB (OKB) into **wOKB**.
* Paxos Standard (PAX) into **wPAX**.
* Suchi token (SUSHI) into **wSUSHI**.
* Tether USD (USDT) into **wUSDT**.
* USDC into **wUSDC**.
* Uniswap (UNI) into **wUNI**.
* Wrap governance token (WRAP) into **WRAP**.
* Wrapped BTC (WBTC) into **wWBTC**.
* Wrapped Ether (WETH) into **wWETH**.

When users wrap tokens on Ethereum using Wrap Protocol, the equivalent wTokens are minted on Tezos 1 hour after the wrap initiation as a security measure against chain reorganization ⁷.

Initially, users who wrap tokens will be rewarded with extra **$WRAP** governance tokens for their participation. Once tokens are wrapped, they can be traded easily on DEXes (like QuipuSwap) or unwrapped using the reverse process.

Note that the wrapping/unwrapping process requires connecting both Ethereum and Tezos wallets to sign operations.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrkzCEQiGHCOyp8%2F24.jpeg?generation=1632834594983950\&alt=media)

&#x20;                       **Figure:** Wrapping process AAVE token on Ethereum→wAAVE token on Tezos.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrlgAk93v6F1pkX%2F25.jpeg?generation=1632834594977201\&alt=media)

&#x20;                          **Figure:** Unwrapping process wAAVE on Tezos→AAVE token on Ethereum.

This project has been [reviewed and audited by Least Authority](https://leastauthority.com/static/publications/LeastAuthority_Wrap_Protocol_Smart_Contracts_Final_Audit_Report.pdf).

\[7]: A chain reorganization takes place when a node receives blocks that are part of a new valid chain. The node will *deactivate* blocks in its old valid chain in favor of the blocks that build the new valid chain. This process allows individual nodes across the network to agree on the same version of the blockchain.

### StakerBridge

StakerBridge allows to exchange tokens between the Ethereum network and the Tezos network, and the Ethereum network and the Algorand network.

StakerBridge is governed by the StakerDAO organization. STKR token holders can submit a proposal to bring new tokens into the bridge protocol.

Currently, StakerBridge allows Ethereum and Tezos to interoperate with:

* BLEND token (BLND): A token that tracks a managed basket of vetted Proof-of-Stake assets.
* Staker token (STKR): Governance token of StakerDAO.
* Wrapped XTZ (wXTZ).

Using this bridge requires connecting both Ethereum and Tezos wallets to sign and approve transactions on both chains.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrm9cQZ9TrBn_iz%2F26.jpeg?generation=1632834594983203\&alt=media)

&#x20;                                          **Figure:** An example of bridging wXTZ from Ethereum to Tezos.

This project has not been audited as of August 2021.

### TezEx Bridge

[TezEx](https://tezex.io/) is a cross-chain bridge on the Tezos blockchain and a non-custodial decentralized exchange for both traders and liquidity providers.

TezEx Bridge (Beta) is now live and allows users to trade USDC for USDtz as well as ETH for ETHtz, and back.

Soon, TezEx (Beta decentralized exchange) will be launched and embed TezEx Bridge. TezEx will include more cross-chain swaps (including Tether) as well as swaps between Tezos tokens and Tez. Additional features will be added over time.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrnw5U0QJE90Hke%2F27.jpeg?generation=1632834594983901\&alt=media)

&#x20;                                      **Figure:** TezEx Bridge—cross-chain exchange web interface.

This project has been [reviewed and audited by Apriorit](https://drive.google.com/file/d/1lDv61uy3KeDGt4bjl1SdUKGoI8wr8HSF/view?usp=sharing).

## Yield Farming

Yield farming is a DeFi-speciﬁc feature that refers to the various ways users generate rewards with cryptocurrencies by providing liquidity to liquidity pools and participating in DeFi protocols.

Whereas staking is about securing the network while earning rewards for doing so, yield farming focuses on earning a competitive yield using smart contracts, decentralized exchanges, token minting, liquidity-mining programs, etc.

### Bender Labs

Along with its wrapping protocol, [Bender Labs](https://www.benderlabs.io/) has created a [farming protocol](https://app.tzwrap.com/farming) with which **$WRAP** token holders can stake their coins to be rewarded with wTokens (wrapped ERC20 tokens on the Tezos blockchain).

Each time users wrap and unwrap ERC20/ERC721 tokens, fees are collected by the protocol in wTokens. For example, if a user wraps BUSD tokens (to wBUSD), they will pay fees in wBUSD. $WRAP token holders who use the wBUSD farming pool will get a portion of the wBUSD fees generated during the wrapping process.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrr38XV3kC22B3D%2F31.jpeg?generation=1632834594990676\&alt=media)

&#x20;                                       **Figure:** Some of the Wrap farming pools—Wrap protocol.

This project has been [reviewed and audited by Least Authority](https://leastauthority.com/static/publications/LeastAuthority_Wrap_Protocol_Smart_Contracts_Final_Audit_Report.pdf).

### Youves

[Youves](https://app.youves.com/) is a decentralized, [self-governing](https://docs.youves.com/governance/Governance-Mechanism), and [non-custodial](https://docs.youves.com/glossary/Glossary#noncustodial) platform dedicated to the creation and management of synthetic assets that are secured by [eligible collaterals](https://docs.youves.com/collateralManagement/Collateral-Management-Details#eligibleCollateral).

Users can become [minters](https://docs.youves.com/syntheticAssets/lifecycle/Minting-and-Burning) by posting and locking tez as collateral in a vault and creating synthetic assets. The ﬁrst synthetic asset will be a [stable token](https://docs.youves.com/syntheticAssets/stableTokens/StableToken-Introduction), the **$uUSD.**

The stable tokens can be sold or transferred to other parties. Minters have the opportunity to leverage their cryptocurrency exposure as they can sell their stable tokens against cryptocurrencies, which increases their exposure to the relevant cryptocurrency price. Holders of stable tokens can diversify their volatile cryptocurrency asset exposure without having to access the ﬁat currency world.

The self-governing aspect will be managed by a governance token, the **$YOU**. Youves currently oﬀers three services:

* Minting: Users can mint new synthetic assets and be rewarded in YOU tokens and new freshly baked tez. As of August 2021, only uUSD is available at the mintery and the trade marketplace.
* Saving: uUSD can be bought in a marketplace and locked in a savings contract to earn interest in uUSD.
* Staking: When staking YOU tokens, users are rewarded in uUSD. YOU tokens oﬀer the possibility to participate in the YOU platform governance.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrsGLFmcnFMzRcQ%2F32.jpeg?generation=1632834595048181\&alt=media)

&#x20;                                                         **Figure:** Youves’ protocol web interface.

This project has been [reviewed and audited by Least Authority](https://github.com/youves-com/youves-smart-contract/blob/main/audits/09212021-LeastAuthority-TezosFoundationSyntheticAssetPlatformSmartContractsFinalAuditReport.pdf).

### NFT Marketplaces

An NFT ⁹ (Non-Fungible Token, under the “FA2” standard on Tezos) is a digital asset that represents an asset whose main feature is to be unique. It can represent a fully digital asset or the certiﬁcation of a real-world one, such as a piece of art.

At the time of writing, the NFT market is expanding rapidly and we are witnessing increasing interest for this new blockchain use case. NFTs on Tezos are unique in that they are cheap and environmentally sustainable thanks to the Liquid Proof-of-Stake-based consensus algorithm of the Tezos blockchain.

NFT marketplaces enable collectors, artists, and art amateurs to share their common passion: Art. On those marketplaces, it is possible to trade and collect art pieces smoothly and eﬀectively.\
\
\[9]: For more information about NFTs, visit: <https://adoption-support.nomadic-labs.com/wp-content/uploads/2021/07/NFT-2.pdf>

### Hic et Nunc

[Hic et Nunc](https://www.hicetnunc.xyz/) is currently one of the most active NFT marketplaces in the world. It has a very engaged community that selected Hic et Nunc and Tezos because its members care about sustainable art.

At the time of writing, more than 233,000 art pieces have been minted on Hic et Nunc since its creation in early 2021.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrtZmlKfnbzkqHr%2F33.jpeg?generation=1632834594991370\&alt=media)

&#x20;                                                                **Figure:** Hic et Nunc marketplace.

During Hic et Nunc’s ﬁrst 45 days, NFT traders won **$hDAO** tokens for interacting on the marketplace.

Hic et Nunc’s platform charges a 2.5% fee on each $hDAO transaction to maintain the platform and support its developers. In the near future, $hDAO tokens will be used to increase artwork visibility and perform artwork trades without using tez.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrusJihD2bPUV4e%2F34.png?generation=1632834595057303\&alt=media)

&#x20;                                        **Figure:** Minting an artwork on Hic et Nunc (limit 40MB).

Minting an art piece on Hic et Nunc costs 0.08 XTZ ($0.30 on June 11, 2021). Royalties are chosen by artwork issuers. Hic et Nunc ensures sustainable earnings by charging fees each time an artist’s work is exchanged on the secondary market.

This project has not been reviewed and audited as of August 2021.

### Kalamint

[Kalamint](https://kalamint.io/) is another popular NFT marketplace on Tezos.

It has the same core principles as Hic et Nunc but requires a sign-up process to access the service. Artists and collectors can trigger and participate in auctions.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrvMGz14aLSXgzE%2F35.jpeg?generation=1632834595050559\&alt=media)

&#x20;                                                                **Figure:** Kalamint’s platform.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrwmP6XBJnmyTJ8%2F36.jpeg?generation=1632834594980009\&alt=media)

&#x20;                                             **Figure:** Kalamint’s minting process (limit: 50MB).

Minting artworks on Kalamint costs approximately 0.2 tez.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrxyIxyp3k6IJAW%2F37.jpeg?generation=1632834594988949\&alt=media)

&#x20;                                                           **Figure:** A Kalamint artwork sheet.

Creators choose whether to list their artwork. Once an artwork is listed for sale, the creator can delist it at any time (a feature also available on Hic et Nunc).

This project has not been audited as of August 2021.

### Objkt

[Objkt.com](https://objkt.com/) is a secondary market of NFTs that provides art auctions and aggregation of NFTs from various platforms including [Kalamint](https://kalamint.io/), [Hic et Nunc](https://www.hicetnunc.xyz/), [tzColors](https://www.tzcolors.io/), [Interpop](https://www.interpop.io/), and [BazaarNFT](https://bazaarnft.xyz/). It also makes it easier for the Tezos community to buy and sell artwork from the Hic et Nunc marketplace. Henceforth, collectors can gather their collections in one place.

The platform currently oﬀers two kinds of auctions:

* English auctions.
* Dutch auctions.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdry2HVvExhvc88a%2F38.jpeg?generation=1632834595025174\&alt=media)

&#x20;                                                                **Figure:** Objkt’s web interface.

In the future, Objkt.com plans to create an independent marketplace with its own infrastructure.

This project has not been audited as of August 2021.

## Games

### 1. Interpop

[Interpop](https://www.interpop.io/) is a company that forges the future of digital fandom with comic, game, and collectible NFTs minted responsibly on the Tezos blockchain.

The team behind Interpop builds games and entertainment brands using true digital ownership to redeﬁne fandom through digital collectibles and experiences.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWdrzR92o7qqgxNnB%2F39.jpeg?generation=1632834595067861\&alt=media)

&#x20;                                                                **Figure:** Interpop applications.

To date, Interpop has built four projects, three of which are available at the time of writing:

#### Play with BRIO

[Play with BRIO](https://tezos-staging.doublecoconut.com/home) is a Solitaire game allowing players to play against each other and earn tez.

Players connect themselves with their social accounts, link their *tz* addresses, or purchase tez directly on the platform using Ramp bridge and then play the game.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWds-7NBmU9QR6Sj2%2F40.jpeg?generation=1632834594995376\&alt=media)

&#x20;                                                                **Figure:** Brio’s dashboard.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWds0BWdji7A3qVks%2F41.jpeg?generation=1632834594992025\&alt=media)

&#x20;                                                    **Figure:** XTZ purchase with Ramp interface.

This project has not been audited as of August 2021.

#### Interpop Comics

[Interpop Comics](https://www.interpop.io/projects/interpop-comics/) allows users to build digitally native comics diﬀerently with true digital ownership of their titles, using NFTs. It is possible to sell or trade digital comics just like people would with the physical ones they bought in a comic store.

It is also possible to enjoy comics for free in the e-reader, then buy the whole issue as an NFT. With this ownership comes the ability to engage with the content and have a hand in directing the story’s outcome.

Readers will have power over decisions that range from the cosmetic to the cosmic through voting. Which costume do you like best? Does the hero stop to read this message? Who should join the team? Who was most responsible for a character’s death? These choices will have real consequences and a lasting impact on the outcome.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWds1KaMjzbs8R1kE%2F42.jpeg?generation=1632834595064980\&alt=media)

&#x20;                                                         **Figure:** Interpop Comics’ interface.

This project has not been audited as of August 2021.

#### MinterPop

[MinterPop](https://minterpop.com/) is an NFT art and collectibles marketplace built on the Tezos blockchain. It is possible to buy and collect NFT art from a curated roster of contemporary and pop creators, as well as trade NFT users’ own art on MinterPop’s user-to-user marketplace.

Interpop believes that buying and owning NFTs should be easy. Creating an account is as simple as registering email or social media accounts and logging in. MinterPop also creates a web wallet for users when they register.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-MkgWRkRk-OVbSBPEngl%2F-MkgWds2_pvAzCEf47g6%2F43.jpeg?generation=1632834595051408\&alt=media)

&#x20;                                                                **Figure:** MinterPop’s interface.

This project has not been audited as of August 2021.


# Non-Fungible Tokens (NFTs) on the Tezos blockchain

## Introduction

On March 13, 2021, Christie’s auction house’s ﬁrst sale of a digital piece of art emphasized the current traction for Non-Fungible Tokens (**NFTs**). That artwork was sold for 69 million USD, which was a record-breaking price for an NFT.

**NFTs** provide ownership management features for digital assets. That doesn’t eliminate the risk of copies, forgeries, or creation stealing, but it makes these things harder and thus helps to protect buyers, creators, and platforms.

A token is a representation of a physical or virtual asset.

There are two broad classes of assets: **fungible** and **non-fungible**.

* A **fungible token** is composed of units that are indistinguishable and interchangeable. [Gold is a fungible asset, since (for example) a standard 12.5 kg gold ingot is equivalent to any other ingot of the same weight](https://en.wikipedia.org/wiki/Fungibility).
* A **non-fungible token** is composed of units that are distinct and non-interchangeable. It can be represented by an NFT. The Mona Lisa is a non-fungible asset. There’s only one; even an excellent copy is still not the Mona Lisa. A token representing ownership of the Mona Lisa shouldn’t be interchanged for a token representing ownership of a copy of it.

## Non-fungible tokens

An [NFT](https://en.wikipedia.org/wiki/Non-fungible_token) consists of data stored on a digital ledger to certify a digital asset as unique, indivisible, and not interchangeable.

It can be stored on a blockchain and used to represent a digital artwork, an ownership certiﬁcate of a tangible asset, or any other property of a non-fungible asset - be it material, cultural, electronic, and so forth.

The value of an NFT depends on the value of the asset that it denotes: an NFT representing the Mona Lisa is likely to be worth more than one representing a copy of the Mona Lisa. That is not because the original is necessarily prettier than the copy; but because the copy is not the original.

As we’ll demonstrate in this document, NFTs can be issued and exchanged smoothly and quickly on the Tezos blockchain. Furthermore, buyers can prove swiftly and easily that they own an NFT, simply by making a query to the blockchain. So, for example, a process that traditionally might involve several hours looking up title deeds stored in a bank vault could be automated using blockchain to be done in microseconds with a few taps on a computer or mobile phone.

## FA2 standard

On the Tezos blockchain, the token standard for creating NFTs is the [FA2 standard](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-12/tzip-12.md). The FA2 standard allows the management of fungible tokens and NFTs within the same contract. However, its use is also adapted to interact only with NFTs. Each token is associated with a unique ID (identiﬁer) and metadata.

Metadata is useful information related to a smart contract, for example, the symbol of a token, the name of a token, an external link to a website, etc.

This standard allows simple management of NFTs, and it’s the Tezos equivalent of the Ethereum ERC1155 standard. Most of the Tezos NFT contracts implement this standard.

## NFT platform and tools on Tezos

Here is a list of NFT projects currently available on Tezos:

* [**Hic et nunc**](https://www.hicetnunc.xyz/): the most popular NFT marketplace on Tezos. There are more than 500,000 NFTs available on their platform by September 2021. Hic et Nunc is mostly oriented towards art-related NFTs.
* [**Objkt.com**](https://objkt.com/): an auction market enabling to sell Hic et nunc artworks ad various pieces from artists.
* [**Kalamint**](https://kalamint.io/): curated marketplace for all sorts of NFTs (art, collectible cards, music, etc. ).
* [**tzNFT**](https://assets.tqtezos.com/docs/token-contracts/fa2/2-fa2-nft-tutorial): a toolbox for creating your own NFTs.
* [**Openminter**](https://tqtezos.medium.com/introducing-openminter-3e9c1777cd47)**:** a toolbox for creating your own NFT platform.
* [**tzcolors**](https://www.tzcolors.io/): auction marketplace allowing you to buy rare colors as NFTs.

### Hic et nunc

A fast and simple solution to create an NFT on the Tezos blockchain is to use an NFT marketplace.

To create an NFT on Hic et Nunc, you need to connect to your favorite wallet and load your digital art piece.

You can set a title, description, tags, and price for your NFT...

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fknowledge-center%2F-Mk2TX5e5rEQ_oofTUDH%2F-Mk2U36P9netfzsBu1Vb%2F4.png?generation=1632146048681781\&alt=media)

Once all the information have been ﬁlled in, we can create our NFT. Royalties are mandatory on Hic et Nunc, and can be set from 10 to 25 percent.

<div align="left"><img src="https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-Mk2TX5e5rEQ_oofTUDH%2F-Mk2W4g6nay1Bkd_FakH%2FCapture%20d%E2%80%99%C3%A9cran%20de%202021-09-20%2016-02-41.png?alt=media&amp;token=afe613e0-54f9-462f-b30f-9bf362fa90d7" alt=""></div>

Metadata will store information regarding the current content of the NFT, where it’s stored, and the information you provided during the creation. Creating an NFT on Tezos costs around 0.08 tez, which would be around 0.23 EUR as of June 4, 2021.

### Openminter

OpenMinter is a free and open-source DApp framework enabling the creation and collection of NFTs on Tezos. Its features include browsing and marketplace capabilities.

OpenMinter relies on Minter SDK for its smart contracts, but it only implements two of them: the NFT collection and the Sales smart contract. Minter SDK provides many more, but they’re not implemented in OpenMinter yet. You can ﬁnd the rest of the smart contracts [here](https://github.com/tqtezos/minter-sdk/tree/main/packages/minter-contracts).

When you create an NFT with OpenMinter, it creates a collection containing that NFT and sets you as the owner of both the collection and the NFT. If you decide to list it for sale, the NFT becomes the property of the Sales smart contract. At that point, you don’t own it anymore. To be able to get the ownership back, you need to cancel the sale listing with the dedicated entry point.

Here’s a list of useful documentation regarding OpenMinter:

* **OpenMinter Github**: <https://github.com/tqtezos/minter>
* **Minter SDK**: <https://github.com/tqtezos/minter-sdk/>
* **Medium**: <https://tqtezos.medium.com/introducing-openminter-3e9c1777cd47>

### tzNFT

Another option could be to install tzNFT, which is a command-line tool for creating NFTs. It provides the following features:

* **Mint** an NFT
* **Inspect** an NFT
* **Transfer** an NFT

Every time you create a new NFT collection, it creates a new smart contract. Once created, it won’t be possible to add or remove tokens; only transfers will be available. With Hic et nunc, this tool relies on [IPFS](https://ipfs.io/) decentralized storage for storing NFT metadata. This is a very interesting option if you don’t want to pay any fees and have full control over your NFT.

| Solutions comparison (non-exhaustive) | tzNFT | Openminter | Hic et nunc | Objkt.com |
| ------------------------------------- | ----- | ---------- | ----------- | --------- |
| mint                                  | ✅     | ✅          | ✅           | ❌         |
| buy/sell                              | ❌     | ✅          | ✅           | ✅         |
| collections                           | ✅     | ✅          | ✅           | ✅         |
| browsing                              | ❌     | ✅          | ✅           | ✅         |
| royalties                             | ❌     | ❌          | ✅           | ✅         |
| DAO token                             | ❌     | ❌          | ✅           | ❌         |
| edit NFT metadata                     | ❌     | ❌          | ❌           | ❌         |
| metadata search                       | ❌     | ❌          | ❌           | ❌         |
| auctions                              | ❌     | ❌          | ❌           | ✅         |

## Interactions

You can interact with an NFT through its original contract. Contract entry points deﬁne the possible actions, which are generally as follows:

* **creation/destruction**: it’s usually possible in centralized or open contracts.
* **transfer**: it allows token transfers between peers.
* **swap**: atomic and decentralized swap. This can only be done for tokens inside the same contract (it can also include a transaction).
* **delegation**: it allows a trusted external party to manage the tokens.

## Tickets and NFTs

Since the integration of the Edo Amendment into the Tezos blockchain in early 2021, a new type of data has emerged: the [ticket](https://docs.nomadic-labs.com/nomadic-labs-knowledge-center/tickets-on-tezos). A ticket has three intrinsic properties:

* it **contains** the **address** of the **contract** that created it,
* it **cannot** be **modiﬁed**,
* it **cannot** be **duplicated**.

That allows the ticket to materialize and interact with a token within the blockchain outside its original contract. A token represented by a ticket can then be exchanged outside its original contract. Its authenticity is guaranteed by its address of origin, corresponding to the contract that created it. Tickets would be a great solution for managing the ownership of multisig NFTs or NFT collections. Instead of having a complex multi-signature process, you could just verify that the signer's address owns a speciﬁc ticket to grant access. It could also greatly facilitate the setup of a permissioned structure for an NFT or NFT collection.


# Home Base DAO

BaseDAO is a generic smart contract framework enabling DAO deployments on Tezos. This document aims to describe the **baseDAO** tool and its features.

## Description of the tool

The framework contains 3 customizable FA2 compliant DAO smart contract templates:

* TrivialDAO: a simple template to get familiar with DAOs.
* RegistryDAO: an arbitrary data key-value storage. It can also hold XTZ and FA2 tokens with a how-to spend logic.
* TreasuryDAO: a DAO that holds XTZ and FA2 tokens with a how-to spend logic.

### Features

**baseDAO** is a turnkey solution which contains a set of tools to compile and deploy DAO smart contracts on the Tezos blockchain.

In order to use **baseDAO**, the **tezos-client** must be set up with the matching node and wallet configuration.

### Ledger

Every address that is stored in the ledger is associated with its unfrozen token balance and frozen token balance. When unfrozen tokens are transferred, the balance of the *from\_* addresses is decreased and the balance of the *to\_* addresses is increased according to the transferred values.

### Life cycle of the DAO smart contract

The contract constantly cycles between two stages, a *proposing\_stage* and a *voting\_stage*. Both have the same length, *voting\_period* and alternate between each other, starting from \\"voting\\" for period number 0. Tokens can be frozen in any period, but they can only be used for voting, proposing and unfreezing starting from the following one and onwards.

#### Proposals

Everyone can make a new proposal, however, you have to freeze some tokens for that. The proposer specifies how many frozen tokens they want to stake and this value is checked by the contract according to its compile-time configuration. This can only be performed in a proposing stage period, meaning one that's **odd-numbered** and the proposer must have frozen his tokens in one of the preceding periods. Proposals are identified by a key which is a byte value computed via **Blake2B** hashing function of a pair of proposed *entrypoint,* *parameters* and the *proposer address*.

#### Voting

Once a proposal is submitted, everyone can vote on it as long as they have enough frozen tokens to stake. One frozen token is required for one vote. A vote can only be cast in a voting stage period, meaning one that's **even numbered**. Moreover the proposal vote on must have been submitted in the proposing period immediately preceding and the voter must have frozen his tokens in one of the preceding periods. Voting period is specified for the whole smart contract and can be updated by the administrator; on update, the existing proposals are also affected. It's possible to vote positively or negatively. After the voting ends, the contract is "flushed" by calling a dedicated *entrypoint*.

![Source: https://medium.com/tezos-weekly-spotlight/exploring-homebase-a-dao-framework-for-tezos-with-gregory-rocco-7b7c0ba2ca20](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-Meemac_Ul0g9B3J2gij%2Flifecycle.png?alt=media\&token=f8d07663-92ee-42d1-8661-28802bfdb5c9)

## Deploying your DAO

### Configuration and deployment with CLI

In this example we will use the TreasuryDAO smart contract on Edo2net using the **baseDAO** CLI. We need to specify our admin address and the name of our DAO:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemVHYck1V0zUrVL6e%2Fcommanddeploy.png?alt=media\&token=acb82fae-5a91-4eca-86eb-7f2532c11135)

Result:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemWVZgk-5-o0ftkZx%2FdeployTreasury.png?alt=media\&token=3205cba6-e0bc-4af3-b494-f2c47931782f)

The deployed version of the DAO smart contract can be found here : <https://better-call.dev/edo2net/KT1CBJDRLQdK7hUDgWDDx6eCp76xBSLGLCED/operations>

#### baseDO Typescript API

A TypeScript API is also provided to facilitate the interactions with the deployed DAO smart contract : <https://github.com/tqtezos/baseDAO/tree/master/typescript/baseDAO>

### Homebase UI

#### Presentation

Homebase is a platform designed to let users create and manage DAOs on the Tezos blockchain. There is a live deployed version of Homebase DAO available here : <https://tezos-homebase.herokuapp.com/explorer/daos> This version is connected to Edo2net.

It is based on the **baseDAO** smart contracts. To be able to let users directly deploy smart contracts from its UI, Homebase embeds the compiled Michelson versions of the **Treasury** and **Registry** DAOs of **baseDAO**.

#### Deployment

To match the CLI deployment we did, we will also deploy the Treasury DAO, using the Homebase UI. Let's start by clicking on **CREATE DAO**:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemaclNDN6mnaZz4Z6%2Fhombase0.png?alt=media\&token=9cd1b00e-40c9-4c30-b7b6-934eebf2d4fd)

Here, we have two choices, either the Treasury or the Registry DAO, we select the Treasury template and name our DAO token *MTD*:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemacksbM_5bGI3snF%2Fhombase1.png?alt=media\&token=087d22c5-b936-4793-8142-1054f6fa27fa)

We now need to specify our DAO logic, by customizing the proposal & voting processes:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemacjCt8AQLCJ5odE%2Fhombase2.png?alt=media\&token=8e87d081-1808-48e7-ab75-7ca547039ba0)

We decide of the initial distribution of the DAO tokens, and give ourselves 10 MTD:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemachOiGaOmTqVyvU%2Fhombase4.png?alt=media\&token=26221e39-274d-4bd7-ae72-e666ffe55e75)

You can find below the review of our DAO submission:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemacgOmvd9gk5MaRF%2Fhombase5.png?alt=media\&token=e3913a0f-6efb-4962-8468-1875347b9d99)

Let's now deploy our DAO smart contract using the Temple Wallet:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemacdOTkDyjGvbLUC%2Fhombase8.png?alt=media\&token=25b6a6ce-d1a6-4444-881e-8caf355175f7)

Our contract is now originated and available here: <https://better-call.dev/edo2net/KT1TfWzLTD3DjqyJxwb9JMp93i8WiWwruDrZ/operations>

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemacbJ8hcuniJkFUp%2Fhombase10.png?alt=media\&token=2e1d3978-72e9-495a-9bcc-0cdfdd9dd0de)

In the screenshot below, you will be able to find the dashboard of our DAO. On the top right corner of the UI, We can see our MTD balance of 10 MTD:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Meeg1UVEGFWXkuXBJ17%2F-MeelKC13N6nACC05LWH%2F-MeemacarG-XTyEdo4_E%2Fhombase11.png?alt=media\&token=3b2290cf-eac6-4926-9387-bc087eab0ff7)

The Homebase DAO UI offers several other features such as:

* Creating proposals
* Voting for proposals
* Checking past and current proposals
* View locked tokens
* View token holders
* ...

## Limitations

* With **baseDAO**, users need to be familiar with command-line tools, Tezos client, and Ligo language
* **baseDAO** depends on the package **morley-large-originator** which is heavy to build
* With **Homebase DAO**, there are currently only two available templates

## Other Tezos DAO initiatives

* StakerDAO: <https://www.stakerdao.com/>
* DAOBaker: <https://github.com/DAObaker>

## Sources

* Base DAO repository: <https://github.com/tqtezos/baseDAO>&#x20;
* Homebase DAO repository: <https://github.com/dOrgTech/homebase-app>&#x20;
* Homebase DAO live web application: <https://tezos-homebase.herokuapp.com/explorer/daos>&#x20;
* Tezos DAO Medium article: <https://medium.com/tezos-weekly-spotlight/exploring-homebase-a-dao-framework-for-tezos-with-gregory-rocco-7b7c0ba2ca20>


# Self-sovereign Identities

### :sparkles: Let's dive into the concept of Self-sovereign identity  <a href="#g3y0giuvosf" id="g3y0giuvosf"></a>


# Introduction

Digital and technological tools are ever more embedded in our daily lives. Use of smart objects has soared over recent years, putting a wide range of new and innovative products within easier reach.

In today’s constantly evolving digital ecosystem, we are using more and more apps, services, and digital platforms. When we use these services, we generally have to provide information about our identity. Users often underestimate the importance of controlling their personal data online. This explains why the most commonly used passwords tend to be very simple (for example, “abc123,” birthdays, names of pets and so on).

The more we interact online, the greater our potential exposure to cyber criminals.

Even if we take steps to protect our online data and passwords, we can still be vulnerable to more sophisticated cyber attacks. Many websites and businesses have had thousands or even millions of user passwords and pieces of private information breached by hackers.

History shows that we cannot blindly trust centralized entities to manage our data. This is why it is so important to come up with more resilient, decentralized management solutions, particularly where our identities are concerned.

Self-sovereign identity is a paradigm shift for digital identity, which promises significant advantages but over whose definition consensus has not yet been reached. In this document, we set out the attributes of self-sovereign identity offered by decentralized digital identity, as well as its digital properties.

\
**Definitions:**

**SSI – Self-sovereign Identity:** A cryptographic technology which allows individuals and organizations to confirm their identity. Self-sovereign identity is private and not shared.

**DID – Decentralized Identifier:** Set of identifiers enabling the creation of a verifiable decentralized digital identity. They are based on the SSI paradigm. A DID allows a person, organization, or data model to be identified and verified by a DID controller. These identifiers are designed to allow a DID controller to prove they have control of the DID.

**VCs – Verifiable Credentials:** A verifiable credential consists of information regarding the identification of:

* the subject of said credential (for example, a photo, name, or identification number),
* information relating to the issuing authority (for example, a local council, national agency, or certifying body),
* information regarding the type of document in question (for example, a Dutch passport, a US driving license or a health insurance card),
* information about the specific attributes or properties of the subject requested by the issuing authority (for example, their nationality, the vehicle categories they are licensed to drive, or their date of birth),
* proof of the origins of a legitimation card,
* information about any limits on the card (for example, the expiry date or conditions of use).

A verifiable credential can include the same information as a physical proof of identity (e.g. a driver licence, a fingerprint, or whatever is appropriate). The addition of technologies like digital signatures makes verifiable credentials more secure and reliable than their physical equivalents.

This document aims to give an outline of self-sovereign identities: **decentralized digital identity**, its main characteristics, risks, and the solutions currently available on the Tezos blockchain.


# Issues surrounding decentralized identity

An identity-management platform is a complex and sensitive tool. Its impact on the life of its users is highly significant and if poorly managed, the consequences can be serious. The risks involved should therefore be understood at the earliest opportunity, so that all the necessary protections can be put in place. These risks may vary depending on where the identity system is implemented. The issues differ according to the GDP and level of access to the Internet and digital technologies of the country in which such a solution is established.

The following list of risks was identified by the World Bank Group 5.

### Risk of exclusion <a href="#vaj1miimx9mg" id="vaj1miimx9mg"></a>

When a new ID system is put in place, one of the key elements is the strengthening of identification requirements for the population concerned. It is important to keep in mind that a population that was identified by nonofficial or informal documents in the old system risks being excluded from the new one due to being unable to meet its basic requirements (access to a reliable Internet connection or ownership of smart objects).

All research toward the development of a decentralized identity management system must include an analysis of the risks of exclusion in order to ensure that the majority of the population in question can benefit from it. This is particularly important for high-risk groups such as remote or isolated residents, minorities, disabled people, people with poor connections, and those unable to read or write.

It is therefore essential to take this sort of risk into account when devising solutions that could extend identification requirements.

### Invasion of privacy and security breaches <a href="#kbzoall11zrl" id="kbzoall11zrl"></a>

The risks of invasion of privacy are not specific to decentralized identity solutions; they are shared by any application that collects, stores, and uses personal data. Other dangers associated with the collection and use of personal data include the theft or misuse of data, fraud, identity theft, and discrimination.

Identity-management systems can be lucrative targets for hacking groups. Such systems must therefore be closely supervised and heavily regulated to ensure maximum security for users and their data. A “privacy-and-security-by-design” approach must be taken from the very beginning to ensure all the necessary protections are put in place.

An evaluation of privacy and security risks must be included in the planning process (for example, an analysis of the impact on data protection, penetration tests, and cybersecurity audits) and must continue throughout every stage of the implementation of the identification system.

### Audit <a href="#syurt4qdk0ar" id="syurt4qdk0ar"></a>

During audits, the decentralized identity solution must be capable of providing information on its users without compromising the basic principles of its system, namely decentralization, security, and anonymity. If the solution is used on a countrywide scale, the regulators must also be able to verify the actions of certain entities under certain conditions.


# Development of the notion of identity

The following presentation of different ID systems is inspired by the work of Omar Dib and Khalifa Toumi in their article “Decentralized Identity Systems: Architecture, Challenges, Solutions, and Future Directions” (Dib, Omar; Toumi, Khalifa, 22).

### Centralized identities <a href="#id-44hgi9qb7kx3" id="id-44hgi9qb7kx3"></a>

Centralized identity-management systems are based on the traditional paradigm whereby an entity holds its own ID system which allows it to manage access to its services. These entities are therefore responsible for collecting, storing, and using the personal data and identities of their users. This is the approach currently taken by most private and public organizations such as social networks, governments, banks, and websites.

![How a centralized identity system works](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2F8USriKwmHdyuiCLsVoFU%2FCapture%20d%E2%80%99%C3%A9cran%20de%202022-02-15%2019-49-08.png?alt=media\&token=2825cd41-b36a-4114-ac04-4013f51de21b)

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FHKee6HPSD1pusfgdE1H7%2F4?alt=media)

The above diagram represents how the vast majority of digital identity systems work: the authentication mechanism is principally based on the connection between a username and password. The username/password pair is usually stored in a database hosted by each service provider.

The quality of these data storage systems can vary widely, ranging from the top-quality, high-security systems used by governments, public institutions, and financial services to the often very poor-quality offerings of social media apps with little or no verification system.

This centralized and silo-based paradigm has enabled the rapid development of numerous online services, but its limits are becoming apparent, particularly in terms of security and confidentiality. As the information is managed by a single centralized entity, this entity is the only one with total control over that information and responsibility for its security. Yet these solutions are rarely interoperable, and they force users to have multiple identities because they have to create a new identity for every service they need to access.

According to a study by Digital Guardian published in 2020 (Lord), of 1,000 people surveyed in 2017:

* **29% of users said they didn’t know how many accounts they owned**, because they had too many to count
* In the USA, **each email address is used for an average of 130 different accounts**
* **20%** of those surveyed said they **used the same password everywhere**

This demonstrates that the fragmentation of identities presents a significant risk for users because of the multiple accounts created.

The centralization of an identity system also demands significant resources from the entity responsible for storing and protecting the data. In order to provide an adequate level of security to satisfy users and regulators, it must invest heavily in human and material resources and security measures.

### Federated identities <a href="#id-2zf3faibvlny" id="id-2zf3faibvlny"></a>

A federated identity system is a group of service providers who rely upon one single trusted centralized identity provider. In this scenario, the service providers accept the conditions, standards, and execution of the identity provider and build their own identity management based on these elements. Examples include the numerous websites that rely on the identities provided by well-known actors such as Facebook or Google to manage user sign-ins and accounts.

For users, this system has the advantage of simplifying how they handle their accounts and passwords. They only have to manage one single identity, established by the main provider, with which they can access numerous services.

![How a federated identity system works](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FrBkT61seMgfw7LCWPV1p%2FCapture%20d%E2%80%99%C3%A9cran%20de%202022-02-15%2019-51-33.png?alt=media\&token=5b7f0167-a392-4d0e-91bf-6636fd562188)

The confidence that the service providers place in federated identities will depend largely on the quality of the system and the reputation of the entity providing it.

Yet there are downsides to federated identities. Through their centralized identity management systems, service providers and the identity provider can trace the activities across different services.

### &#x20;<a href="#id-8at7qp5eeubv" id="id-8at7qp5eeubv"></a>


# Decentralized identifiers

### Decentralized identifiers <a href="#oaz2vu5ks409" id="oaz2vu5ks409"></a>

Now that we’ve covered the different components of decentralized identities, let’s take a closer look at decentralized identifiers and how they are used. The following is based on W3C’s definition of decentralized identifiers.

### Definition <a href="#j2xvu0jpsjgo" id="j2xvu0jpsjgo"></a>

Decentralized identifiers enable the creation of decentralized, verifiable digital identities. These identities can represent people, organizations, businesses, etc. The aim of these identifiers is to be completely decoupled from centralized or federated entities.

External entities may nevertheless play a part in the process, but in a much more limited way. Indeed, the only actions that can be taken by third parties are the issuing and verification of proofs. Furthermore, as we have seen, disclosing the proof will only involve sharing confirmation of the veracity of the information, without revealing the underlying information itself. The decision to disclose the proof is at the sole discretion of the data owner.

DIDs are [URIs](https://fr.wikipedia.org/wiki/Uniform_Resource_Identifier) that associate a DID subject with a DID document allowing identification and interactions associated with that subject.

As outlined above, each DID document can express cryptographic material, verification methods, or services that provide a set of mechanisms enabling a DID controller to prove control of the DID.

A DID is a text string consisting of three parts:

* a scheme identifier
* an identifier for the DID method
* a DID method-specific identifier attributed to the owner

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2F9wC2yBP0Dul1GRFKJyp4%2F7?alt=media)

The example DID above, taken from [W3C’s definition](https://www.w3.org/TR/did-core/#a-simple-example), represents a DID document. A DID document contains information associated with the DID, such as the means of cryptographically authenticating a DID controller. We will look at DID controllers in more detail later.

| <p>{</p><p>"@context": \[</p><p>"<https://www.w3.org/ns/did/v1>",</p><p>"<https://w3id.org/security/suites/ed25519-2020/v1>"</p><p>]</p><p>"id": "did:example:123456789abcdefghi",</p><p>"authentication": \[{</p><p>// used to authenticate as did:...fghi</p><p>"id": "did:example:123456789abcdefghi#keys-1",</p><p>"type": "Ed25519VerificationKey2020",</p><p>"controller": "did:example:123456789abcdefghi",</p><p>"publicKeyMultibase": "zH3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"</p><p>}]</p><p>}</p> |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

### Goals <a href="#id-9fdrt25cyovi" id="id-9fdrt25cyovi"></a>

Decentralized identifiers are essential components of verifiable credentials.

Let’s take a closer look at the design goals set out by W3C.

| **Goal**         | **Description**                                                                                                                                                                                                               |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Decentralization | Eliminate the requirement for centralized authorities or single point failure in identifier management, including the registration of globally unique identifiers, public verification keys, services, and other information. |
| Control          | Give entities, both human and nonhuman, the power to directly control their digital identifiers without the need to rely on external authorities.                                                                             |
| Privacy          | Enable entities to control the privacy of their information, including minimal, selective, and progressive disclosure of attributes or other data.                                                                            |
| Security         | Enable sufficient security for requesting parties to depend on DID documents for their required level of assurance.                                                                                                           |
| Proof-based      | Enable DID controllers to provide cryptographic proof when interacting with other entities.                                                                                                                                   |
| Discoverability  | Make it possible for entities to discover DIDs for other entities, to learn more about or interact with those entities.                                                                                                       |
| Interoperability | Use interoperable standards so DID infrastructure can make use of existing tools and software libraries designed for interoperability.                                                                                        |
| Portability      | Be system and network independent, and enable entities to use their digital identifiers with any system that supports DIDs and DID methods.                                                                                   |
| Simplicity       | Favor a reduced set of simple features to make the technology easier to understand, implement, and deploy.                                                                                                                    |
| Extensibility    | Where possible, enable extensibility provided it does not greatly hinder interoperability, portability, or simplicity.                                                                                                        |

### Architecture <a href="#id-1wlfrpvng9l8" id="id-1wlfrpvng9l8"></a>

In the previous section, we covered the main elements of a decentralized identity solution. We will now turn to the essential components of a DID.

The diagram below, taken from [the W3C definition](https://www.w3.org/TR/did-core/#architecture-overview), gives an overview of the architecture of a DID, as well as the relationship between the elements with which it interacts. The following descriptions of these elements are also taken from the W3C definition.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FO3Mx7d91CxOIESQhGZy7%2F8?alt=media)

#### DIDs and DID URLs <a href="#id-6pqxyxhzue0c" id="id-6pqxyxhzue0c"></a>

A decentralized identifier, or DID, is a URI composed of three parts: the scheme DID, a method identifier, and a unique, method-specific identifier specified by the DID method.

DIDs are resolvable to DID documents. A DID URL extends the syntax of a basic DID to incorporate other standard URI components such as path, query, and fragment, in order to locate a particular resource—for example, a cryptographic public key inside a DID document, or a resource external to the DID document.

#### DID subjects <a href="#ri7delxtc6is" id="ri7delxtc6is"></a>

The subject of a DID is the entity identified by the DID. The DID subject might also be the DID controller. The subject of a DID could be a person, group, organization, or even a concept.

#### DID controller(s) <a href="#z42c6t35t0ou" id="z42c6t35t0ou"></a>

The controller of a DID is the entity (person or organization) that has the capability—as defined by a DID method—to make changes to a DID document.

It is generally necessary to control a whole set of cryptographic keys in order to make these changes.

A DID may have more than one controller, and the DID subject can be the DID controller, or one of them.

#### Verifiable data registries <a href="#k96mr8scost6" id="k96mr8scost6"></a>

In order to be resolvable to DID documents, DIDs are typically recorded on an underlying system or network of some kind. Regardless of the specific technology used, any such system that supports recording DIDs and returning data necessary to produce DID documents is called a verifiable data registry. Examples include blockchains, decentralized file systems (such as IPFS), databases of any kind, peer-to-peer networks, and other forms of trusted data storage.

#### DID documents <a href="#ckahr51p8v6x" id="ckahr51p8v6x"></a>

DID documents contain information associated with a DID. They typically express verification methods, such as cryptographic public keys, and services relevant to interactions with the DID subject. A DID document can be serialized.

#### DID methods <a href="#np6jbn7a07tz" id="np6jbn7a07tz"></a>

DID methods are the mechanism by which a particular type of DID and its associated DID document are created, resolved, updated, and deactivated.

#### DID resolvers and DID resolution <a href="#ybmojg59l9cb" id="ybmojg59l9cb"></a>

A DID resolver is a system component that takes a DID as input and produces a conforming DID document as output. This process is called DID resolution. The steps for resolving a specific type of DID are defined by the relevant DID method specification.

#### DID URL deferencers and DID URL dereferencing <a href="#sxye30gtj4kc" id="sxye30gtj4kc"></a>

A DID URL dereferencer is a system component that takes a DID URL as input and produces a resource as output. This process is called DID URL dereferencing.


# Decentralized identity platforms

### Architecture <a href="#id-9brm0clvyp17" id="id-9brm0clvyp17"></a>

Entrepot DID = DID warehouse

Certificats DID = DID credentials

Resolveur DID = DID resolver

Client DID utilisateur = DID client user

Authentification DID = DID authentication

Applications et services = applications and services

#### Decentralized identifiers <a href="#nh470tyrvu5l" id="nh470tyrvu5l"></a>

As seen above, DIDs are identifiers that users create, hold, and control independently of any organization or government.

#### Decentralized systems <a href="#hzrcti9hs5no" id="hzrcti9hs5no"></a>

DIDs are based on decentralized systems which provide the necessary mechanisms and functionality for a decentralized identity solution to work.

#### User DID clients <a href="#id-8sogh87zlok" id="id-8sogh87zlok"></a>

DID clients are applications which allow people to use decentralized identities. They allow you to create DIDs, manage data and authorizations, and sign/validate requests linked to the DIDs.

#### DID resolvers <a href="#i2a204c9jw6w" id="i2a204c9jw6w"></a>

DID resolvers are servers which use a set of DID drivers to provide a standard DID lookup and resolution method, and return the DID document.

#### DID identity warehouses <a href="#yyhfb8se35sv" id="yyhfb8se35sv"></a>

A network of cloud servers and physical devices (cell phones, computers) which facilitate data storage and interactions with identities.

#### Verifiable DID credentials <a href="#dc57wpccdnf7" id="dc57wpccdnf7"></a>

Credentials signed by DID are based on standard formats and protocols, such as those defined by W3C. They allow identity owners to generate, present, and verify requests. This is the basis on which trust is established between users and the entities using these identities.

#### Decentralized applications and services <a href="#mfisddv5h46" id="mfisddv5h46"></a>

The DIDs associated with Identity Hub personal datastores enable the creation of a new category of apps and services. They store data with the user’s Identity Hub and work within the limits of the authorizations granted to them.

### Process <a href="#zfpq0md5tujb" id="zfpq0md5tujb"></a>

#### DID generation <a href="#id-7tu69m4i7qcn" id="id-7tu69m4i7qcn"></a>

The process of creating a DID is defined by each DID method. Some DID methods, like **did:key**, are purely generative, so that a DID and DID document are generated by turning a unique piece of cryptographic material into a standard form.

Other DID methods may require the use of a verifiable data registry, where the existence of the DID and DID document is only recognized by third parties after registration, as defined by the chosen DID method. Other processes may be defined by a particular DID method.

#### DID lookup and retrieval <a href="#war4n7ia9k7n" id="war4n7ia9k7n"></a>

A DID is a specific type of URI, thus it may refer to any resource. According to the norm \[[RFC3986](https://www.w3.org/TR/did-core/#bib-rfc3986)]: the term “resource” is used in a general sense to mean anything that could be identified by a URI. A resource is not necessarily accessible via the Internet.

The DID controller determines the DID subject. It should not be possible to determine the DID subject by looking at the DID itself, since DIDs can generally only be understood by machines and not humans. A DID is unlikely to contain information on the DID subject, so additional information on the DID subject is only discoverable by resolving the DID to the DID document and obtaining a verifiable proof on the DID.

The diagram below shows the process of lookup and retrieval through a DID Client.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FXGgHyzD3DtvIGiflHUy3%2F10?alt=media)

#### DID disclosure and authentication <a href="#z04s1e2il2hx" id="z04s1e2il2hx"></a>

The DID refers to the DID subject and resolves to the DID document (following the protocol specified by the DID method). The DID document is not a separate resource from the DID subject and does not have a URI separate from the DID. Rather the DID document is an artifact of DID resolution controlled by the DID controller for the purpose of describing the DID subject. This distinction is illustrated by the graph model below.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FaoxmhTPUVXYeowF0W9Kf%2F11?alt=media)

The authentication verification relationship is used to specify how the DID subject is expected to be authenticated, for purposes such as logging into a website or engaging in any sort of challenge-response protocol.

If authentication is established, it is up to the DID method or other application to decide what to do with that information. A particular DID method could decide that authenticating as a DID controller is sufficient to, for example, update or delete the DID document. Another DID method could require different keys or a different verification method entirely to be presented in order to update or delete the DID document than that used to authenticate.

#### Managing authorizations <a href="#id-6aaumm3ifb7a" id="id-6aaumm3ifb7a"></a>

Let’s look at a case where the DID subject is also the DID controller. This is the case when an individual or organization creates a DID to self-identify.

From a graph model perspective, even though the nodes identified as the DID controller and DID subject in the below figure are distinct, there is a logical arc connecting them to express a semantic equivalence relationship.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FYYMeBAkOjEVQFBcWM39X%2F12?alt=media)

In this case, the DID subject (also the controller) has total control over its DID document.

The second case is when the DID subject is a separate entity from the DID controller. This is the case when, for example, a parent creates and maintains control of a DID for a child; a corporation creates and maintains control of a DID for a subsidiary; or a manufacturer creates and maintains control of a DID for a product, an IoT device, or a digital file.

From a graph model perspective, the only difference from the figure above is that there is no equivalence arc relationship between the DID subject and DID controller nodes. In this case, the DID subject has no control over its DID document.

### &#x20;<a href="#q5tnfcid9z0j" id="q5tnfcid9z0j"></a>


# Tezos and decentralized identity

Below are the solutions that are currently being built on the Tezos blockchain.

### Spruce Systems <a href="#u2msbvc83ldp" id="u2msbvc83ldp"></a>

[Spruce Systems](https://www.spruceid.com/) is a company building an open-source accreditation framework conforming to W3C norms around decentralized identifiers. It is ready to be rolled out and extensible to the IT systems of businesses and governments.

Among their key products are:

* **Kepler:** A decentralized storage system which uses smart contracts to define where your data is stored and who can access it.
* **Credible:** a wallet with credibility (Apache 2.0) for self-sovereign identity.
* **DIDKit:** a multiplatform toolkit for working with decentralized identifiers and W3C verifiable credentials.
* **SSI:** A RUST library for decentralized identity.
* **Keylink:** a digital signature tool.

#### Tezos Profiles <a href="#id-3yhwhxi4nhkx" id="id-3yhwhxi4nhkx"></a>

[Tezos Profiles](https://tzprofiles.com/) is a web application developed by Spruce Systems, that helps Tezos users to regain control of their digital identity and use it on different platforms. It allows users to create verified profiles by proving control of their public social media accounts and self-attested information. These verified profiles are then linked to their Tezos accounts, allowing any platform to resolve and establish trusted information to reduce the risk of identity theft.<br>

Here’s an overview of the decentralized Tezos Profiles app:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2Fp79nL4Lpxg2m9OQdMqh6%2F13?alt=media)

A basic profile is created through the following stages:

1. The user connects to their Tezos wallet and completes their self-attested information. This could be simple information about themselves, or claiming ownership of social media accounts (Twitter, Discord, GitHub).

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FoV6DY7T0vhldcbaoFuoD%2F14?alt=media)

1. The user can then deploy their profile using the “Deploy Profile” button. In this example, we have only filled in the information concerning the “Basic Profile.”

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2Fnzm5BZPibhOe3qhDKuKG%2F15?alt=media)

1. The user must then accept the terms and conditions using the “Deploy” button.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2F8bSXZPghvZwOOBpv13xK%2F16?alt=media)

1. The application then asks the user to sign the information they are claiming ownership over using their wallet.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2F3S9xPHcKzMK7QX9oVsdb%2F17?alt=media)

1. The transaction deploying the smart contract corresponding to the user profile must then be submitted. The user profile controls the smart contract containing the URL and hashing of the contents of the claims. (Approximate cost: 0.23 tez.)

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FgSRVzNoNd4iVYqXICG5G%2F18?alt=media)

The profile is now deployed on the Tezos blockchain. The “View on TzKt” button allows you to see the contract on the Tezos blockchain.

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2Ftfwwab3rKAneoB5kJqx1%2F19?alt=media)

(Optional) The user can update the content of the smart contract and approve additional storage operations to update or delete requests. Users can also have greater control over the active contents of the contract by using their Tezos account, and even define the URL in the smart contract to point toward files on their own web host.

The ID information from tzProfiles is stored in a storage service on kepler.tzprofiles.com. The service can produce a public URL which anyone can access, allowing users to create, update, and delete data using their Tezos wallet to sign requests. Although bare instances of IPFS can be replicated by unknown parties, Kepler adds authorizations around IPFS to restrict replication so that users can delete their data and may reasonably withdraw if they wish to.

### &#x20;<a href="#ktyu1fezs1wr" id="ktyu1fezs1wr"></a>

### Talao <a href="#id-24lifcy18ngt" id="id-24lifcy18ngt"></a>

Talao is a self-sovereign identity solution which has implemented an easily integrable electronic wallet with minimal dependencies and regardless of its environment, whether for projects carried out by companies or by institutions. It aims to facilitate the widest possible take-up of self-sovereign identity concepts and technologies.

[Talao](https://www.talao.io/) offers the first smartphone wallet available on the Apple and Google stores that carries identity in the format of the Tezos network. The Tezos blockchain has many advantages for SSI identities, in particular that of open governance, high security, and a proof-of-stake consensus, which makes it one of the least energy-consuming in the world. This wallet allows all Tezos applications to offer their users an SSI identity to access their services.

Here’s what the wallet interface looks like on iOS:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FsWJlFSo7OfqA9GaEL2YE%2F20?alt=media)

By clicking on “Generate a new wallet,” you are given a recovery phrase (which must be kept secret) allowing your wallet to be identified:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2F5DHXUY7EY4OEIm0LYKee%2Ftalao2.png?alt=media\&token=35dbdcbb-ccb6-4776-9817-389c1097223e)

You can also modify your personal information in the application:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FDLGPUAM9t8jLIdxFyQY8%2Ftalao3.png?alt=media\&token=1ed675c6-bc27-49b0-918f-b2a38a2ac828)

In the general information section, we can see our DID with the Tezos address which has been generated for us:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FDTstOHj3ge3dQWrUtQ5X%2Ftalao4.png?alt=media\&token=9d1c8dd0-3e39-40ac-9652-31e9fe899fb8)

### Gravity <a href="#xlagi7pjxmfi" id="xlagi7pjxmfi"></a>

SSI solutions to promote financial inclusion

[Gravity](https://www.gravity.earth/) allows individuals, small businesses, and NGOs to gather their verifiable data in a digital wallet and build identities and trusted digital relationships that are private, portable and persistent.

Based on Spruce’s stack, the project operates in three key areas: identity for humanitarian aid, financial inclusion, and governmental identity.

Gravity also incorporates:

* **DIGID:** Dignified Identities in Cash Programming, developed with the Norwegian Red Cross and Save the Children.
* **Educational credits:** Developed with the UNPD, these credit letters will be granted to Syrians in temporary protection in Turkey.

### TezID <a href="#b9yl0p591ejg" id="b9yl0p591ejg"></a>

[TezID](https://tezid.net/) is an identity oracle on the Tezos blockchain. It allows users to prove ownership of certain digital assets such as email addresses, telephone numbers, etc.

TezID is a smart contract containing registered addresses and verified proofs for each of these addresses. Users can register their address as well as their various proofs. The oracle is used to verify these proofs.

How to use TezID?

The user connects their wallet to the TezID app:

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2FCo3Xkq08qkwShMjfURYa%2Ftezid1.png?alt=media\&token=a28dd148-5b88-426f-8c1e-85491ff6294f)

They register the data over which they want to claim ownership (email, phone number, address):

![](https://2844416659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Meeg1UVEGFWXkuXBJ17%2Fuploads%2F9VucDzWdZKWhilSt8Prv%2Ftezid2.png?alt=media\&token=057d9c2c-6353-44ae-a02a-c98e5f48c42d)

The user then registers one of the supported proofs with the TezID Smart Contract and requests a verification code from the oracle.

The oracle verifies the uniqueness of the property (you cannot register the same email twice). The oracle sends a verification code to the property.

The user receives the verification code and enters it in the TezID app.

Finally, the oracle marks the proof as verified in the Smart Contract.

This solution can be used from other Smart Contracts to verify that a Tezos address is associated with a real human being.

### &#x20;<a href="#g3y0giuvosf" id="g3y0giuvosf"></a>


# Sources & bibliography

### Sources <a href="#g3y0giuvosf" id="g3y0giuvosf"></a>

<https://id4d.worldbank.org/global-dataset>

<https://blogs.worldbank.org/voices/global-identification-challenge-who-are-1-billion-people-without-proof-identity>

<https://id4d.worldbank.org/sites/id4d.worldbank.org/files/2018-08/ID4D%20Data%20Notes%20revised%20082918.pdf>

<https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RE2DjfY>

<https://www.microsoft.com/en-us/security/business/identity-access-management/decentralized-identity-blockchain>

<https://consensys.net/blockchain-use-cases/digital-identity/>

<https://esource.dbs.ie/handle/10788/3647>

<https://www.cs.bgu.ac.il/~frankel/TechnicalReports/2016/16-02.pdf>

<https://www.tandfonline.com/doi/full/10.1080/14650045.2020.1823836>

<https://documents.worldbank.org/en/publication/documents-reports/documentdetail/727021583506631652/global-id-coverage-barriers-and-use-by-the-numbers-an-in-depth-look-at-the-2017-id4d-findex-survey>

<https://documents.worldbank.org/en/publication/documents-reports/documentdetail/248371559325561562/id4d-practitioner-s-guide>

<https://www.mastercard.com/news/europe/en-uk/newsroom/press-releases/en-gb/2019/march/new-mobile-money-propositions-have-the-potential-to-reduce-the-world-s-unbanked-population-by-more-than-a-third/>

<http://financial-inclusion.com/wp-content/uploads/2019/03/MCC1-FinInc-Report-Screen.pdf>

<https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3785452>

<https://www.adaltas.com/fr/2019/01/23/identites-auto-souveraines/>

### Bibliography <a href="#j8s0zh1wy1y0" id="j8s0zh1wy1y0"></a>

Consenys. “Blockchain in Digital Identity.” <https://consensys.net/blockchain-use-cases/digital-identity/>. Accessed June 2021.

Dib, Omar; Toumi, Khalifa. *Decentralized Identity Systems: Architecture, Challenges, Solutions and Future Directions*. 2020, <https://papers.ssrn.com/sol3/papers.cfm?abstract\\_id=3785452>.

Lord, Nate. “Uncovering Password Habits: Are Users’ Password Security Habits Improving? (Infographic).” *DATA INSIDER, Digital Guardian's blog*, 29 September 2020, <https://digitalguardian.com/blog/uncovering-password-habits-are-users-password-security-habits-improving-infographic>. Accessed 23 July 2021.

Metz,Anna Zita; Clark,Julia Michal.2019. *Global ID Coverage, Barriers, and Use by the Numbers: An In-Depth Look at the 2017 ID4D-Findex Survey*. 2019, <https://documents.worldbank.org/en/publication/documents-reports/documentdetail/727021583506631652/global-id-coverage-barriers-and-use-by-the-numbers-an-in-depth-look-at-the-2017-id4d-findex-survey>.

Microsoft. *Decentralized Identity, Own and control your identity*. 2018, <https://www.microsoft.com/en-us/security/business/identity-access-management/decentralized-identity-blockchain>.

Simon Hardie. *Unravelling the web of inclusion*. Mastercard, 2019, <http://financial-inclusion.com/wp-content/uploads/2019/03/MCC1-FinInc-Report-Screen.pdf>.

van Bokkem, D., Hageman, R., Koning, G., Nguyen, L. and Zarin, N.,. *Self-sovereign identity solutions: The necessity of blockchain technology*. 2019, <https://arxiv.org/pdf/1904.12816.pdf>.

VYJAYANTI T DESAI; ANNA DIOFASI; JING LU. “The global identification challenge: Who are the 1 billion people without proof of identity?” 2018,

<https://blogs.worldbank.org/voices/global-identification-challenge-who-are-1-billion-people-without-proof-identity>.

World Bank Group. *ID4D Practitioner’s Guide*. 2019, <https://documents.worldbank.org/en/publication/documents-reports/documentdetail/248371559325561562/id4d-practitioner-s-guide> &#x20;


# EuroTz

## What is a CBDC?

Central Bank Digital Currency (CBDC ) is a digital form of fiat money, likely to be implemented on a distributed ledger to better control the issuance, flows, and ownership of the digital currency. CBDCs are not yet a standardized term and no rule-making, however, we can recognize some characteristics: &#x20;

* Central bank-issued digital money and a liability**¹** of the central bank&#x20;
* Backed by the government in the same way that current forms of fiat currency are backed
* Distinct from existing accounts at Federal Reserve Banks

**\[1]:** Liabilities are what the bank owes to others. Specifically, the bank owes any deposits made in the bank to those who have made them. The net worth or equity of the bank is the total assets minus total liabilities. ([The full article](https://courses.lumenlearning.com/wm-macroeconomics/chapter/banking-profits-and-losses-name/)).

## What is EuroTz?

Started in February 2020, EuroTz is a Proof of Concept proposal to build a collateralized Euro stable coin on the Tezos Blockchain.

* It is a token that can be used on the Tezos public Blockchain or

  on a Tezos private Blockchain;
* It is **backed 1:1 by euro fiat deposits made in reputable banks ²**;
* It is auditable in real time (the 1:1 backing is verifiable in

  real time);
* It can be emitted by a duly licensed and regulated financial

  institution based in the EU.

**\[2]:** For each coin issued on the blockchain, one equivalent monetary unit, also known as fiat (EURO, USD, GBP, etc) is escrowed.

## What are the functionalities and purposes of EuroTz?

* First, it creates a Euro backed digital currency(100% covered by

  euro deposits in a hive-off account via PSD2 standard) that can

  ease interbank exchanges and consequently exchanges between

  consumers.
* On top of this stable coin can be built a software ecosystem

  allowing to tokenize OTC derivatives (bonds, options, structured

  products...);
* It offers a secure mechanism of Delivery versus Payment(DvP) to

  ensure a well unwound of digital assets trading.
* One of the most innovative aspects is the possibility for a

  digital asset owner to swap its asset for another one, while

  downplaying fees and securing the swap.

## What is Delivery versus Payment (DvP)?

Delivery versus payment is a mechanism that links a securities transfer and a fund transfer in such a way as to ensure that delivery of securities occurs only if payment of funds occurs,

* It provides compliant, atomic and flexible transactional features

  with no intermediaries;
* It can automatically handle reporting and regulatory requirements

  and all the post-deal lifecycle steps;
* It is traceable and fully supports AML and KYC can provide market

  data to products requiring them and connectivity to secondary

  markets supporting heterogeneous products;

Smart contract securities that will be created on the Tezos blockchain can embed this functionality.

## How settlement is performed on the blockchain?

First, through a retailer platform, a consumer who wants to buy EuroTz has to connect to his traditional bank account(in euro) via the PSD2 standard and receive the equivalent amount in EuroTz on his Tezos wallet.

However, the consumer doesn't necessarily need to be familiar with the native Tezos address or hold a Tezos account, the transfer management will be managed in the backend by a Feeless transfer/approval contract process.

## How is Camunda BPM used to assume compliance?

* Provide Business Process management/statistics that help to manage

  the euroTz Back-office interaction.
* Transactions are translated into business workflows
* At each process step, an administrator can have a global view of

  the current transactions state in real time, so he can perform

  manual verifications on the transactions (KYC / AML, verification

  of sufficient funds of an address. This process offers a

  compliance mechanism to euroTz ).

**Camunda BPM (Business Process Manager)**: an open-source workflow and decision automation platform.

## How events are managed on euroTz?

A contract called EventSink is used as an alternative to the events. After each successful transfer or approval, an internal call to the eventSink contract is fired as an event summarizing information relevant to the event.

## Sources

* <https://gitlab.com/tezos-paris-hub>
* <https://gitlab.com/tezos-paris-hub/eurotzfrontend>
* <https://gitlab.com/tezos-paris-hub/eurotz-euro-stable-coin>


# Whitelist smart contract

## 🌊 Intro

#### This repository provides an implementation of Whitelist interface proposed in the [TZIP-15](https://gitlab.com/tzip/tzip/-/blob/tzip-15-whitelist/proposals/tzip-15/tzip-15.md) written in [SmartPy](https://smartpy.io/): Python library for constructing Tezos SC and compiled to Michelson code. The contract is migrated from the [Lorentz whitelisting contract](https://github.com/tqtezos/lorentz-contract-whitelist).

## 💡 Why a whitelist contract?

The purpose of the Whitelist contract is to validate transfers so the token's contract holder can control which users can perform such operations. The Whitelist contract contains a list of `users` and `entities` that have satisfied the euroTz KYC/AML compliance procedures and thus are eligible to hold euroTz Tokens.

## 🔔 Specifications

#### `UserID`

As userID, we use the user's public key hash, e.g. a `tz1 address`.

### Storage

• `whitelists`:

```
big_map (
         key = whitelistID: Nat,
         value = {
         unrestricted: Bool,
         allowedWhitelists: set(whitelistID)
        })
```

• `users`:

```
big_map (
         key = userID: address,
         value = whitelistID : Nat
        )
```

• `admin`: address

• `issuer`: address

### 🚀 We use the interface as an on-chain wrapper:

1. The whitelist contract is deployed separately from our euroTz contract.
2. The assertion entrypoints are called from euroTz contract, without requiring callbacks since they call `FAILWITH` when they fail.

### How does our wrapper whitelist SC work?

🎥 ***Main scenarios:***

1. `Issuer` may transfer to `bob` **ONLY** if `bob`'s is an asserted receiver, in other words, bob must be added to the `users` big\_map and his `whitelistID` must be set and `unrestricted` in the `whitelists` big\_map.
2. `Alice` may transfer to `Bob` **ONLY** if `bob` and `Alice` are asserted users AND `Bob`'s whitelistID is in `Alice`'s `allowedWhitelists`.

## ⬇️ Get the Project:

1. Clone the project & cd to the directory;
2. Install the packages with `yarn install`.

## 🔍 EntryPoints  (SC methods):

| EntryPoint           | Params (type / desc.)                                                            | Permission | Type        |
| -------------------- | -------------------------------------------------------------------------------- | ---------- | ----------- |
| addUser              | `address (address) / whitelistID (option(nat))`                                  | Admin      | Management  |
| setWhitelistOutbound | `whitelistID (nat) / option(allowed_whitelists (set) / unrestricted (bool))`     | Admin      | Management  |
| setAdmin             | `address (address)`                                                              | Admin      | Management  |
| setIssuer            | `address (address)`                                                              | Admin      | Management  |
| getAdmin             | `address (address / KT1 view contractAddress)`                                   | Any        | Informative |
| getIssuer            | `address (address / KT1 view contractAddress)`                                   | Any        | Informative |
| getWhitelist         | `address (address / KT1 view contractAddress) / whitelistID (nat)`               | Any        | Informative |
| getUser              | `address (address / KT1 view contractAddress) / address (address / userAddress)` | Any        | Informative |
| assertReceiver       | `address (address)`                                                              | Any        | Assertion   |
| assertReceivers      | `set (set(address))`                                                             | Any        | Assertion   |
| assertTransfer       | `from_ (address) / to_ (address)`                                                | Any        | Assertion   |
| assertTransfers      | `set (set({from_: address, to_: address}))`                                      | Any        | Assertion   |

*Visit* [*TZIP-15*](https://gitlab.com/tzip/tzip/-/blob/tzip-15-whitelist/proposals/tzip-15/tzip-15.md#entrypoints) *to get a more developed description of the whitelist contract entrypoints.*

## 👀 Tests Cases

#### The smartContract tests are written in smartPy and in JS (with Taquito, Mocha and Chai)

> To launch tests, you have to:

1. Originate the whitelist contract with:

   ```
    yarn originate-whitelist
   ```
2. Paste the address of the originated whitelist SC in the conf file under `/conf` as following:

```
whitelistContractAddress: KT1-whitelist-address
```

1. Originate the euroTz contract with:

   ```
    yarn originate-euroTz
   ```
2. Paste the address of the originated euroTz SC in the same conf file as follows:

```
euroTzContractAddress: KT1-euroTz-address
```

🎉 **You're ready to launch tests now\...**

> *The following tests use as*

*• whitelist contract address:* [*KT1PFj9vshZKrHYLCswxUXKtY89SDYkXThDC*](https://you.better-call.dev/carthagenet/KT1PFj9vshZKrHYLCswxUXKtY89SDYkXThDC/operations)

*• euroTz contract address:* [*KT1WcxYBrh9WwRo1vkbSJxAqr6ZVAUqDEiFg*](https://you.better-call.dev/carthagenet/KT1WcxYBrh9WwRo1vkbSJxAqr6ZVAUqDEiFg/operations)

#### Management entrypoints

```
    yarn test-setAdmin # Test setAdmin entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: SetAdmin Entrypoint tests
initialAdmin:  tz1SVqTz7entj982jDSKcTQNgT7f2cg7C8dk
------------------------------------------------------------
MESSAGE STATEMENT:  only admin may update
✓ Update admin as non-admin / Should fail (4409ms)

OpHash :  oo5ofnco8QxcMtjm4Xo3Px93knyssQBLhL2bCTeKHUSbpWW7fX3
Admin from storage:  tz1XrCvviH8CqoHMSKpKuznLArEa1yR9U7ep
✓ Update admin as admin / Should succeed (27855ms)

OpHash :  oom91CsjUhFs9ThaSP2S2NgtYK4UT5HnceEHwr27i6bn3kvxeMX
Admin from storage:  tz1SVqTz7entj982jDSKcTQNgT7f2cg7C8dk
✓ Reset old admin as admin / Should succeed (46817ms)
3 passing (1m)
✨  Done in 82.75s.
```

```
    yarn test-setIssuer # Test setIssuer entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: SetIssuer Entrypoint tests
initialIssuer:  tz1SVqTz7entj982jDSKcTQNgT7f2cg7C8dk
------------------------------------------------------------
MESSAGE STATEMENT:  only admin may update
✓ Update issuer as non-admin / Should fail (5824ms)

OpHash :  ooERfBcJPaByiUdrhvidyHZEkZ2ki68LbVMz2mbPWrSJMfDwvzU
Issuer from storage:  tz1XrCvviH8CqoHMSKpKuznLArEa1yR9U7ep
✓ Update issuer as admin / Should succeed (38408ms)

OpHash :  oooiEXQCbmtAFYZpqvDKbJzeyXvYGYqWatTfGxCYdxxZona1gZz
Issuer from storage:  tz1SVqTz7entj982jDSKcTQNgT7f2cg7C8dk
✓ Reset old issuer as admin / Should succeed (52151ms)
3 passing (2m)
✨  Done in 101.61s.
```

```
    yarn test-addUser # Test addUser entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: AddUser Entrypoint tests

MESSAGE STATEMENT:  only admin may update
✓ Add user as non-admin / Should fail (2832ms)

MESSAGE STATEMENT:  issuer is not a user
✓ Add Issuer as a standard user as admin / Should fail (3734ms)

OpHash :  opVy3boRogtgpU2fz4wjgMwNEYxogymqGRqsUFzPdc7WChEzviq
✓ Add User with None as admin / Should succeed (16585ms)

OpHash :  ooZvAefYT4Q7bqi8K2AJQY1QWi3neMZVxEVqXGeAzsN52pHVKtz
userWhitelistID: 10
✓ Add user with Some as admin / Should succeed (116256ms)

4 passing (2m)
✨  Done in 142.39s.
```

```
    yarn test-setWhitelistOutbound # Test setWhitelistOutbound entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: SetWhitelistOutbound Entrypoint tests

MESSAGE STATEMENT:  only admin may update
✓ Set Whitelist Outbound as non-admin / Should fail (3120ms)

OpHash:  ooczsae6WA6xDTGYVhUuk4SS1WC55CFeqcBtPkdhGkVQjfqnrR6
whitelistDetails:  { allowed_whitelists: [], unrestricted: true }
✓ Set Whitelist Outbound as admin with Some / Should succeed (177318ms)

OpHash: onjtUV2b4KWD67hNawDmKkndh1Hwa4JWDYmg83iXCrhn4ZDrGMB
whitelistDetails:  {allowed_whitelists: [ 555 ], unrestricted: true}
✓ Update existing outbound whitelists as admin / Should succeed (36756ms)

OpHash:  oooTfhZYiiMQUjPpsTMXXdH6KUUQu6a5a4KDqV2k9BPaha798o6
✓ Remove outbound whitelist as admin / Should succeed (25887ms)

4 passing (4m)
✨  Done in 247.35s.
```

#### Informative entrypoints

```
    yarn test-viewEntryPoints # Test getters entryPoints
```

#### Test Output:

```javascript
Whitelist Smart Contract: Informative Entrypoints tests

viewOpHash :  ooZZfDBazuXBiUsE2Vc3NAfg6f9eWPFdA6RooXqDtguajvpFGiY
Admin from view contract storage:  tz1SVqTz7entj982jDSKcTQNgT7f2cg7C8dk
✓ Get Admin Address / Should succeed (84910ms)

viewOpHash :  oofULds4jJv6DyWw6v2nnh3FCogfgZhNvPwPTyica45zZzQAvzD
Issuer from view contract storage:  tz1SVqTz7entj982jDSKcTQNgT7f2cg7C8dk
✓ Get Issuer Address / Should succeed (16055ms)

viewOpHash :  op2rGJ3L2oczuUnkfshRetWgAkGSj2Zr6nahuGyzbAHfSJ3wNpw
Whitelist details from view contract storage:  { allowed_whitelists: [], unrestricted: true }
✓ Get WhitelistDetails / Should succeed (111324ms)

viewOpHash :  onq4VEiZ6q3SVKp8p1k7fya7auSL2m8WNaaUiphGi6XdJ2hv1NP
whiteListID from view contract storage: 444
✓ Get User whitelist ID / Should succeed (75185ms)

MESSAGE STATEMENT:  whitelist not found
✓ Get inexistent WhitelistDetails / Should fail (2839ms)

MESSAGE STATEMENT:  user not found
✓ Get inexistent User / Should fail (4059ms)

6 passing (5m)
✨  Done in 302.18s.
```

#### Assertion entrypoints

:warning: ***In order to mint some euroTz tokens to the\*\*\*\* ****`Issuer`****, you must launch the\*\*\*\* ****`assertReceiver`**** ****test before the**** ****`assertTrasnfer`**** \*\*\*\*one.***

```
    yarn test-assertReceiver # Test assertReceiver entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: AssertReceiver Entrypoint tests

opHash :  onsWLrfWngr7PGLjYTJWUE5Fn1N2pGcd8uWPXQb1b2G9TCRqLKn
✓ Assert receiver Issuer - Admin mints 50 euroTz to the Issuer / Should succeed (66577ms)

MESSAGE STATEMENT:  user not on a whitelist
✓ Assert receiver inexistent User - Admin tries to mint 40 euroTz to an inexistent user / Should fail (4432ms)

OpHash :  op5bsabpVa8FNszZJWmXi5TpDyYjz3AViovU1J3dMafo3Vha6m7
✓ Admin adds Ouss in users big_map (26387ms)

MESSAGE STATEMENT:  whitelist does not exist
✓ Assert receiver existing User, his associated whitelistID don t refer to an existing whitelist - Admin tries to mint 40 euroTz / Should fail (5517ms)

OpHash :  oodR5jieVi7enfGoVkUZcJdVnep5fyya7DFGQ576rJZzbtSEoAs
✓ Admin sets Ouss s whitelist outbound initally restricted (26856ms)

MESSAGE STATEMENT:  outbound restricted
✓ Assert receiver existing User, his associated whitelist is restricted - Admin tries to mint 40 euroTz to whitelisted restricted user (Ouss) / Should fail (2814ms)

OpHash :  oneyu5hcCPQopgvuQ2KsV4AjJLrNjkh2iKCWi96tuB9VceChcJX
✓ Admin sets Ouss s whitelist outbound unrestricted (106327ms)

opHash :  ooRxZ5HtiEfwtSrMpYgzJ6qWyt6qap87ThpRFP2mNpfjyughTH9
✓ Assert receiver existing User, the associated whitelistID refers to an existing whitelist and unrestricted - Admin mints 50 euroTz to Ouss: whitelisted unrestricted user / Should succeed (26285ms)

8 passing (4m)
✨  Done in 270.13s.
```

```
    yarn test-assertReceivers # Test assertReceivers entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: AssertReceivers Entrypoint tests

MESSAGE STATEMENT:  user not on a whitelist
✓ Assert receivers with one inexistent user / Should fail (3127ms)

OpHash :  ooHWW4VusZTuiDREUuXefX7rLbAQw1PZe38Vz8qJXJDdMTTeCDc
✓ Admin adds Khaled in whitelst contract (75338ms)

MESSAGE STATEMENT:  whitelist does not exist
✓ Assert receivers with one user s whitelistID don t refer to an existing whitelist / Should fail (3524ms)

OpHash:  oo5W1bhrJmmSrv97mc5mS3Ee7Kqgbgu71vxJTYh1JW4jpM7QgZx
✓ Admin sets Khaled s whitelist outbound restricted (26590ms)

MESSAGE STATEMENT:  outbound restricted
✓ Assert receivers with one user s whitelist restricted / Should fail (6387ms)

OpHash :  opZcnwmQvBPiHReqad11vSB3iFZbto4i5aBsUAH1Ck8k23gxCoQ
✓ Admin sets Khaled s whitelist outbound unrestricted (55717ms)

OpHash:  opCXZZmrC4esizqy5trQgTPv3gKv4yE7SHmXMpXRzfgvWcgufV9
✓ Assert receivers: all users are existing and unrestricted / Sould succeed (35641ms)

7 passing (5m)
✨  Done in 324.29s.
```

```
    yarn test-assertTrasnfer # Test assertTrasnfer entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: AssertTransfer Entrypoint tests

MESSAGE STATEMENT:  user not on a whitelist
✓ Assert Transfer from Issuer to an inexistent user - Issuer tries to transfer 9 euroTz to Fred / Should fail (3379ms)

OpHash :  oozZLubPscjt5ed9YaQi61Mfq94xNLAYC6bruTy3u2zHvcZSDcR
✓ Admin adds Fred in whitelst contract (91502ms)

MESSAGE STATEMENT:  whitelist does not exist
✓ Assert Transfer from Issuer to an existing user with whitelistID don t refer to an existing whitelist - Issuer tries to transfer 9 euroTz to Fred / Should fail (5575ms)

OpHash:  ooykfX3jCuioSabk69PV9BpLdxT5BCT7sbJMZB2sRH4sAogk6sW
✓ Admin sets Fred s whitelist outbound initally restricted (18412ms)

MESSAGE STATEMENT:  outbound restricted
✓ Assert Transfer from Issuer to existing, restricted user - Issuer tries to transfer 9 euroTz to Fred / Should fail (7536ms)

OpHash:  opMY1NtPZC9tmJAP2PCZqXQ6jfzKL6S5XDVvJpu6sYNjPHf8qvD
✓ Admin sets Fred s whitelist outbound unrestricted (36973ms)

euroTzTrasnferOpHash:  onxrnAwMs63ZvQKvG5T2GVhohfTuWdVcbKFLq9qQwzPgzTww5tS
✓ Assert Transfer from Issuer to an existing, unrestricted user - Issuer transfers 9 euroTz to Fred / Should succeed (27318ms)

MESSAGE STATEMENT:  user not on a whitelist
✓ Assert Transfer from existing to an inexistent user - Fred tries to transfer 3 euroTz to Safwen / Should fail (4771ms)

OpHash :  ooeXt7h7WrTsWNhFvwM4MJngD4pWb6eoCiLyDw3GmztBG1WkQU3
✓ Admin adds Safwen in whitelst contract (77621ms)

MESSAGE STATEMENT:  whitelist does not exist
✓ Assert Transfer between: Two existing users with sender s whitelistID don t refer to an existing whitelist - Fred tries to transfer 3 euroTz to Safwen / Should fail (3318ms)

OpHash:  op6oNdbhSAKixx795dQrogrDC9hzKYJissrJVBZbVeZ4Ldij8Kf
✓ Admin sets Safwen s whitelist outbound unrestricted (106412ms)

OpHash:  oobQx7dVeYVtTBs9WSSiBBD4onMQPcHcXwCSwc1nJgDqL7a9hU6
✓ Admin sets Fred s whitelist outbound restricted (61054ms)

MESSAGE STATEMENT:  outbound restricted
✓ Assert Transfer between: Two existing users while sender is restricted -  Fred tries to transfer 3 euroTz to Safwen / Should fail (3590ms)

OpHash :  ooYvVeAkfasz18E7F935WYeG1B5Ur9RgjHWhJr4ohqtAoxPtDHD
✓ Admin sets Fred s whitelist outbound unrestricted and contains Safwen (31729ms)

euroTzTrasnferOpHash :  oorXEA6UpHcQhaFYp51sT11SYf6mpDMbvYDXKfwGawbUDEe5fKP
✓ Assert Transfer between: Two existing users, sender and receiver are unrestricted, receiver s whitelistID is in the sender s whitelist - Fred transfers 3 euroTz to Safwen / Should succeed (22084ms)

15 passing (8m)
✨  Done in 507.14s.
```

```
    yarn test-assertTrasnfers # Test assertTrasnfers entryPoint
```

#### Test Output:

```javascript
Whitelist Smart Contract: AssertTrasnfers Operation Testing


MESSAGE STATEMENT:  user not on a whitelist
✓ Assert list of transfers with one inexistent sender / Should fail (4333ms)

MESSAGE STATEMENT:  user not on a whitelist
✓ Assert list of transfers with one inexistent receiver / Should fail (2927ms)

OpHash :  opTmp7RmzQS3BypxzahgsjtzemypbLVXiepgsNGgXHqzJGLwecg
✓ Admin adds Daly to users big_map in whitelist contract (16347ms)

MESSAGE STATEMENT:  whitelist does not exist
✓ Assert list of transfers with one sender s whitelistID don t refer to an existing whitelist / Should fail (3160ms)

OpHash:  oo9HkTbzfvffz8Zi6Avj4rAXqDysC4TtnpcDZt3zEde4vGKRQxU
✓ Admin sets Daly s whitelist outbound restricted (25520ms)

MESSAGE STATEMENT:  outbound restricted
✓ Assert list of transfers with one restricted sender & restricted receiver / Should fail (2629ms)

OpHash:  op5s6LJTAPrBZ5FvDvNz5KC1V3mpHquef2N5BYP5deFhi5c6FLG
✓ Admin sets Daly s whitelist outbound unrestricted (74910ms)

MESSAGE STATEMENT:  outbound not whitelisted
✓ Assert list of transfers with one transfer where the receiver s whitelistID is not in the sender s whitelist / Should fail (2550ms)

OpHash:  opEixE7d7tZF9XUcBP7ob6fSj91ifiYm4g4CBuFe43sszKK1TdP
✓ Admin adds Thib to Daly s whitelist (34924ms)

OpHash:  oo7ss2kbjivZvchJKRUWdyDGa5LTCJ6Ditb5jFUX6h7wj6pCWVS
✓ Assert list of transfers: all senders & receivers are existing and unrestricted, all receivers are whitelisted in the senders' whitelists / Should succeed (2662ms)

10 passing (8m) 
✨  Done in 490.57s.
```

## 👮 Roles:

1. **Admin**: the contract's owner and manager, he can:

   • Set a new contract's `admin`;

   • Set a new contract's `issuer`;

   • Add / Update / Delete any user in the `users` big\_map;

   • Add / Update / Delete any whitelist in the `whitelists` big\_map.
2. **Issuer**:

   • Can't be explicitly added to `users`;

   • Is always `unrestricted`;

   • Whose `allowedWhitelists` is the set of ALL `whitelistId`'s

## 🔗 Implementations

* An implementation of wrapping and non-wrapping forms in Lorentz may be found [here](https://github.com/tqtezos/lorentz-contract-whitelist)
* A partial implementation of the compile-time wrapping form in LIGO may be found [here](https://github.com/tqtezos/ligo-contract-whitelist)


# Rarible

Nomadic Labs, [Edukera](https://www.edukera.com/) and [Functori](https://www.functori.com/) worked on the integration of Tezos in the[ Rarible NFT marketplace](https://rarible.com/) regarding the Bakend, SDK and smart contracts parts.

For further details, please find the repositories below:

* Smart contracts: <https://gitlab.com/tezos-paris-hub/rarible/rarible-smart-contracts>
* Backend: <https://gitlab.com/tezos-paris-hub/rarible/rarible-backend>
* FA2 templates: <https://gitlab.com/tezos-paris-hub/rarible/rarible-nft-contracts>


# Recommended tooling

## Official repositories

* <https://gitlab.com/tezos/tezos>
* <https://gitlab.com/nomadic-labs/tezos>
* <https://hub.docker.com/r/tezos/tezos>

## Official documentation

* <https://tezos.com/developer-portal>
* <https://tezos.gitlab.io/>
* <https://tezos.gitlab.io/michelson-reference/>

## Setting up dependencies

<https://tezos.gitlab.io/introduction/howtoget.html#setting-up-the-development-environment-from-scratch>

## Running a node

Using Docker and Flextesa: <https://assets.tqtezos.com/docs/setup/2-sandbox/>

Using sources: <https://tezos.gitlab.io/user/sandbox.html>

## Running a baker

Plug and play tools:

* Bake Buddy: <https://bakebuddy.xyz/>
* Kiln: <https://tezos-kiln.org/>

## Interacting with Tezos nodes

### CLI

Using `tezos-client` from sources: <https://tezos.gitlab.io/user/sandbox.html>

Using `tezos-client` from packages: <https://github.com/serokell/tezos-packaging>

Using `tezos-client` from binaries: <https://assets.tqtezos.com/docs/setup/1-tezos-client/>

### Libraries

* **Taquito - TypeScript library suite** <https://tezostaquito.io/>
* **TzStats - indexer and API** <https://tzstats.com/docs/api#tezos-api>
* **TzKT - indexer and API** <https://api.tzkt.io/>
* **Conseil - indexer and API** <https://github.com/Cryptonomic/Conseil>
* **ConseilJS - library for building apps in TypeScript and JavaScript** <https://cryptonomic.github.io/ConseilJS/#/>
* **ConseilPy - Python toolkit for Conseil indexer and API** <https://github.com/baking-bad/conseilpy>
* **Morley - Developer tools for Michelson** <https://gitlab.com/morley-framework/morley>
* **TezosKit - Swift SDK for iOS, macOS, and iPadOS** <https://github.com/keefertaylor/TezosKit>
* **KotlinTezos - Android/Kotlin toolbox** <https://gitlab.com/camlcase-dev/kotlin-tezos>
* **PyTezos - Python SDK** <https://github.com/baking-bad/pytezos>
* **Sotez - JavaScript library** <https://github.com/AndrewKishino/sotez>
* **Magic - passwordless wallet connector for apps** <https://docs.magic.link/advanced/tezos/get-started>
* **Beacon - wallet connector for apps** <https://www.walletbeacon.io/>
* **TezBridge - wallet connector for apps** <https://docs.tezbridge.com/>
* **Go Tezos- Go library** <https://github.com/goat-systems/go-tezos>
* **TezosJ - Android Java SDK** <https://github.com/TezosRio/TezosJ_SDK>
* **TezosJ Plain Java - Java SDK** <https://github.com/TezosRio/TezosJ_plainJava>
* **Netezos - .Net Standard 2.0 library** <https://github.com/baking-bad/netezos>

## Writing and building smart contracts

* **Python** | <http://smartpy.io>
* **Pascal, OCaml, ReasonML** | <https://ligolang.org/>
* **Haskell** | <https://indigo-lang.gitlab.io/>
* **Domain-Specific** | <https://archetype-lang.org/>
* **Language of Tezos Smart Contracts** | <https://michelson.nomadic-labs.com/>

## Explorers

* **TzStats** <https://tzstats.com/>
* **tezblock** <https://tezblock.io/>
* **Arronax** <https://arronax.io/>
* **TzKT** <https://tzkt.io/>
* **TezTracker** <https://teztracker.everstake.one/mainnet>
* **TezEdge - Tezos Node Explorer** <https://tezedge.com/#/network>
* **Tezos Notifier Bot (Telegram)** <https://t.me/TezosNotifierBot>
* **Better Call Dev - Smart Contract Explorer** <https://better-call.dev/>
* **SmartPy Contract Explorer** <https://www.smartpy.io/dev/explorer>
* **Misualizer - Smart Contract Explorer** <https://misualizer.tezbridge.com/>
* **Tezos Hubble Explorer** <https://hubble.figment.network/tezos>
* **Baking Bad - Delegation Explorer** <https://baking-bad.org/>
* **Mininax** <https://mininax.io/mainnet>
* **Blockchair** <https://blockchair.com/tezos>

## Tools

* **SmartPy IDE** <https://smartpy.io/dev/>: Online editor to write smart contracts in SmartPy.
* **Try-Archetype:** <https://gitpod.io/#https://github.com/edukera/try-archetype>: Online editor to write smart contracts in Archetype.
* **LIGO IDE** <https://ide.ligolang.org/>: Online editor to write smart contracts in LIGO.
* **sol2ligo Transpiler** <https://madfish-solutions.github.io/sol2ligo/>: Tool to migrate Solidity smart contracts to LIGO.
* **Tplus** <https://tplus.dev/tplus>: Tool to manage Tezos environments (sandboxes and public nodes).
* **Michelson - IntelliJ** <https://www.plugin-dev.com/plugins/tezos-michelson/>: Michelson Plugin for IntelliJ.
* **Michelson Emacs Mode** <https://github.com/tezos/tezos/tree/master/emacs>: Michelson Plugin for Emacs.
* **Granary** <https://stove-labs.github.io/granary/>: Tezos Development Toolkit.
* **Truffle** <https://www.trufflesuite.com/docs/tezos/truffle/quickstart>: Development environment, testing framework, and asset pipeline.
* **Tezster** <https://github.com/Tezsure/Tezster-CLI>: Testing tool for Tezos.
* **Magic's Testnet Faucet** <https://magic-tezos-faucet.now.sh/>: A simple faucet for a Tezos Testnet.
* **Testnet Faucet** <https://faucet.tzalpha.net/>: Faucet for a Tezos testnet.
* **Mainnet Faucet** <https://faucet.tezos.com/>: Faucet for the Tezos Mainnet.
* **Testnet Faucet Bot** <https://t.me/tezos_faucet_bot>: Telegram Faucet Bot for Tezos testnets.
* **Tezos Giga Node** <https://tezos.giganode.io/>: Reliable and geographically distributed Tezos public node infrastructure.
* **TezosLive** <https://www.tezoslive.io/>: GraphQL API to the Tezos Node RPC.
* **Nautilus Cloud** <https://nautilus.cloud/>: A full suite of tools to develop and deploy Tezos applications.
* **Tezos Link** <https://tezoslink.io/>: Scalable API access to the Tezos network.

## Education/Training

* **Sol2Ligo handbook** <https://madfish-solutions.github.io/sol2ligo-course/#/>: Learn Ligo and write Tezos smart contracts with the interactive tool. Convert your Solidity contracts to Ligo easily.
* **Blockmatics SmartPy Developer Course** <https://training.blockmatics.io/p/tezos-smartpy-developer-course/>: Blockmatics’ SmartPy Developer Course teaches the basics of SmartPy and the SmartPy IDE.
* **Cryptoverse Wars (SmartPy)** <https://cryptocodeschool.in/tezos/overview>: Cryptoverse Wars is a fun interactive code school developed by BUIDL Labs that teaches developers how to write smart contracts in SmartPy.
* **Tezos Academy (LIGO)** <https://tezosacademy.io/>: Tezos Academy is a fun interactive tutorial developed by OCTO Technology on how to code smart contracts in LIGO.
* **Tezos Training at Nomadic Labs** <https://training.nomadic-labs.com/training.html>: After running successfully through all the steps of this training session, you will be able to run a Tezos node (test network/sandboxed), use the Michelson emacs mode, and compile pieces of code in both LIGO and SmartPy.
* **TQ Digital Assets Portal** <https://assets.tqtezos.com/docs/intro/>: This documentation aims to help developers streamline the implementation, integration, and use of digital assets on Tezos.
* **Getting Started with LIGO** <https://medium.com/coinmonks/getting-started-with-ligo-13ea2c4e844e>: These tutorials by Claude Barde walk-through how to create smart contracts on the Tezos blockchain using the LIGO language.
* **Cryptonomic Developer Portal** <https://cryptonomic.tech/developers.html>: Cryptonomic’s tech stack makes it easy to develop and deploy Tezos applications.
* **An Introduction to Michelson** <https://medium.com/better-programming/introduction-to-michelson-the-language-of-tezos-part-1-374c03394cc3>: These tutorials by Claude Barde walk-through how to use the Michelson programming language and write smart contracts on Tezos.
* **Michelson Labs** <https://michelson.baking-bad.org/>: Series of Jupyter notebooks for learning the Tezos native contract language.
* **PyTezos Labs** <https://pytezos.baking-bad.org/>: Series of Jupyter notebooks for learning Tezos internals with Python.
* **CoinList-Tezos Hackathon Workshops** <https://www.youtube.com/playlist?list=PLZYHxOo6wufh2XacXH2YyeSecR3qMk0lH>: Online workshops from the development teams of tools such as Truffle, Magic, SmartPy, LIGO, and more.
* **Tezos Developer Documentation** <https://tezos.gitlab.io/>: A complete Tezos documentation resource for developers.
* **TezEdge Tezos documentation** <https://docs.tezedge.com/introduction/tezos>: A documentation resource by the TezEdge team.
* **TQ Tezos Wiki** <https://wiki.tezosagora.org/>: A Tezos wiki by the TQ Tezos team. Learn about Tezos basics, proof-of-stake in Tezos, governance, smart contracts, and more.

## Wallets

* **Temple Wallet** <https://templewallet.com/>: Cryptocurrency wallet for the Tezos blockchain

  as a Web Extension for your Browser.
* **Kukaï:** <https://wallet.kukai.app/>: A software wallet enabling social network authentication.
* **Galleon** <https://cryptonomic.tech/galleon.html>: A software wallet for Desktop.
* **Umami** <https://umamiwallet.com/>: A software wallet for Desktop.
* **Ledger** <https://www.ledger.com/staking-tezos>: An hardware wallet.

## Helm charts

* **tezos-helm-chart** <https://github.com/tqtezos/tezos-helm-charts>
* **tezos-k8s-helm-chart** <https://github.com/tqtezos/tezos-k8s#tezos-k8s-helm-chart>

## Node monitoring

* **tezos-metrics** <https://gitlab.com/nomadic-labs/tezos-metrics/>
* **net-dada** <https://www.netdata.cloud/>
* **prometheus** (need net-data and tezos-metrics both installed) <https://prometheus.io/>
* **grafana** (need prometeus installed) <https://grafana.com/>

## Formal verification

* [**https://gitlab.com/nomadic-labs/mi-cho-coq/blob/master/doc/talk\_15\_10\_2019/talk\_multisig.pdf**](https://gitlab.com/nomadic-labs/mi-cho-coq/blob/master/doc/talk_15_10_2019/talk_multisig.pdf)
* [**https://gitlab.com/nomadic-labs/mi-cho-coq/**](https://gitlab.com/nomadic-labs/mi-cho-coq/)<br>


# Installation & data volume

## What is the size of the Tezos Blockchain?

The greediest mode is "archive", today it takes around 80GB There are also "rolling" and "full" nodes, with which you can launch your tezos node thanks to a recent snapshot of the blockchain. For snapshots taken the 14th of September 2020, it weighs between 474Mb (rolling node) and 4,7Gb (full node) and a few minutes to set up.

## What is the size of each block?

The maximum size for a block is 512kB, with one block per minute in the Edo protocol.

## How much does the blockchain grow per day?

Since it depends on the activity on the blockchain, there is no fixed value. On the other hand, there is a block created every minute and a block max size is 512kB, the maximum it could increase in a day would be 737,28 MB.

## What is the minimum required hardware for a node?

We recommend the following:

* Server available 24/7 with stable internet connection
* At least 8 GB of RAM
* SSD disk (preferably with more than 100 GB storage)


# Network flow

## What are the data exchanged between the nodes?

Nodes relay the operations (transfers, SC origination, ...) and blocks they receive (or sometimes create) from other nodes. Since the nodes can't be trusted, they also check every information they receive. They communicate only with a subset of all the nodes in the network that can vary over time.

### What are the nodes default ports?

The main port which the node is listening on by default is 9732.


