Image for post
Image for post
Photo by Ricardo Braham on Unsplash

Here at Cryptium Labs, besides delegation services and protocol development, we are also developing a smart contract language called Juvix. A few talks I went to at Devcon 5 have me reflecting on some thoughts of smart language design. I’d like to tie them up with our Juvix work and share them in this post.

Smart contract developments are fundamentally different from other software developments. First, smart contracts often have very high stakes. Mis-specifications are thus extremely costly. Second, smart contracts are public and the incentives to hack them are high because of the monetary rewards. …


Image for post
Image for post

This is the fifth part of a tutorial series on writing smart contracts in Liquidity. I recommend going through the first, second, third, and fourth parts if you haven’t already.

In this tutorial, we’ll deploy and call the token contract we wrote in the last tutorial via the Tezos client command line interface. I strongly recommend thorough testings of this contract before launching it in the mainnet. Deploying the contract creates a fungible token system running on the Tezos ledger. To recap, the users of this contract include the owner of the token system, the users (account holders) of the tokens, and other contracts. In this tutorial we focus on the owner and the account holders. …


Image for post
Image for post

This is the fifth part of a tutorial series on writing smart contracts in Liquidity. I recommend going through the first, second, third, and fourth parts if you haven’t already.

In this tutorial, we’ll step up our game (yet again!) and write a token contract! Deploying the contract creates a fungible token system running on the Tezos ledger. One can transfer tokens between accounts in the token system and approve amounts to be transferred on your behalf. The token standard was inspired by this. A comparable (more detailed) Ethereum standard can be found here. In the next tutorial (part 5.2), …


Image for post
Image for post

This is the fourth part of a tutorial series on writing smart contracts in Liquidity. I recommend going through the first, second, and third parts if you haven’t already.

In the last tutorial, we wrote a contract that publishes authenticated data. The contract ensures that the published data is from the publisher and not anyone else. However, because the data is stored in the contract storage, it gets costly to publish large data. In this tutorial, we’ll write a different implementation of the same contract, altered such that large amounts of data can be published without high cost.

We make use of a hash function to hash the data to be published. A nice property of hash functions is that they can map data of arbitrary size to a fixed size. For large data, the contract can save costs by storing the hashed data instead of the plain data. The readable data can be stored somewhere else off the chain. To make sure the off-chain data is not compromised, the contract verifies the data for the audience. When the audience calls the contract, he/she provides the data he/she has as a parameter. The contract then hashes the data provided and checks it against the hashed data that is in the storage of the contract. …


Image for post
Image for post
Photo by Skitterphoto from Pexels

This is the third part of a tutorial series on writing smart contracts in Liquidity. I recommend going through the first and second parts if you haven’t already.

In this tutorial, we will write a contract that publishes authenticated data. Examples include price information of a cryptocurrency or protestor group announcements. The contract ensures that the published data is from the publisher and not anyone else. How does it do that? We’ll get to that in a bit! First, let me introduce the users of our contract. The users include a data publisher and an audience:

The data publisher:

  • deploys the contract to start sharing data. …

Image for post
Image for post
Photo by Weiwei Chen from Pexels

This is the second part of a tutorial series on writing smart contracts in Liquidity. See the first part here.

Last time we wrote the identity contract, and ran a simulation of it. This time, we’ll write a contract that sends one tez to another account. We’ll also deploy the contract to the testnet (Alphanet), and call it to see it in action!

The contract

The caller of this contract initiates a transfer from the contract’s account to the destination (receiver’s) address. The Liquidity code below is saved as send_one_tez.liq

type storage = unit 

let%entry main
(key : key_hash)
_storage =
let op = Account.transfer …

Image for post
Image for post
Photo by Darwis Alwan from Pexels

This is the first part of a tutorial series which provides a hands-on, step-by-step guide to writing smart contracts in Liquidity. In each part, we will write a Liquidity contract inspired by an example in the Michelson “A contract a day” series. Michelson has evolved since the Michelson series was written, so the contracts in that series may not necessarily run as written.

Liquidity is a high-level typed smart-contract language for Tezos that strictly complies with Michelson security restrictions. Anything that can be written in Michelson can be written in Liquidity. OCaml developers will find the syntax of Liquidity familiar, because it has OCaml-like syntax. …

About

Marty Stumpf

Blockchain protocol/smart contract engineer @CryptiumLabs. thealmarty.com, twitter: @MartyStumpf.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store