The Power Blog

Our smart contracts: Rust + Wasm


Our vision of Smart Contracts

This post aims to highlight our vision and our very kind of smart contract. Of course, in order to do so, we’d have to get some general and important notes out of the way.

With that said, let’s begin with the definition of a smart contract. As a matter of fact, however, we can easily split smart contracts into two separate groups. The first type would be defined as a script which can execute certain types of interactions. The second group defines smart contracts as a fully-fledged program which is capable of executing almost any type of interaction, even if it weren’t put into program logic.

What is more, all smart contracts could also be split into two different groups by the way they are saved in the blockchain. The first type of smart contracts is inserted into the code of the blockchain (e.g. Graphene), while the second type is saved into the blockchain and executed for security reasons within a Virtual Machine (VM).

We, from The Power, decided to shatter script limitations. As such, our smart contracts are fully-fledged programs which are saved into the blockchain.

The most popular example of a virtual machine in the blockchain community is EVM — Ethereum Virtual Machine. Of course, we could easily choose the simple way and use EVM along with smart contracts built with Solidity. But as you may already guess, we chose another way. And here’s why.

After we explored EVM thoroughly, we decided to build our very own VM based on Wasm. The EVM code which is inextricably linked to Ethereum’s blockchain has critical limitations for implementation into our own blockchain. What is more, we decided that Wasm, in terms of technology, is more perspective compared to EVM. As it turns out, our opinion was backed up by many popular blockchain projects.

What is Wasm?

According to Wikipedia:
“WebAssembly (Wasm, WA) is a web standard that defines a binary format and a corresponding assembly-like text format for an executable code in Web pages. It is meant to enable executing code nearly as quickly as running native machine code. It was envisioned to complement JavaScript to speed up performance-critical parts of web applications and later on to enable web development in languages other than JavaScript.”

Even though Wasm is developed for Web usage, its roadmap also mentions IoT implementation and multi-threaded apps development. Wasm is the result of long years of joint work of W3C — a consortium of tech moguls Microsoft, Google, Apple, and Mozilla.

It’s also important to note that Wasm is compatible with a family of compiler programs such as LLVM (Low-Level Virtual Machine). If a device contains such a compiler program, Wasm can easily be executed on it. For example — on a smartphone.

You could read about Wasm here and here.

By the way, Ethereum announced they are going to switch to Wasm, while EOS already uses Wasm (with C++).

Why Rust?

Among languages which are compatible with Wasm Rust was chosen for a range of different reasons, including embedded tests, simple refactoring, a universality of the language and last, but not least — it has a number of limitations for developers to prevent bugs in the process of writing programs. Put simply, writing a program with bugs is much more difficult to happen while using Rust. What is more, we observe a growing interest in Rust — Parity, for instance, has moved to Rust and Wasm.

Current state

Currently, we’ve developed the alpha version of the Power_VM — a program shell which links programs based on Wasm with The Power blockchain.

Now, our smart contract could be compiled to Wasm code, inserted into blockchain and executed within The Power testnet. We already tested smart contracts which are analogues of ERC-20 standard.

In the future, we plan to develop a marketplace with smart contract samples to provide an opportunity for normal users to use it for a range of purposes.
Now, we are developing a new type of smart contract. We call it DApp 2.0 as it is a full-stack decentralized application. We kindly ask you to be patient and it will be disclosed in the near future!