Solana Smart Contracts Overview

Jul 24, 2020 5 min read
Solana Smart Contracts Overview

Everything You Want To Know About Smart Contracts For Solana

Hey Readers👩‍💻,

In our previous article about the Solana Network, we discussed the basics of what makes it such a unique project. In this article, we’re taking a look at Smart Contracts and how they work on Solana.

Solana’s mission is to support all high-growth and high-frequency blockchain applications and to democratize the world’s financial systems. So, let’s start from the beginning; what are smart contracts?

The overall term to describe smart contracts is a self-enforcing software piece managed by a peer-to-peer network of devices. Smart contracts provide a coordination and enforcement framework for agreements between network stakeholders without the need for third parties or traditional legal contracts. They are often implemented to formalize simple agreements between parties, create digital assets, or support organizational processes.

Smart contracts, from a user’s point-of-view, work a lot like a vending machine. You select the product you’d like to have, such as a contract, ownership form, or anything else. Once you’ve entered the right amount of digital currency, you’ll get the product delivered right to your lap. Within the contract itself, enforcement rules and specifications are registered, and they will also automatically be enforced.

Smart contracts give autonomy because they eradicate the need for a third-party intermediary. They also give trust, as no one can steal or lose documents since they are encrypted and stored on a shared ledger. Furthermore, you don’t need to trust the second party you’re dealing with or require them to trust you. Thirdly, you can save money on real estate agents, advisors, assistance, etc. It is also safer and more efficient, smart contracts save you a lot of time because you’re no longer stuck on complicated processes.

For a further explanation about smart contracts and why they are a vital part of the blockchain world, check the video below.

🏎 How Smart Contracts Work On Solana

As some of you might be aware, the Solana Network works on a Proof-of-History consensus. Solana’s approach to smart contract execution is based on how operating systems load and execute dynamic code. So, let’s have a look at the image below. As you can see, the client creates a program in whichever coding language, and then compiles it together with something called LLVM and sends it to the Solana Bytecode.

  • LLVM refers to a low-level virtual machine. It also refers to a compiling technology called the LLVM project, which is a collection of the modular and reusable compiler and toolchain technologies.

The output file is called an ELF. It has a specific bytecode as its target, which is designed for quick verification and conversion on the local machine instruction set (on which Solana is running).

A kernel is an essential part of a modern computing operating system used to initialize and manage critical resources such as CPU and Memory. It also provides a platform to run other programs on. Most of the time, smart contracts’ performance focusses on WASM, which we’ve discussed in earlier articles. However, Solana has also emphasized the bytecode, which is based on the Berkeley Packet Filter (BPF). BPF is a technology used in operating systems for programs that need to analyze network traffic, as is the case with smart contract technology. In a nutshell, it provides an interface to data link layers, allowing raw link-layer packets to be sent and received. The reason that Solana is basing their bytecode on BPF is that what the kernel does with untrusted code overlaps the requirements that they have. Which are:

  1. A deterministic amount of time to execute code
  2. Bytecode that is portable between machine instruction sets
  3. Verified memory accesses
  4. A short amount of time to load the object and verify the bytecode.
  5. The simplest, fastest, and easiest way to verify instruction sets.

If you’re wondering what bytecode is, it is a program code compiled from source code into low-level code designed for a software interpreter. As discussed with the LLVM, it can be executed by a virtual machine or compiled into machine code. See the video below for a further explanation.

Another aspect of importance is memory management. It all starts with the ELF file itself. At first, contracts are constrained to be read-only code and data segments: meaning, no mutable globals, or mutable static variables. As the Solana Network develops, this requirement can be relaxed. Since smart contracts do not hold state, Solana had to develop a way to manage the contract. Therefore, they’ve decided to create an interface for creating state; the interface is invoked through a transaction similar to any other contract method.

So, what are the pros and cons of building smart contracts on Solana? First, as mentioned in our previous article, Solana has implemented eight different key technologies that are essential for its existence. One of those is called Sealevel, which makes parallel smart contracts runtime possible. In many blockchain networks, one smart contract at a time influences and modifies the blockchain state. However, on Solana, the runtime can process tens of thousands of contracts in parallel. This allows for non-overlapping transactions to execute concurrently, and for transactions that are only reading the same state to execute concurrently as well.

Other pros of building on Solana are the max. transactions per second (59.490), the new creation of blocks every 400 milliseconds, and the low cost per transaction ($0.00001). A con, however, is that even though the Mainnet Beta version has been launched, most implementations are still waiting to be launched. Meaning, the network doesn’t work as smoothly as advertised. This could be solved with updates in the future. Check the blog for news on updates and projects.

🚀 Getting Started

Now that you know how smart contracts work on Solana, and you’ve seen the pros and cons. You might consider getting started with it yourself. So, if you’re looking to build an application or something else with the help of smart contracts, we suggest you take a look at the developer documentation first. For examples and demos, click here.

🧐 Conclusion

Smart Contract networks such as Solana have been among the hottest topics in the blockchain and specifically the Proof-of-Stake blockchain world. Many platforms are competing with each other. And while all platforms have some shortcomings, we’re interested to see how Solana is going to develop the smart contracts for the future.

More Information


DISCLAIMER: This is not financial advice. Staking, delegation, and cryptocurrencies involve a high degree of risk, and there is always the possibility of loss, including the loss of all staked digital assets. Additionally, delegators are at risk of slashing in case of security or liveness faults on some protocols. We advise you to do your due diligence before choosing a validator.

Join the conversation

Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.