Digging into Tezos with ConseilPy

DYOR series by Baking Bad

Baking Bad
Coinmonks
Published in
3 min readJul 11, 2019

--

ConseilPy is a Python library providing Sqlalchemy-like query syntax for Conseil blockchain indexer. You can start using ConseilPy right now: the package can be installed via PyPi, documentation, and examples are available on Github. We want to thank Tezos Foundation for supporting us and Cryptonomic team for their cooperation and quick responses.

We are big fans of Jupyter notebook, and we also like when things are working out of the box. ConseilPy lets you start playing with Tezos alphanet in a few clicks, and in this article, we will take several interesting usage examples.

Delegates registrations and roll price

There is not much useful information that can be extracted from the alphanet, but we start from the assumption that before bakers do something in the Mainnet they pre-try to do it in the alphanet.

Let’s check if there is a connection between the price of one roll and the number of registered delegates. In order to register as a baker, one has to make a delegation operation to himself. It’s not possible to compare fields in Conseil right now, but we can filter operations by source (note that this won’t work after Emmy update).

Applying some pandas magic:

And finally, we get the chart. One can note the growth of interest after the moments of strong price drops. Also, it was a great time to open a bakery at the end of June :)

Smart contract insights

Let’s see what we can find out about smart contracts. It should be noted that some of the developers prefer to debug smart contracts on the local node because it’s much more convenient. Therefore, our results will not be quite correct. But it’s ok for demo purpose.

Hello from developers

It’s always nice to come across some joke left by the programmer in the code. We’ve already mentioned ASCII-art sample found accidentally but what can we extract using ConseilPy? Luckily, we can utilize a full-text search on storages, scripts, and parameters. For instance, we can look for URLs and emails:

Or run into a man crying for help:

I’m afraid he never got help

Analyzing scripts you can find a lot of interesting things too, for example, we were looking for internal originations and delegations to debug better-call.dev. Conseil does not support internal operations at the moment, so we used the following query:

Source languages

Using a fairly simple heuristics, in some cases, we can determine which high-level language was used to write the contract. For example, Liquidity compiler can be detected if field or variable annotations of special kind occur, or SmartPy can be recognized by the error message template.

Let’s see how the number of deployed contracts written in Liquidity and other languages was changing. Start with non-liquidity originations:Hello from developers

You can notice that we are grouping originations by script, this is a simple approach for removing codebase duplicates. A better approach would be to use a fuzzy comparison, but a simple one would do for our research.

Moments of fast growth are most likely related to the deployment of several modifications of one contract (debugging). Generally, the result is expectedly biased, but some conclusions can be drawn.

Summary

With ConseilPy you can start exploring Tezos with a minimum effort. SQLAlchemy-like syntax and inline metadata docstrings allow writing queries very fast. Next time we will show how to use ConseilPy and PyTezos together to make even cooler things.

Follow us on Twitter and Github to stay updated.
Cheers!

Originally published at https://baking-bad.org on July 11, 2019, where you can find full version of the article.

Get Best Software Deals Directly In Your Inbox

--

--

Baking Bad
Coinmonks

Baking-bad.org, Audit & Rating of Tezos bakers. Active Tezos tools contributor. Author of better-call.dev, Pytezos, Netezos, TzKT.io, atomex.me