Announcing Liquidity version 1.0

Liquidity version 1.0

We are pleased to announce the release of the first major version of the Liquidity smart-contract language and associated tools.

Some of the highlights of this version are detailed below.

Multiple Entry Points

In the previous versions of Liquidity, smart contracts were limited to a single entry point (named main). But traditionally smart contracts executions path depend strongly on the parameter and in most cases they are completely distinct.

Having different entry points allows to separate code that do not overlap and which usually accomplish vastly different tasks. Encoding entry points with complex pattern matching constructs before was tedious and made the code not extremely readable. This new feature gives you readability and allows to call contracts in a natural way.

Internally, entry points are encoded with sum types and pattern matching so that you keep the strong typing guarantees that come over from Michelson. This means that you cannot call a typed smart contract with the wrong entry point or the wrong parameter (this is enforced statically by both the Liquidity typechecker and the Michelson typechecker).

Modules and Contract System

Organizing, encapsulating and sharing code is not always easy when you need to write thousand lines files. Liquidity now allows to write modules (which contain types and values/functions) and contracts (which define entry points in addition). Types and non-private values of contracts and modules in scope can be accessed by other modules and contracts.

You can even compile several files at once with the command line compiler, so that you may organize your multiple smart contract projects in libraries and files.

Polymorphism and Type Inference

Thanks to a new and powerful type inference algorithm, you can now get rid of almost all type annotations in the smart contracts.

Instead of writing something like

<span class="kw">let</span>%entry main (parameter : <span class="dt">bool</span>) (storage : <span class="dt">int</span>) =
  <span class="kw">let</span> ops = ([] : operation <span class="dt">list</span>) <span class="kw">in</span>
  <span class="kw">let</span> f (c : <span class="dt">bool</span>) = <span class="kw">if</span> <span class="dt">not</span> c <span class="kw">then</span> <span class="dv">1</span> <span class="kw">else</span> <span class="dv">2</span> <span class="kw">in</span>
  ops, f parameter

you can now write

<span class="kw">let</span>%entry main parameter _ =
  <span class="kw">let</span> ops = [] <span class="kw">in</span>
  <span class="kw">let</span> f c = <span class="kw">if</span> <span class="dt">not</span> c <span class="kw">then</span> <span class="dv">1</span> <span class="kw">else</span> <span class="dv">2</span> <span class="kw">in</span>
  ops, f parameter

And type inference works with polymorhpism (also a new feature of this release) so you can now write generic and reusable functions:

<span class="kw">type</span> 'a t = { x : 'a set; y : 'a }

<span class="kw">let</span> mem_t v = <span class="dt">Set</span>.mem v.y v.x

Inference also works with contract types and entry points.

ReasonML Syntax

We originally used a modified version of the OCaml syntax for the Liquidity language. This made the language accessible, almost for free, to all OCaml and functional language developers. The typing discipline one needs is quite similar to other strongly typed functional languages so this was a natural fit.

However this is not the best fit for everyone. We want to bring the power of Liquidity and Tezos to the masses so adopting a seemingly familiar syntax for most people can help a lot. With this new version of Liquidity, you can now write your smart contracts in both an OCaml-like syntax or a ReasonML-like one. The latter being a lot closer to Javascript on the surface, making it accessible to people that already know the language or people that write smart contracts for other platforms like Solidity/Ethereum.

You can see the full changelog as well as download the latest release and binaries at this address.

Don’t forget that you can also try all these new cool features and more directly in your browser with our online editor.

1 Trackback or Pingback

Leave a Reply

Your email address will not be published. Required fields are marked *