$2.86 -0.88%
XTZ · 48w

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