WebAssembly - Wiki OpenEthereum Documentation

The development of this feature was supported by the Energy Web Foundation in order to expedite the energy sector revolution towards decentralisation.

General overview

Along with EVM, OpenEthereum has an experimental support for WebAssembly as a bytecode for contracts. Some advantages of WebAssembly (WASM for short) are:

Getting started

To allow your custom chain to take advantage of WASM contracts, just enable them in in your chain spec JSON file under params section by specifying block number starting from which WASM bytecode is allowed to run (wasmActivationTransition).

For example, params section might look like this:

	"params": {
		"accountStartNonce": "0x0",
		"maximumExtraDataSize": "0x20",
		"minGasLimit": "0x1388",
		"networkID" : "0x11",
		"wasmActivationTransition": "0x1"
	},

Now the engine will be able to distinguish and run WASM byte code if it is used as a contract code. Note that this is the addition to the EVM, so all your EVM contracts on chain are safe and will continue to function as before!

Building simple contract

Any valid WASM module with the exported call function can be used as a contract code. As our codebase is dominated by Rust language, we use experimental Rust tools to compile actual contracts.

Simple contract in Rust language might be as short as this:

#![no_std]

extern crate pwasm_ethereum as ext;

#[no_mangle]
pub fn call() {
    ext::ret("Hello world");
}

Which always return "Hello world" string to the caller.

See Links examples section for some more sophisticated examples.

Other languages for contracts

If your language of choice can be compiled in WebAssembly and can generate bindings for those syscalls, you are good to go.

Integrating in the existing toolchain

See our Links repositories section for some general-purpose WebAssembly repositories we support.