Preparing for the Tezos hackathon with Baking Bad

Putting Granary, LIGO, PyTezos, and Better Call Dev together

Last weekend we participated in the First Eastern European Tezos Hackathon as mentors, and now we want to tell you how we prepared for it, what happened and what conclusions we drew.

You are in safe hands now

We decided to go through all the steps from setting up the environment to calling the smart contract and record everything. We used four tools for local development and debugging of smart contracts in Tezos:

Granary — All-in-one toolkit for smart contract development;

LIGO — High-level smart-contract language that compiles down to Michelson;

PyTezos — Python SDK for Tezos;

Better Call Dev — Michelson contract explorer.

All sources are available in our repository https://github.com/baking-bad/tezos-nft-sample.

Setting up sandbox

Before we go we need to ensure all necessary system libraries are installed and also proper versions of node.js, python, and docker.

Sudoless docker

A typical issue, when you cannot run any docker command without sudo . Explained in the official docs: https://docs.docker.com/install/linux/linux-postinstall/

Python environment

Common problems with python: multiple versions on the same machine, missing ssl or zlib modules. The best workaround is using pyenv , start from this page: https://github.com/pyenv/pyenv/wiki/Common-build-problems

PyTezos dependencies

In order to work with elliptic curve cryptography (ed25519, secp256k1, NIST256) you need to install system libraries first, follow the instructions: https://baking-bad.github.io/pytezos/#requirements

We are good to go now, let’s start from cloning our starter kit and installing dependencies.

$ git clone https://github.com/baking-bad/tezos-nft-sample

$ cd tezos-nft-sample

$ npm i

$ pip install -r requirements.txt

After that, we can run the local Tezos node (a single node blockchain) and activate a protocol (in our case it’s Athens).

$ npm run init

$ npm run start

$ npm run activate-alpha

This is what Granary basically provides, a sandboxed Tezos chain of a single node, and a set of useful scripts to interact with it. We can then shut down the node with npm run stop or reset to the initial state with sudo npm run clean

Compiling sources and testing

We have a sample contract written in LIGO in the src/nft.ligo file (this is a demo source, pls do not use it for any other purpose). Next thing we want to do is compile it down to Michelson. Luckily Granary is shipped with a dockerized LIGO compiler and a convenient alias.

$ npm run compile

If everything goes well we will get a result in a .tz file, otherwise, there will be an error message (atm stdout and stderr are not separated, but this to be fixed soon).