Skip to main content

Economics and rewards

In this chapter, we will dig deeper into the fees of the Tezos network and the baking and endorsing 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 or an endorser.

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: minF\text{min}_{F}
  • Size of the operation (in bytes "B\text{B}"): s\text{s}
    (The size "s\text{s}" is the number of bytes in the complete serialized operation).
  • Gas used for the operation (in gas unit "gu\text{g}_u"): g\text{g}
  • Minimal nano-tez per byte: min(nꜩ/B)\text{min(nꜩ/B)}
  • Minimal nano-tez per gas unit: min(nꜩ/gu)\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:

FeesminF+min(nꜩ/B)×s+min(nꜩ/gu)×g\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:

  • minF=100 µꜩ\text{min}_{F}=\text{100 µꜩ}
  • min(nꜩ/B)=250,000 nꜩ/B (250 µꜩ/B)\text{min(nꜩ/B)}=\text{250,000 nꜩ/B}\text{ (250 µꜩ/B)}
  • min(nꜩ/gu)=100 nꜩ/gu\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 Delphi transaction has a gas limit: 1,040,000 gu\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 computation 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. In Delphi, the limit is 10,400,000 gu\text{g}_u (10 times the gas limit per operation). 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:

    • reading
    • 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: nin_i

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

      Then the contract's size "CsC_s" is:

      Cs=α×ni+SC_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 and endorsers. 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]:

With:

  • "nen_e": the number of endorsements the block receives
    32 endorsements are required to validate a block.

  • "BreBr_e": the baking reward per endorsement

  • "BrbBr_b": the network baking reward per block

Then:

Brb=ne×Bre\bm{Br_b=n_e\times Br_e}

For a high-priority baking:

Bre=1.2500 ꜩ\bm{Br_e}=\text{1.2500 ꜩ}

For a low-priority baking:

Bre=0.1875 ꜩ\bm{Br_e}=\text{0.1875 ꜩ}

This Carthage update allows focusing the baker's efforts on the priority blocks.

If we apply the block reward formula on a priority block, we get 40ꜩ:

Brb=32×1.2500=40\bm{Br_b}=32\times 1.2500=\bm{40}

Endorser reward#

Selected endorsers are also rewarded. One block needs 32 endorsers slots, while one endorser can have more than one. The total reward for an endorser "ErEr" is then easy to calculate.

For:

  • "ErEr": the endorser's total reward
  • "nsn_s": the endorser's number of slots
  • "ErbEr_b": the endorsement reward per block

We have:

Er=ns×Erb\bm{Er=n_s\times Er_b}

For a high-priority block:

Erb=1.250000 ꜩ\bm{Er_b}=\text{1.250000 ꜩ}

For a low-priority block:

Erb=0.833333 ꜩ\bm{Er_b}=\text{0.833333 ꜩ}

The total available reward for endorsing a high-priority block is fixed to the same amount as the baking of that block: 40ꜩ.
That value is distributed among all the endorsers, proportionally to their slots.
The operation is the same for a low-priority 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 endorsing block rewards, each new high-priority block generates 80 new Tez. A new block is created roughly every minute. 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 the inflation rate of the Tez token is approximatively 5.5%:

42,000,000763,000,000=427635.5%\frac{42,000,000}{763,000,000}=\frac{42}{763}\approx5.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.

References#

[1]https://tezos.gitlab.io/protocols/003_PsddFKi3.html#baker

[2]https://forum.tezosagora.org/t/psa-do-not-quote-gas-cost-in-tez/1618

[3]https://blog.nomadic-labs.com/delphi-changelog.html#lowered-storage-costs

[4]https://en.wikipedia.org/wiki/Sybil_attack

[5]https://blog.nomadic-labs.com/smarter-contracts-thanks-to-delphi-part-12.html

[6]https://tezos.foundation/delphi-upgrade/

[7]https://medium.com/tqtezos/how-to-minimize-transaction-costs-of-tezos-smart-contracts-9962347faf64

[8]https://blog.nomadic-labs.com/a-new-reward-formula-for-carthage.html

[9]https://tezos.gitlab.io/007/proof_of_stake.html#rewards

Last updated on by Aymeric BETHENCOURT