# Economics and rewards

In this chapter, we will dig deeper into the fees of the Tezos network and the baking and attesting rewards. The calculations you'll learn about are helpful from the simplest transaction issuance to the most complex application built on Tezos. That is why it is important to understand the basics of fees and gas optimizations. Of course, this will be particularly useful if you are a baker.

## Transaction cost​

Each transaction on Tezos has a cost for the user. To account for this, the user must include a gas fee when submitting transactions. Bakers will then choose transactions using a minimal fee filter. If the baker chooses a transaction, he will add it to the block and propagate it. The fee is therefore used to pay the bakers. They are calculated by using the following formula [1]:

Let:

• Minimal Fees: $\text{min}_{F}$
• Size of the operation (in bytes "$\text{B}$"): $\text{s}$
(The size "$\text{s}$" is the number of bytes in the complete serialized operation).
• Gas used for the operation (in gas unit "$\text{g}_u$"): $\text{g}$
• Minimal nano-tez per byte: $\text{min(nꜩ/B)}$
• Minimal nano-tez per gas unit: $\text{min(nꜩ/}\text{g}_u\text{)}$
Gas unit cost in Tez is defined by the protocol. It does not depend on the fee market; it does not depend on arbitrary defaults in config files; etc [2]

Then:

$\text{Fees}\geq\text{min}_{F}+\text{min(nꜩ/B)}\times\text{s}+\text{min(nꜩ/}\text{g}_u\text{)}\times\text{g}$

The transaction default values are:

• $\text{min}_{F}=\text{100 µꜩ}$
• $\text{min(nꜩ/B)}=\text{250,000 nꜩ/B}\text{ (250 µꜩ/B)}$
• $\text{min(nꜩ/}\text{g}_u)=\text{100 nꜩ/}\text{g}_u$ [2]

In a Tezos operation, we can add additional information such as smart contracts deployment, smart contract call, etc. These have a storage cost which is represented in tez per byte. Since the Delphi update to the protocol [3] this minimal cost has been reduced from 1ꜩ to 0.25 ꜩ per kilobyte (250 µꜩ/B). The minimal price of creating a new account has thus been lowered from 0.257 tez to 0.06425 tez (the cost of creating an account is important to protect the system from spams and Sybil attacks [4]).

On the Tezos blockchain, gas refers to the cost necessary to perform a transaction on the network. Bakers set the price in gas based on supply and demand for computational power on the network (needed to process smart contract calls and other transactions).

Gas is used to determine the complexity of the transaction execution and also to avoid the risks of infinite loops. It is one of the main factors a baker considers before choosing transactions. Before including a transaction, the baker reviews the amount of gas required and its cost per unit. If this ratio is adequate, the baker selects the transaction.

Each transaction has a gas limit: 1,040,000 $\text{g}_u$. If the contract execution, or deployment, exceeds this limit, the contract is considered unusable. This limit is useful to guarantee that the bakers will be able to validate the block in a limited amount of time [5]. The gas limit may seem relatively low, but its value is a network's inclusion metric: any user should be able to run a node and bake a block within the allotted time. Even slow nodes can participate.

The Delphi update also increased the number of computations per unit of gas. The minimal amount of gas units to achieve operations has been reduced from 10,000 to 1,000. With this update, the execution cost of smart contracts decreased by approximately 75% [6]. This evolution allowed more complex smart contracts' executions and was a demonstration of Tezos's adaptability.

Note that a baker also takes into account the gas limit per block. Today, the limit is 2,600,000 $\text{g}_u$. So, of course, it limits the number of transactions to include in a block. However, for the storage cost, it isn't a fee that rewards the baker. Actually, this particular fee is "burned", meaning nobody receives it.

## Smart contract execution and optimization​

There are two limits to take into account when developing a smart contract. The gas limit is an important parameter for the usability of the smart contract. But there is also a second major limit: each serialized operation has a maximum size of 16,384 bytes. It is, therefore, impossible to upload a smart contract bigger than this limit (origination).

One must account for these two variables to optimize a contract:

1. The gas consumption
Many options are possible [7]. However, note that a large proportion of the gas is spent on the conversions from byte sequences to protocol-specific typed representations (and vice versa). These conversions can be:

• deserialization
• parsing of bytes
• checking the correctness of types
• conversion back to bytes

Follow this link for more details on the cost of gas.

2. The contract size
The formula below calculates an approximation of a contract's size:

• An assumed constant value per instruction: $\alpha$

• The number of instructions: $n_i$

• The sum of the sizes of all variable-size constants (strings, bytes) in the contract: $S$

Then the contract's size "$C_s$" is:

$C_s=\alpha\times n_i+S$

So, the size optimization comes down to decreasing the number of instructions and the variable-size constants. [7]

## Tezos reward​

To maintain the network, Tezos needs bakers. They stake their tokens and use their computing power to create blocks, manage transactions, vote, and secure the network. In exchange for these tasks, bakers are rewarded with a fee.
Since the Carthage update[8], the reward system has been updated to make the network more robust against non-cooperative baking strategies.

### Baking reward​

When a baker bakes a block, he receives a reward composed of all the transactions fees contained in the block in addition to a network reward computed by the following formula[9]:

$\bm{baking\ rewards=5 + e\times 0.002143}$

where e ∈[0; 2,333] = the number of extra attestations slots beyond the threshold of 4,667.

The baking rewards are 10 tez at most, for a fully attested block (not counting the transaction fees).

$\bm{attesting\ rewards=s \times 0.001428}$

where s = number of attestation’s slots.

A baker may have several attestation 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.

For more detail about the Tezos baking process, please refer to the "Baking" module.

### Inflation​

It's important to note that the Tez token is based on a model with inflation. By adding up the baking and attesting block rewards, each new block generates 20 new Tez (without taking into account the 1.25 Tez generated for liquidity baking). A new block is created roughly every 15 seconds. This represents 42 Million Tez per year ($\approx$ 80 ꜩ $\times$ 60 mins $\times$ 24 hours $\times$ 365 days). At the Tezos launch, the network was composed of 763 Million Tez. Therefore, during the first year, the inflation rate of the Tez token was approximately $\frac{42}{763}\approx5.5\%$. Today, in 2023, the inflation rate is around 4.5%.

## What have we learned so far?​

Thanks to this chapter, you should now have a better understanding of how Tezos economics work. This understanding can now help to build viable Tezos smart contracts.

This chapter is the last one of the Tezos Basics module. The next chapter is the examination.