Posts

Together with Ziverge Inc., we’re more than happy to invite you to the first ZIO Hackathon 2020 after the official launch of the 1.0 version that took place on August 4, 2020. The whole ZIO community was waiting for this moment for almost three years, but here we are!

During the ZIO Hackathon 2020, you will be able to attend talks on ZIO projects straight from ZIO open source contributors, as well as get advice on all your ZIO challenges like bugs and new feature ideas.

About ZIO Hackathon 2020

Date: 20 – 21 November 2020
Location: Online – Zoom/Discord/Github

Schedule

  • Friday, November 20st: Introductory talk – 8 pm (GMT+1)
  • Saturday, November 21st: ZIO Hackathon – Start: 10 am (GMT+1)

Hands-on open-source coding, guided by expert mentors – is, of course, the main idea of the ZIO Hackathon 2020. However, attendees can join breakout sessions to learn about specific aspects of ZIO (ZIO core, fibers, STM, execution traces, fiber dumps, ZIO test, ZIO config, etc.), and team leaders will help different groups work on core issues in ZIO, the ZIO ecosystem, and other related libraries in the functional Scala ecosystem.

Additionally, Anyone who attends the ZIO Hackathon and merges a contribution to any official ZIO project during the event will get a free ZIO T-shirt (no shipping limitations) and a 10% discount to the Functional Scala 2020 Conference.

About ZIO

ZIO is a zero-dependency Scala library for asynchronous and concurrent programming. Powered by scalable, non-blocking fibers that never waste or leak resources, ZIO lets you build scalable, resilient, and reactive applications that meet the needs of your business.

After the big launch, it already has more than half a million downloads in a month. ZIO is used by firms like Netflix, DHL, Evolution Gaming, and many others.

The event was brought to you by Ziverge Inc. – the commercial developer of the ZIO library and us, Scalac. Scalac is a development, and consulting company, and contributor in multiple projects in the ZIO ecosystem. Find out more about Scalac.

Other ZIO events and resources by Scalac

Functional World Meetup

Exploring ZIO Prelude: The game-changer for type classes in Scala

Join us on Thursday, August 20 at 6.00 PM, GMT+2

About the talk

On this talk, we are going to explore how ZIO Prelude provides us an accessible and fun way of writing pure, generic, and composable code in Scala, without needing to appeal to the traditional Functor hierarchy.

More specifically, we’ll explore these uses cases:

  • Combining data structures
  • Traversing data structures
  • Validating data structures
  • And… working with the brand-new ZPure!

About Jorge Vasquez

Software developer focused on the backend. He had the chance to work with several technologies and programming languages across different industries, such as Telco, AdTech, and Online Education. 

He’s always looking to improve his skills, finding new and better ways to solve business problems. He loves functional programming, and he’s convinced it can help to make better software. Also, he’s excited about new libraries like ZIO that are making Scala FP more accessible to developers. 

Author of the “Mastering modularity in ZIO with Zlayer” ebook mentioned below.

Mastering Modularity in ZIO with Zlayer Ebook

Writing modular applications is without a doubt very important in software engineering.  It allows us to build software no matter the complexity involved. And composability has been one of the core principles of ZIO from the very beginning.

In this e-book you will learn:

  • What is the new module structure suggested by ZIO
  • How to reorganize the ZIO application around ZLayers
  • ZIO new data types: ZLayer and Has
  • ZLayer type aliases
  • How to create and combine ZLayers, with a horizontal and vertical composition
  • How to reorganize ZIO tests and mocks around ZLayers 

Read also

Cryptonomic NYC Hackathon part 2

The idea

It was the first time I’d ever taken part in a hackathon. I hadn’t been to any of these events before because I was very skeptical about them. I thought: how can we make anything useful in only two days? Well, it turns out that small, but handy tools can be created, even without sacrificing code quality. The key is to choose the right project; not too big or too complicated so you can complete it within a weekend. In our case, it was a Micheline Michelson translator that I’m going to tell you more about in this article.

The hackathon

Our hackathon took place on the first weekend of August (03-04.08). Cryptonomic is a startup which provides tools and smart contracts for decentralized and consortium applications. We had to use the Cryptonomic technology stack, tools such as ConceilJS (https://github.com/Cryptonomic/ConseilJS) during the hackathon. We decided to create a Google-like translator between Michelson and Micheline; two formats of source files used in Tezos software development. 

What are Tezos and Michelson?

According to the Tezos website:

“Tezos is a new decentralized blockchain that governs itself by establishing a true digital commonwealth.”

“Tezos addresses key barriers facing blockchain adoption to date: smart contract safety, long-term upgradability, and open participation”

Michelson is a domain-specific language that we use to write smart contracts on the Tezos blockchain. Unlike Solidity or Viper which must be compiled to EVM (Ethereum Virtual Machine) byte code to be executed on EVM, Michelson code itself gets to run in the Tezos VM.

Micheline vs. Michelson

First of all, Michelson is the specification and Micheline is the concrete language syntax of Michelson encoded in JSON. Before deployment to Tezos VM, Michelson is transformed into Micheline. 

For example, here is the same program in Michelson and Micheline representation:

Micheline

parameter int;
storage int;
code {CAR;                      # Get the parameter
      PUSH int 1;               # We're adding 1, so we need to put 1 on the stack
      ADD;                      # Add the two numbers
      NIL operation;            # We put an empty list of operations on the stack
      PAIR}

Michelson

[
    {
      "prim": "parameter",
      "args": [
        {
          "prim": "int"
        }
      ]
    },
    {
      "prim": "storage",
      "args": [
        {
          "prim": "int"
        }
      ]
    },
    {
      "prim": "code",
      "args": [
        [
          {
            "prim": "CAR"
          },
          {
            "prim": "PUSH",
            "args": [
              {
                "prim": "int"
              },
              {
                "int": "1"
              }
            ]
          },
          {
            "prim": "ADD"
          },
          {
            "prim": "NIL",
            "args": [
              {
                "prim": "operation"
              }
            ]
          },
          {
            "prim": "PAIR"
          }
        ]
      ]
    }
]

As you can see, there is a clear correspondence between Michelson and Micheline representation. Despite this, many people still find it challenging to understand the difference between Michelson and Micheline. That’s why our team decided to create this translator. Above all, we hope it is going to help other developers to learn smart contracts development in Tezos.

The Technology stack

To create our Micheline Michelson translator, we agreed to use Scala and Akka http for the backend side. At the frontend side, we used React, Redux, and Typescript.

The Coding

A conversion between the two formats is already a part of Cryptonomic tools. So, we needed to extract it from the base source code. After that, we decided to create a separate module for conversion which, we could then import into other projects, so as not to duplicate code.

A Micheline to Michelson translation has already been implemented in Scala using Circe, so it was quite easy to integrate it into our Scala-based project. However, the Michelson to Micheline conversion code is JavaScript. We tried to come up with our own Scala parser for Michelson. Unfortunately, it was too time-consuming, and we finally decided to use a parser from ConceilJS. We also chose Node.js for running the JavaScript code.

Michelin Michelson Translator

The Solution

In short, our solution consists of one frontend and two backend modules. 

Frontend module:

https://github.com/ScalaConsultants/Tezos-Micheline-Michelson-Translator-Frontend

Translation module:

https://github.com/ScalaConsultants/Tezos-FullStack-Console-Translation-Module

Console backend:

https://github.com/ScalaConsultants/Tezos-FullStack-Console

(There’s more detailed information about the modules in the Readme files, so there’s no point in duplicating the text)

Also, our team selected Heroku as the deployment platform.

Final application

You can try out our solution here: https://smart-contracts-micheline-michelson-translator-for-tezos.scalac.io/

On the left side, you paste the Micheline code and click translate to see the result. That simple!

The experience

In conclusion, it turns out that over only two days, it’s possible to create a small yet beneficial application. It was also an excellent opportunity to learn about some Tezos development tools. 

The Micheline Michelson translator was one of two projects that by Scalac. Check out the Frontend data visualization app that the other team made.