Tezos
$1.01 0.11%
XTZ · 12w

How to write a Tezos protocol

A Tezos node is parameterized by a software component called an economic protocol (or protocol for short). Different protocol implementations can be used to implement different types of blockchains.

This is the first post of a tutorial series on how to implement such a protocol. We will see how to write, compile, register, activate and use an extremely simple protocol. By doing so, we will also start to explore the interface between the protocol and the node (more specifically the shell component of the node). In later blog posts, we will gradually work our way up to a more realistic protocol.

In what follows, we suppose you have cloned the Tezos repository and we specifically look at revision 2d903a01 on the master branch. You should be already familiar with running a node in sandbox mode. All paths are relative to the root of this repository. All Bash commands are to be executed in sandbox mode.

Protocol Registration

A node can contain several economics protocols (they are said to be registered), but only one is activated at any given time.

We can query a node to know the registered protocols. Protocols are identified by a b58check hash. On the master branch, hashes are arbitrary values and do not depend on the actual code, but on production branches, they are hashes of the source code of the protocol.

$ tezos-admin-client list protocols ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im

The node in this example contains three protocols. They were statically linked (embedded) to the node at compile time. genesis is the protocol activated at start-up. alpha is the main Tezos protocol. demo_noops is a simple protocol without operations (hence the name no-ops) that we will use as our main example in this article.

Protocols can also be registered dynamically at run-time via an RPC (a.k.a. protocol injection). As an e...

Continue on blog.nomadic-labs.com
Recent news
XTZ +0.11% · forum.tezosagora.org · 11h

Crosspost from Agora

Hello, with the recent unveiling of Halo, ZEC’s zk-SNARKs have some nice improvements, namely no more need for trusted setup. I think this is huge, and I hope whatever protocol upgrade introduces zk-S...
XTZ +0.11% · medium.com · 16h

Testing Michelson contracts with PyTezos

In our previous post, we slightly touched on how to conduct integration tests for Michelson contracts. It’s time to dive deeper and try some more advanced features offered by PyTezos. We believe…
XTZ +0.11% · medium.com · 21h

tezblock Weekly Update #8 - AirGap

Over the last two weeks we’ve released the tezblock MVP and open sourced the code with a MIT license. If you’re interested what happened last week in more detail take a look at the tezblock GitHub…