What can Ontology Wasm do for developers?

The Ontology Team
OntologyNetwork
Published in
4 min readJun 20, 2019

Imagine you are a dApp developer and you have just launched a puzzle game dApp on a leading public blockchain platform after months of research and coding. Since its launch, the number of users has skyrocketed. Instead of becoming complacent, you began to think about what’s next:

What will become of this dApp?

Scenario 1: This puzzle game is super fun! The game has taken the world by storm since its launch, and is now on the most-popular dApp ranking! So you are thinking of bringing the dApp onto other top public blockchains to reach more users.

Scenario 2: User growth soon reached a plateau. So you are thinking of moving the dApp to other platforms to explore new opportunities.

You then realized that if the dApp can be instantly integrated into different platforms, it will enjoy long-term growth.

However, you need to use different programming languages to develop dApps on different public blockchains. If you have the same problem, then the Ontology Wasm is just the right thing for you.

What is Wasm?

Wasm is a binary instruction format initiated by Google, Microsoft, Mozilla, and Apple. It enables deployment on the web for client and server applications.

Wasm MVP standard is now supported by most mainstream browsers. Moreover, applications written in many other languages (C, C++, and Rust) can be compiled into Wasm byte code. An application ecosystem based on this greatly reduces the learning costs for developers.

Currently, EOS is one of the few public blockchains which support Wasm VM. Some are still under development. The Rust community by far offers the most comprehensive support for Wasm, as its compiler and the standard library can be used directly. Some other languages are also carrying out experimental projects on Wasm, such as Go, Python, and Java.

Introduction to Ontology Wasm Virtual Machine

The Ontology Wasm Virtual Machine runs in a sandboxed environment and uses the open-sourced Wagon project as the interpretation engine for Wasm. Based on Wagon, the Ontology Wasm blocks the types and methods related to floating-point numbers and added fee calculation.

Contracts are deployed and called as follows:

As can be seen, we distinguish NeoVM contract and Wasm contract using contractype field, and different types of contracts will run on the corresponding virtual machine sandboxed environment.

Ontology Wasm Advantages

  1. C++ standard support:

C++ is a very popular language and has a good developer base. C++ has introduced many modern programming language features since C++11, 14, and 17, such as type inference, lambda expressions, templates for variable length arguments, list initialization, rvalue reference, and perfect forwarding, which make C++ more powerful. The C++20 standard has entered the feature freeze phase and will be a major version after the C++11 standard. Currently, frozen features such as Module and reflection will be more convenient for developers. Thanks to the support of modern standards in C++, developers can pay more attention to their business logic.

2) Rust support:

Rust has been voted Stack Overflow’s most liked language for three consecutive years and offers the most comprehensive support for Wasm. Developers can use Cargo, a native tool, to compile Wasm byte codes directly. They can also use the existing standard library.

3) Library support:

The community offers a lot of readily available resources for both C++ and Rust, which can greatly reduce the costs for developers;

4) Multi-language support:

As the Wasm ecosystem grows, more smart contracts written in C++ and Rust will support Wasm, so that codes can be used repeatedly in the Wasm ecosystem.

Ontology Wasm C++ Contract Development Tool

Ontology CDT

Ontology CDT is a C/C++ supporting Wasm contract development tool. It supports libc/libcxx/boost/libcrypto library. The most commonly used one is libcxx. Developers can also use the frequently-used vector, array, map, list, and queue data structures and methods. The Ontology CDT provides ont_cpp, a C++ compiler, Wasm-objdump, a decompiler, and Wasm-opt optimizer. Developers can use ont_cpp to compile C++ contracts into Wasm byte codes and deploy them on the TestNet.

For more details refer to the links below:

a. Introduction to Ontology Wasm C++ CDT;

b. Introduction to Ontology Wasm C++ CDT interface and data structure;

c. How to use Ontology Cli to deploy or call Wasm contract (take OEP-4 as an example):

Ontology Wasm Rust Contract Development Tool

Rust is currently the best language to support Wasm. The Rust contract development tool we provide supports code distribution framework, optimizes memory allocation, contract storage management, and Ontology Blockchain API, a contract testing framework.

a. Introduction to Rust contract development tool

b. Rust contract development tool tutorial

Ontology Wasm Go SDK

We provide Go SDK for automatically deploying and calling Wasm contracts.

a. Wasm Go SDK;

b. Wasm Go SDK contract deployment and call samples

Are you a developer? Make sure you have joined our tech community on Discord. Also, take a look at the Developer Center on our website, there you can find developer tools, documentation, and more.

--

--