Skip to main content

Web Assembly Smart Contract (WASM)

WebAssembly is used in Substrate as a compilation target for the runtime.

Why WebAssembly?

WASM is used as a binary instruction format for a stack-based virtual machine. It is designed as a target for compiling high-level languages such as C/C++/Rust. This enables deployment on the web for server and client-based applications.

From a technical perspective, WASM is used as a platform-agnostic binary format. This means it would run similar instructions throughout whatever machine it operates on. Blockchains need determinacy to have highly reliable state transition updates throughout all nodes within the peer-to-peer (P2P) network without forcing every peer to run the same exact hardware. WASM is very fast and efficient. The efficiency illustrates that it could be uploaded onto the blockchain as a blob of code. This results in it not causing bloating while maintaining its ability to execute at near-native speeds.

Smart Contract Deployment on WASM