The Tezos Experience for Developers
A look at smart contract and dApp development on Tezos.
Since its inception, Tezos has positioned itself as a developer-friendly blockchain platform. What does “developer-friendly” mean in the context of blockchain, though? In addition to providing developers with various avenues to receive funding, Tezos is also equipped with multi-language support for both smart contract development and blockchain interaction via SDKs (software development kits).
Smart Contracts on Tezos
Tezos smart contracts can be written in a variety of languages. Today, Michelson, LIGO, and SmartPy are three of the most popular. Let’s discuss why it’s important to support different programming languages for smart contract development.
First of all, Tezos smart contracts always compile down to Michelson no matter what source language you write them in. In other words, if you write a smart contract in LIGO or SmartPy, the compiler will “convert” your code into valid Michelson before deployment to the network.
So now you may be wondering why everyone doesn’t just write smart contracts in Michelson. What’s the point of writing Python code via SmartPy if it’s going to be compiled to Michelson?
The answer lies in language-accessibility and developer preference.
High Level Language vs. Low Level Language
Before we get into the pros and cons of Michelson, it’s important to understand the differences between high level programming languages and low level languages. High level languages are typically much more accessible to developers because they’re designed for human readability and collaboration. Compared to low level languages, high level languages have more abstraction — the process of hiding or “assuming” parts of a system with the goal of making the system more accessible and easier to understand.
Abstracting and implementing low-level concepts into a high level language allows developers to work faster, and opens up a project or ecosystem to a wider developer base due to the reduced level of onboarding complexity. In the context of Tezos, a Python developer, of which there are over 8.2 million in the world, can use SmartPy to write a Tezos smart contract.
This may sound simple and obvious on paper, but a lot of blockchain platforms don’t support multiple languages for smart contract development.
As ecosystem builders, we can’t assume that a majority of developers are going to learn a new language just to build on Tezos. What we can assume is that most people will always take the route of least friction. Thus, we should embrace this reality and create language-based abstractions like SmartPy and LIGO to cater to more developers.
Tezos Smart Contract Languages
The Tezos ecosystem has a variety of smart contract languages for different kinds of developers. In this section, we’ll go over LIGO, SmartPY, and Michelson.
LIGO is a high-level statically-typed smart contract language “designed for developing longer contracts than one would naturally write in Michelson”. With LIGO, you can write smart contracts in a few different syntaxes.
At this time, smart contracts can be written in PascaLIGO, CameLIGO, and ReasonLIGO. As you may have guessed, PascaLIGO lets you write in a Pascal-like syntax, while CameLIGO and ReasonLIGO resemble OCaml and OCaml’s Reason syntax, respectively.
LIGO’s statically-typed design means that type-checking will be done during compile time. Type-checking is the process of ensuring that variables respect their respective constraints. For example, a string like “Tezos is cool” cannot be assigned to an
int variable, which is designed to hold numbers.
The statically-typed design aids in the overall safety and quality of Tezos smart contracts because it ensures the correct usage of variable types.
SmartPy is a high-level smart contract language that lets Python developers get in on the Tezos action. Over the past few years, the Python language has experienced an explosive level of growth. In fact, many rank Python as the fastest growing language in the world, and it’s used in a variety of use cases from powering Instagram’s backend to AI and deep learning. Considering Python’s popularity, the existence of SmartPy makes complete sense.
Similar to LIGO, SmartPy also compiles code down to native Michelson for smart contract deployment to the Tezos network. If you’re a Python developer who’s interested in learning about smart contracts, I recommend checking out SmartPy’s fully-featured online editor.
Michelson is Tezos’ “base language” when it comes to smart contracts. Whether you’re using LIGO, SmartPy, or another smart contract language, they all eventually compile to Michelson. Unlike the aforementioned high-level languages, Michelson is a lower-level language.
At its core, Michelson is a domain-specific stack-based language. The term “domain-specific” simply means it’s been designed for a single purpose — in this case, to act as a smart contract language for Tezos. In a stack-based design, there are two main constraints — you can only retrieve an item that is on top of the stack, and you can only add items to the top of the stack.
To interact with the stack, there are two main operations —
pop operations allows you to remove the top item of the stack, and the
push the top operation lets you add a new item to the top of the stack. As an example, if you wanted to write a smart contract to get the third letter of “Tezos”, you would have to
push T, E, and Z on the stack.
Another important aspect of Michelson smart contracts is formal verification. Simply put, format verification allows for “provability” of a smart contract’s output. In typical development, “unit tests” are used to check for expected output for a given input. The issue with unit testing is it requires you specify different inputs to test.
Theoretically speaking, this means unit testing only provides an estimated level of safety because it cannot account for all possible edge cases. As you can imagine, “estimation” doesn’t bode well for smart contracts tasked with managing and transferring large amounts of value. Instead of normal unit testing, Michelson smart contracts use “formal verification” for input/output provability. With verification frameworks like Mi-Cho-Coq, developers can mathematically prove the correctness of smart contracts.
In the context of finance-related smart contract design, Michelson’s constraints are very appealing because it ensures you can’t randomly add and remove stuff in the middle of the stack. In other words, since all Tezos smart contracts are written in or compile to a stack-based language like Michelson, the security and reliability implications of Michelson’s constraints make Tezos a very attractive option for high-value and high-safety use cases.
SDKs for Interacting with Tezos
In addition to Tezos’ wide array of smart contract development languages, Tezos also has a variety of SDKs, or software development kits. If you’re not sure what the differences between smart contract development languages and SDKs are, here’s a quick walkthrough.
Smart contracts written in Michelson, LIGO, and SmartPy execute directly in a decentralized fashion on Tezos nodes. In comparison, SDKs are typically language-specific development tools that allow developers to build apps that interact with the Tezos blockchain and Tezos smart contracts.
Simply put, smart contracts are internal to Tezos, and apps built with SDKs are external to Tezos. The Tezos ecosystem has a large number of SDKs for a wide array of developers. In this section, we’ll go over ConseilJS, TezosKit, and TezosJ.
TezosKit is a Swift SDK for building apps for Apple products — this includes iPhone, iPad, Apple Watch, Apple TV, and Mac. TezosKit allows developers to write iOS, iPadOS, and macOS-native code to interact with the Tezos blockchain. Having access to a Swift SDK opens up the Tezos ecosystem to billions of Apple devices around the world.
TezosJ is a Java SDK for building decentralized applications on Tezos. Java is a very popular programming language, especially for enterprise applications. In addition to Kotlin, Java can also be used for development of Android apps. With the TezosJ SDK, developers can build both web apps and Android apps that utilize the Tezos blockchain.
When it comes to developer experience, Tezos is one of the leading blockchain platforms for developing decentralized applications for high-value and high-security use cases. With its stack-based Michelson smart contract language, formal verification process for reliably proving smart contract functionality, and wide array of development SDKs, Tezos has positioned itself as an extremely developer-friendly blockchain platform.
If you are a developer or an aspiring developer and want to build on Tezos, check out the dedicated development portal: https://developers.tezos.com
Also, feel free to ask questions to a great developor community at the Tezos Stack Exchange site: https://tezos.stackexchange.com