Foresight Ventures: WASM—Engine of the Big Era

half a month ago
This article is approximately 3220 words,and reading the entire article takes about 5 minutes
WebAssembly is a portable, high-performance binary instruction format that can run in a web browser.

Original author: Mike@Foresight Ventures


WebAssembly (Wasm for short) is a portable, high-performance binary instruction format that can run in a web browser. It is designed as a general-purpose compilation target that can be used in multiple programming languages ​​and can run on different platforms.

Blockchain is a decentralized distributed ledger technology that ensures the security and trustworthiness of data through the use of cryptography and consensus algorithms. Blockchain can be used for applications such as recording transactions, storing data, and executing smart contracts.

There are some relationships and application scenarios between Wasm and blockchain:

  1. Smart contracts: Wasm can be used as an execution environment for smart contracts, allowing contracts to run on different blockchain platforms. Wasms high performance and portability allow smart contracts to be executed more efficiently and can be used across platforms.

  2. Cross-chain interaction: Wasm can be used to implement cross-chain interaction functions. By compiling the logic of different blockchains into Wasm code, the same logic can be executed on different blockchains to achieve cross-chain data transmission and interaction.

  3. Off-chain computation: Wasm can be used to perform computations outside the blockchain and submit the results to the blockchain. This can improve computing efficiency and flexibility while maintaining data security and credibility.

  4. Data privacy: Wasm can be used to implement data privacy protection on the blockchain. By compiling the processing logic of sensitive data into Wasm code and executing it on the blockchain, the privacy of the data can be protected while ensuring the verifiability of the calculation.

In short, Wasm and blockchain can be combined with each other to provide more efficient, secure and flexible blockchain applications and services. Wasms portability and high performance make it one of the important technologies in the blockchain field.

Foresight Ventures: WASM—Engine of the Big Era

1. What is WebAssembly?

WebAssembly is an efficient and lightweight instruction set standard developed by W3C (World Wide Web Consortium). It is known as a disruptor of network and high performance and supports cross-browser execution. This means that we can compile different programming languages ​​including C/C++, Go, Rust, etc. into a unified standard binary format, and use it as a replacement for JavaScript to run in the browser with near-native code efficiency.

Foresight Ventures: WASM—Engine of the Big Era

WebAssembly, or WASM for short, is memory-safe, platform-independent, and maps perfectly and efficiently to all types of CPU architectures, with the following key advantages:

  • Efficient: WASM has a complete set of language features. In fact, WASM is a binary format that is small in size and fast to load. Its goal is to fully utilize the capabilities of the hardware to achieve the execution efficiency of native languages.

  • Security: WASM runs in a memory-safe, sandboxed execution environment and can even be implemented within an existing JavaScript virtual machine. In a Web environment, WASM will strictly comply with the same-origin policy and browser security policies. When WASM is compiled, there are relatively few interfaces, but most wasm applications cannot be connected to the Internet (because they do not support sockets), and now they can only support local databases. Many security issues come from memory access during execution. Wasm can avoid illegal memory access when compiling.

  • Compatibility: WASM is designed to be versionless, feature testable, and backward compatible with the Web. WASM can be called by JavaScript, enter the JavaScript context, and can also call browser functions like a Web API. WASM can not only run on the browser, but also in non-Web environments (such as Node.js, Deno, IoT devices, etc.). The traditional method may require multiple compiles, but WASM only needs to be run once, plug and play.

Foresight Ventures: WASM—Engine of the Big Era

Plus: The web is the only truly universal platform that makes your apps accessible on any device. This also allows you to maintain a single code base, simplifying updates and ensuring that all users can access your application. WASM supports 64-bit and 32-bit integer operations, corresponding to CPU instructions one-to-one. By removing floating point operations, determinism can be easily achieved, which is necessary for consensus algorithms.

Powered by the LLVM Compiler Infrastructure Project, this means Wasm can benefit from over a decade of LLVM compiler optimizations. WASM is continuously developed by major companies such as Google, Apple, Microsoft, Mozilla, and Facebook. The backends of browsers developed by these major companies all support wasm compilation.

The beauty of WASM is that it is like a magic engine, it can run anywhere, there is no need to download or install because it is in binary format. With just one click, you can run web applications immediately when you need them. It is more secure than downloading and running the binary directly because the browser has built-in security mechanisms so that the code running in it cannot harm your system. And sharing web applications is just as easy - links are clickable strings that can be placed anywhere.

Foresight Ventures: WASM—Engine of the Big Era

2. Why do we need WebAssembly?

2.1 Web2

Thanks to the functionality built into browsers and the interactivity provided by the Web, the Web has evolved from hypertext static content and small scripting languages ​​into a very powerful and popular platform filled with amazing applications and features. But so far, web applications are still basically driven by the same scripting language (JavaScript), but the primary goal of JavaScript design has never been to achieve this.

JavaScript began as a simple scripting language designed to bring some interactivity to Web applications filled with lightweight hypertext documents. Its designed to be easy to learn and write, and not designed to be fast. Over the years, browsers have made significant performance improvements in JavaScript parsing, resulting in significant performance improvements.

As JavaScript runs faster, the things that can be executed in the browser have greatly expanded. The new API brings features such as interactive graphics, video streaming, offline browsing and more. At the same time, more and more applications (which used to be limited to local applications) are starting to enter the Web. Nowadays you can easily edit documents and send emails in the browser, but there are still areas where JavaScript performance is a challenge. Think about the software you use besides your browser: gaming, video editing, 3D rendering or music production. These applications perform a lot of calculations and require high performance. It is difficult for JavaScript to meet this high performance requirement.

However, it is not practical to replace JavaScript, and it may even take decades to do it, because the entire Internet cannot do without it. Moreover, there are a lot of people who are constantly improving JavaScript. It is true that compared with other languages, JavaScript is not good enough in some aspects such as null and ==, but these problems are not enough to make people replace the entire technology.

Foresight Ventures: WASM—Engine of the Big Era

Therefore, WebAssembly will not replace JavaScript, but this does not mean that no one will use WASM in the future. In fact, the use of WASM will become more and more widespread. Because WASM can bring powerful computing capabilities to web pages, such as image processing or games. Using WASM, you can create a web version of Photoshop that runs very well, or a 3D game that can run at 60 frames per second or even higher in the browser. Games are particularly challenging because they not only require simultaneous audio and video processing, but also coordinate physical effects and AI. WASMs ability to efficiently run games on the browser will open the door to the possibility of bringing many other applications to the browser.

Foresight Ventures: WASM—Engine of the Big Era

Foresight Ventures: WASM—Engine of the Big Era

The above figure shows a comparison of the workflows of javascript and wasm. It can be seen that wasm is much simpler than JavaScript.

2.2 Web3


In 2018, the Ethereum ecosystem began to discuss using WASM VM as a smart contract virtual machine because it felt that its performance was better than EVM. Gavin Wood, the inventor of EVM, has expressed the feasibility of WASM replacing EVM, and Vitalik has also stated that Ethereum 2.0 will be upgraded to the Wasm contract (eWASM) to meet more development needs. Now, the development of Wasm contract has taken a certain shape.

2.3 How is EVM designed? Why is it inefficient?

Schema size is too large

Traditional computers contain instruction sets that accept only 32-bit or 64-bit input. The EVM is different and special in that it is a 256-bit computer, intentionally designed this way to make it easier to process Ethereums hashing algorithms, and it will explicitly produce 256-bit output.

However, the computer that actually runs the EVM program needs to split the 256-bit words into their native architecture to execute the smart contract, making the entire system very inefficient and impractical.

Also, if you want to implement a complex algorithm like SHA 256 on Ethereum using its basic OPCODES, then good luck! In order to solve the high gas problem caused by running complex programs through the instruction set, Ethereum introduced the concept of precompilation, which compiles the program into the EVM and consumes a fixed amount of gas. One precompilation worth paying attention to is the Ethereum hashing algorithm, because if this algorithm is implemented in a virtual machine, the contract will incur extremely expensive fees when called.

Bloated precompilation

The problem with precompilation is that it continues to increase the bloat and complexity of the virtual machine without solving the core problem: the inefficient and poor design of the current instruction set and specification.

What if we could define a new specification and instruction set that didnt require precompiling these complex programs, but could be implemented efficiently with only basic instructions? This is where WASM comes in handy.

2.4 Comparison between EVM and WASM VM

  • speed: WASM is designed to provide faster execution than EVM. EVM may have efficiency issues when dealing with compiling and executing smart contracts, while WASM improves loading speed and processing power by directly converting to compiled code.

  • Precompiled: The EVM relies on precompiled contracts to efficiently perform cryptographic calculations, but this may lead to the risk of hard forks. WASM eliminates the dependence on precompiled contracts, allowing developers to create efficient and fast smart contracts.

  • transaction fee:The faster Wasm virtual machine can significantly increase transaction throughput, and contract deployment and transaction costs can also be significantly reduced. It can be said that the Wasm contract has solved the current problems of high transaction fees and transaction congestion on Ethereum.

  • Flexibility and interoperability: Wasm has expanded the language series available to smart contract developers, supporting the development and writing of complex business logic using any Wasm high-level language (such as Rust, C++, JavaScript, etc.), which means you can write smart contracts in any language you are familiar with. Including the most mature ink! based on Rust, or Ask! based on AssemblyScript, etc.

The EWASM team is integrating WebAssembly on Ethereum to ensure that the execution layer of Ethereum is more efficient and simpler, making it suitable as a completely decentralized computing platform. WASM has been adopted as a standard by many other projects, including Dfinity and EOS both using it to power their execution layers.

2.5 Stylus(Arbitrum)

The Stylus project improves the execution performance of smart contracts by introducing the WebAssembly (WASM) virtual machine on the Ethereum second-layer network Arbitrum. Contracts can be executed faster than Solidity while reducing gas costs. This makes it easier to build high-performance smart contracts on the Arbitrum network, currently supporting compilation in C, C++ and Rust.

Foresight Ventures: WASM—Engine of the Big Era

Custom precompilation support:Stylus also supports custom precompiles, which allows developers to deploy their own Rust or C++ precompiles to the Arbitrum network. This can help introduce new cryptographic algorithms or other specific features on-chain without having to wait for on-chain upgrades. For example, tensor computation can be pre-compiled to reduce inference costs, which may be helpful for on-chain machine learning.

Interoperability with EVM:Stylus enables integration with the existing Ethereum ecosystem through interoperability with the Ethereum Virtual Machine (EVM). This means that Stylus contracts can interoperate with existing EVM contracts and share the same global state with EVM.

Reentrancy:Unlike Cosmos wasm, Stylus Rust SDK introduces reentrancy and allows developers to manually enable it. This allows contracts to interoperate more flexibly, but requires developers to carefully manage state to ensure security.

Based on the popularity of the arbitrum ecosystem, stylus may be the most meaningful integration of wasm, and it will also benefit arbitrums competitiveness in zkrollup.

2.6 Gear(Polkadot)

Gear Protocol is creating a technology that can be deployed as a Polkadot parachain, which will be the tool for hosting smart contracts. Like Polkadot, Gear uses the Substrate framework. This simplifies the process of creating different blockchains for specific applications. Substrate provides a wide range of functionality out of the box, allowing people to focus on creating custom engines on top of the protocol.

Foresight Ventures: WASM—Engine of the Big Era

Previously, launching a blockchain was expensive, but Gear allows dApp developers to focus on their own projects rather than building and operating an entire blockchain from scratch.

The main engine of the Gear protocol is the smart contract module. In the case of Gear, any smart contract is a WebAssembly program compiled in different languages ​​(such as Rust, C, C++, etc.). It has a low barrier to entry for developers coming from outside the crypto world, as they can build smart contracts in a familiar environment. It is easier for developers to try smart contract programming languages.

Gear’s smart contract architecture uses actor models under the hood and provides the following capabilities:

  • Providing persistent memory for immutable programs

  • Asynchronous message processing

  • Minimal, intuitive and adequate API surface for blockchain context

  • The actor communication proxy model between on-chain components provides higher composability, better compatibility with parallel code execution and sharding.

Each program has a fixed amount of memory, which Gear allows you to control. A program can only read and write in its own memory and cannot access the memory space of other programs. Each program has an independent memory space and can process information on the Gear node in parallel.

2.7 CosmWasm(Cosmos)

CosmWasm is a modern, powerful Wasm-based smart contract platform that easily plugs into the Cosmos-SDK. This demonstrates one of the main advantages of CosmWasm: contracts written in CosmWasm are natively and tightly integrated with IBC (Inter-Blockchain Communication), allowing developers and users to enter a multi-chain future, currently only supported in Rust.

Foresight Ventures: WASM—Engine of the Big Era

Advantages of CosmWasm

  1. safety:Improving the security of smart contracts using the Rust language.

  2. Cross-chain compatibility:IBC (Inter-Blockchain Communication) protocol support in the Cosmos ecosystem.

  3. performance:Compared to traditional EVM (Ethereum Virtual Machine), CosmWasm has demonstrated higher efficiency and lower transaction fees in some cases.

  4. Developer friendly:The Rust language’s type-safety and memory-safety features reduce certain types of bugs in smart contracts.

challenges and limitations

  1. learning curve: Compared to more commonly used smart contract languages ​​such as Solidity, Rust may have a steeper learning curve for beginners. CosmWASM needs to support more language compilations to gain the possibility of mass adoption.

  2. Ecosystem and tool support: Although growing, CosmWasm’s development tools and ecosystem may still be limited compared to mature smart contract platforms such as Ethereum.

  3. Market share and popularity: Among smart contract platforms, CosmWasm may not be well-known compared to Ethereum, Binance Smart Chain, etc., which affects its ability to attract developers and users.

  4. Maintenance and upgrade challenges: Although CosmWasm provides contract upgrade functions, the maintenance and upgrade management of smart contracts is still a complex task that needs to be handled carefully to avoid security vulnerabilities.

  5. Compatibility issues: For projects that are accustomed to the EVM or other smart contract environments, migrating to CosmWasm may face compatibility challenges.


In addition to the wasm virtual machine, there is also a recent emerging technology ZKWASM. The inventor Delphinus Labs has open sourced the ZK-WASM code on github. ZKWASM enables developers to verify the correctness of performed calculations without re-executing them. By leveraging ZKWASM, developers have the flexibility to build ZKP applications using a variety of programming languages. These applications execute seamlessly in a Web browser.

Foresight Ventures: WASM—Engine of the Big Era

The concept of ZKWASM comes from ZKSNARK, which is a hybrid of SNARG and zero-knowledge proof. Lets explain, usually, to use ZKSNARK, you need to write a program in an arithmetic circuit language or circuit-friendly language, such as Pinocchio, TinyRAM, Buffet/Pequin, Geppetto, xJsnark framework, ZoKrates, etc. This poses an obstacle to existing programs to some extent, making it difficult for them to leverage the power of ZKSNARK. But there is another way, not to use ZKSNARK at the source code level, but to use it at the bytecode level of the virtual machine, and then implement a virtual machine that supports ZKSNARK. Delphinus Labs adopted the latter approach and wrote the entire WASM virtual machine into the ZKSNARK circuit, so that existing WASM applications can run directly on ZKWASM without any modification. Therefore, the cloud service provider can prove to any user that the calculation results were calculated honestly without revealing any private information.

Foresight Ventures: WASM—Engine of the Big Era

ZKWASM provides various use cases, such as allowing ZK proofs of some operations in the browser to be uploaded to the chain. Make web page operation blockchain verifiable. Another example is oracles, off-chain computing, automation, connecting Web2 and Web3, and generating proofs for machine learning and data processing, and even games and social applications. As adoption increases, zkWASM will expand the possibilities of Web3 and bring Web2 developers into this transformative landscape.

Through Delphinus Labs ZKWASM implementation, developers can harness the power of zero-knowledge proofs to enhance the security and privacy of their applications, paving the way for a more trustworthy and decentralized digital landscape.

3. Conclusion

The future is bright for the performance of the web and the execution layer of smart contract platforms. Not only will dApps have higher performance, integrating WASM will also make smart contract development easier for those who are familiar with the robustness of mainstream languages ​​​​such as Rust and Go, rather than needing to learn Solidity or other blockchain development languages. Various details are needed to develop useful applications on Ethereum. According to Evans Data Corporation, there are nearly 27 million developers worldwide. This number is growing steadily - by about 3% last year and is expected to exceed 28.7 million by 2024. There are no more than 30,000 developers on the blockchain, accounting for about one thousandth of the total number of developers. Although this number has been steadily increasing, it may still be difficult for developers to learn new smart contract languages. The threshold for entering the blockchain.

Foresight Ventures: WASM—Engine of the Big Era

But more and more blockchains are beginning to support Web Assembly as the bytecode of compiled smart contracts. WASM brings not only high efficiency, interoperability and a wide range of application scenarios to the blockchain, but also the key to liberating developers and lowering the entry threshold for developers to enter the blockchain. Imagine the blockchain. In the near future, when Web2 developers want to try blockchain development, they can use their familiar Python, C++, and Javascript to develop large-scale applications on the blockchain to maximize the release of area. The value of the blockchain decentralized network is to first lower the threshold for creators (developers), then lower the threshold for users, and move towards Mass Adoption.

4. Index 18 f 67 cee 15 c 147 dfae 68 b 06269 a 455 c 0 ?pvs=21

Thanks to Maggie, Xinyou Ji (CMU), and Sinka Gao (Delphinus Labs) for providing suggestions and guidance on this article.

About Foresight Ventures

Foresight Ventures is betting on the innovation process of cryptocurrency in the next few decades. It manages multiple funds: VC funds, secondary active management funds, multi-strategy FOF, and special purpose S fund Foresight Secondary Fund l. The total asset management scale exceeds 4 One hundred million U.S. dollars. Foresight Ventures adheres to the concept of Unique, Independent, Aggressive, Long-term and provides extensive support for projects through strong ecological power. Its team comes from senior people from top financial and technology companies including Sequoia China, CICC, Google, Bitmain and other top financial and technology companies.

Original article, author:Foresight。Reprint/Content Collaboration/For Reporting, Please Contact;Illegal reprinting must be punished by law.

ODAILY reminds readers to establish correct monetary and investment concepts, rationally view blockchain, and effectively improve risk awareness; We can actively report and report any illegal or criminal clues discovered to relevant departments.

Recommended Reading
Editor’s Picks