What are Smart Contracts and how you can build them on Stellar?

A very relevant concept in the blockchain space, is the concept of Smart Contracts (SC). In the following blog post, we will talk about them, its early days, and how you can get started building SCs on the Stellar Network.


What is a Smart Contract?

An SC is a computer program that contains certain types of rules, actions, and events that are intended to be automatically executed according to the terms agreed in that particular contract. An SC is like a regular contract (usually written on paper), with the difference that the contracts are stored on a digital ledger, which allows an easy audit of the transactions.


Smart Contract Platform

The term was first used in 1997 by computer scientist, lawyer, and cryptographer Nick Szabo (before the creation of Bitcoin). The term found mainstream recognition with the launch of Ethereum (2015), a decentralized, open-source blockchain with smart contract functionality which uses a virtual machine to guarantee Turing Complete contract execution. This gave a lot of flexibility to developers building on top of the Network. However, the high use of the Ethereum virtual machine, created scalability issues which are currently being translated into high transactions fees.


Does Stellar support Smart Contracts?

The short answer for that is not yet. However, Stellar offers several mechanisms which allow you to create "smart contract-like" functionalities. For more information about smart contracts on Stellar, check out the following blog post titled "Understanding Stellar Smart Contracts". Projects like Rabet and Pendulum are working to bridge the gap between Stellar and DeFi.


Project Jump Cannon

A very interesting project bringing Smart Contracts to the Stellar Network is called Project Jump Cannon. Project Jump Cannon is being built on a WebAssembly (WASM) runtime and aims to build native on-chain smart contracts for Stellar. The project was named after Annie Jump Cannon, an astronomer whose cataloging work was instrumental in the development of contemporary stellar classification still used to this day. If you would like to learn more about the project, feel free to join the Stellar Developers Discord server where you will find their dedicated channel.


Turrets

Another interesting project trying to bring Smart Contracts on the Stellar Network is called Turrets (Prev. TSS). Turrets aims to build a decentralized, Turing Complete network for the secure, cost-effective, creation and signing of Stellar transactions. Projects experimenting and researching Turrets include MozartPay, Litemint, Script3, and AnSwap.


Technologies for building decentralized applications

If you are looking into building a decentralized application that is compatible with DeFi blockchains, it is key to take into consideration technologies (particulary programming languages) that have proven to be high performer, safe and efficient when it comes down to handling complex systems. This is important in order to facilitate interoperability and compatibility with popular DeFi products like NFTs, AMMs, and Liquidity Pools, which are currently being offered by smart contract providers (like Ethereum, Polkadot, Solana, etc). In general, you can build SCs with basically any programming language, popular programming languages for building decentralized applications are C++, Solidy, Rust, Typescript, GO, Java, and others.

I personally like Rust, which was developed by Graydon Hoare while at Mozilla, and is currently being used in many blockchain protocols for the logic of their core functionality. Besides its robustness as a programming language, it is compatible with WebAssembly (an open standard that defines a portable binary-code format for executable programs), enabling high-performance applications on web pages and opening a new world of possibilities for building decentralized applications. This is a very fascinating topic, which we will discuss in more detail in future blog posts.

I hope that you enjoyed this blog post, if you liked it, please share it with your friends, and feel free to join us on Discord .

Resources

[1] Stellar Turrets: Smart contract protocol for Stellar https://tss.stellar.org/

[2] Project Jump Cannon: Choosing WASM https://stellar.org/blog/project-jump-cannon-choosing-wasm?locale=en

[3] Understanding Stellar Smart Contracts https://medium.com/stellar-community/understanding-stellar-smart-contracts-23ebe1568b6

[4] The Idea of Smart Contracts by Nick Szabo https://nakamotoinstitute.org/the-idea-of-smart-contracts/

[5] Distributed Trustless Workers with Stellar https://medium.com/lumenauts/distributed-trustless-workers-with-stellar-e197fd1b77f6