May 18, 2021

Algorand Introduces New Approach to Smart Contract Development

By: Paul Riegle

An update on accessible languages and the Algorand Virtual Machine (AVM) to empower developers and applications for the future of finance

The Algorand blockchain is known for being fast (over 1000TPS with sub 4.5 second blocks), inexpensive (.001 Algos per transaction), immediately final (no forking, 1 confirmation) and green (carbon negative).  These characteristics, combined with Layer-1 primitives like Algorand Standard Assets (ASAs), have made Algorand the blockchain of choice for many asset issuers, and asset management platforms.

Our smart contracts have stayed true to these first principles, including being the first carbon negative smart contract system. Unlike smart contracts on other platforms, we ensured our smart contracts would be fast (the same speed as any other transaction), inexpensive (the same cost as any other transaction - .001 Algos) and at Layer 1 and thus enjoy the same security and finality properties as Algorand's consensus protocol.

The Algorand Smart Contract Model

Our model is simple and powerful. Smart contracts are written in a higher level language and compiled to bytecode for execution by the Layer-1 Algorand Virtual Machine (AVM). An easy frame of reference is Ethereum, where smart contracts are written in Solidity and compiled to bytecode for execution by the EVM.

If you’ve written smart contracts on Algorand, you have already interacted directly with early versions of the AVM while using an assembly-like language called Teal. Through this early use of the AVM, Teal developers have given us feedback and allowed us to rapidly iterate and improve the AVM.  As we approach the AVM v1.0 release, the AVM will enable smart contracts to be written in Turing-complete languages and to send transactions, and will be capable of executing complex smart contracts that can power the most popular DeFi, NFT, and web3 dApps available in blockchain today. 

Critically, this smart contract power does not sacrifice speed or cost. Compute and storage budgets, while generous, are calculated and enforced during runtime. This means that smart contracts will continue to have safety guardrails by design and that potential infinite loops will be terminated before having any impact on the overall system.  

Smart Contract Languages on Algorand

We believe that it is critical to be able to write smart contracts in accessible languages.  We also believe that it is critical to have safety and correctness guarantees when writing smart contract based infrastructure that interacts with billions of dollars of value.  As such, together with our community and ecosystem, we are focused on providing languages that strike the right balance.

  • Reach - Reach provides the ease of use, accessibility, and safety guarantees required for smart contracts to go mainstream in a way that no other language has been able to provide.  Reach uses a subset of JavaScript to specify entire dApps: the smart contract, the clients running on the front-end, the servers running on the back-end, and the communication between all the pieces. The entire specification is in a single language, which enables developers to create, reason about, and deploy dApps quickly.  In addition, the compiler itself uses type-checking, information-flow security, and end-point projection to derive each component correctly from a single specification. The compiler is integrated with a satisfiability-modulo-theories (SMT) theorem prover to automatically check the correctness of the application via developer-specific predicates, as well as automatically generated properties appropriate for all dApps.  
  • Python - Algorand provides language bindings for Python to the AVM.  Developers write their code in Python and access AVM opcodes via a supplied library without having to write directly in Teal.  While Teal will still be available for those that prefer direct interaction with a stack-machine language, we will recommend moving to a higher-level language to write more intuitive smart contracts.
  • Clarity We are also actively working on a compiler to bring the Clarity language to our layer-1 smart contracts.  Clarity is a decidable language, meaning you can know, with certainty, from the code itself what the program will do.  Clarity is designed to optimize for predictability and security. It takes the "what you see is what you get" approach, making it easier to reason about smart contract behavior, cost, and performance. It allows for static analysis of the entire call graph of a given smart contract. Its support for types and type checker can eliminate whole classes of bugs like unintended casts, reentrancy bugs, and reads of uninitialized values.  The Clarity open-source project is supported by Algorand, the Stacks ecosystem, and Hiro PBC. With Clarity, developers can create and call contracts seamlessly using a widely adopted, decidable, secure, highly analyzable and open-source language.

Additional strategies, such as integrating with the LLVM stack are now clearly available to the project and our community, opening up writing smart contracts to a wide variety of popular languages such as Rust, C, C++, Go, Haskell, Python, JavaScript, and more.

An Enduring Smart Contract Platform

Our smart contracts, in their current form, can support the needs of all the major and popular dApps.  In addition, we are actively preparing for a future where smart contract transactions are ubiquitous and numerous enough to cause congestion even on the highest throughput blockchains like Algorand.  We are also preparing for the natural evolution of resource usage in programs, when new and more complicated protocols and cryptographic primitives evolve to require resource usage that would need to be constrained within the current framework.  We are hard at work designing and iterating a layer-2 smart contract system to address these future needs that will be powerful, flexible, and fully composable with our growing layer-1 smart contract dApp ecosystem.

Join our Ecosystem of Builders

Developers on Algorand can expect to build superior DeFi, NFT-related, and web3 dApps with a combination of:

  • Accessible and safe higher level languages (e.g., Reach, Python, Clarity)
  • A powerful execution environment (with AVM 1.0)
  • High-throughput and low-cost smart contract transactions (1000TPS+ and .001 Algos)

Algorand is based on smart and thorough research, careful planning, and excellent implementation and our smart contracts are no different.  They are powerful, fast, inexpensive, and easy to get started in. 

Come Innovate & Build on Algorand!

Interested in Algorand? Let us know how we can help!