Updates from the Provenance Blockchain Ecosystem
Introductory Guide on EVM and WASM
19 April 2023
Basics on virtual machines, the differences between EVM and WASM,
and how to convert your EVM smart contract to WASM.
Smart contracts are a core component of automated financial services on blockchain technology. Smart contracts are built outside of the protocol, which can introduce risks. For that reason, Provenance Blockchain has built smart contract capabilities directly into the protocol. These capabilities are called Markers (Markers technical specifications).
Markers can make your transition to Provenance Blockchain seamless. If you are transitioning from an Ethereum-based blockchain and desire to build your own smart contract to support it, then you will likely need to transition from an EVM to a WASM virtual machine.
What is a virtual machine (VM)?
A virtual machine is a software-based emulation of a physical computer that allows multiple operating systems and applications to run on a single physical machine. It creates a virtual environment that abstracts the underlying hardware, allowing software to be executed in a standardized and isolated manner.
In the context of blockchain, virtual machines are used to execute smart contracts and decentralized applications in a secure and deterministic manner, ensuring that the code behaves predictably and cannot be altered or manipulated by external parties. The virtual machine concept also allows the blockchain to isolate the code so that it cannot reach out to off-chain data, which could lead to security or determinism issues.
Ethereum Virtual Machine (EVM)
While the concept and use of virtual machines existed well prior to blockchain technology, its first deployment on a blockchain was on Ethereum.
EVM stands for Ethereum Virtual Machine. EVM is the software platform developers use to deploy decentralized applications (DApps) on Ethereum and the environment where all smart contracts and Ethereum accounts live, and it is specifically designed to execute code written in Ethereum's Solidity programming language or Vyper.
WebAssembly Virtual Machine (WASM VM)
Considered a “Javascript killer and the next frontier of cloud computing, and the fourth official standard language of the web,” WASM VM stands for WebAssembly Virtual Machine, which is a software runtime environment that executes code written in the WebAssembly. WebAssembly is a compilation of C++, Rust, and AssemblyScript. WASM VMs are used in a variety of contexts, including web browsers, server-side applications, and even IoT devices. WebAssembly Virtual Machine is an important tool for building high-performance applications, such as mobile apps, websites, and smart contracts on blockchain. It provides a powerful and flexible environment for running code in a safe and secure way.
WASM was initially created for executing code in web browsers, and several high-performance examples exist from Microsoft, Google, Apple, and Mozilla.
The WebAssembly Virtual Machine is responsible for loading and executing WebAssembly code, and it provides a sandboxed environment that ensures that code is executed safely and securely. The virtual machine is designed to be fast and efficient, with a focus on performance and low overhead.
Comparison: EVM vs. WASM VM
Guiding Principal:
EVM was built for consistency and technical purity, whereas WASM was built for secure, safe execution and extreme/native level performance. It is considered far easier to add consistency to WASM (by removing floating point and limiting external APIs) than to add performance to the EVM.
Interoperability:
WASM is designed to be interoperable with other programming languages and blockchains, which makes it an ideal candidate for building decentralized applications for use across various blockchains and decentralized applications, whereas EVM is designed specifically for Ethereum, which introduces interoperability challenges with other blockchains and decentralized applications.
Security:
EVM is known to be vulnerable to a variety of attacks, including Solidity attacks, reentrancy attacks, integer overload and underload attacks, and denial of service attacks. These vulnerabilities can be mitigated through careful programming and auditing, but even then, EVM represents potential risks.
In contrast, WASM was designed to run in a sandbox environment, which means that it is isolated from the rest of the network and cannot access or modify data outside of its own memory space.
Web browsers/WASM on mobile devices require extremely rigorous security guarantees, which are useful for safely executing code on a blockchain. CosmWASM (Cosmos WASM) was specifically designed to combat the types of attacks that EVM is vulnerable to. Incrementally, the Provenance Blockchain Markers further mitigate potential risks.
Gas Fees:
When there is high demand and network usage, gas prices can rise significantly, even for those making small transactions, which smart contracts can tend to be. This is a challenge EVM smart contract operators have experienced over the last few years. The challenge Ethereum has is that much of the on-chain activity is low value. Unlike Ethereum, Provenance Blockchain does not have any scaling fees. Further, Provenance Blockchain is specifically designed for high value financial services-only transactions, focusing on a single use-case "financial services" means resources are not shared with other use cases such as collectables, online games, or token speculation schemes.
Scalability:
One major difference is that EVM is a stack-based virtual machine, while WASM is a binary instruction format for a stack-based virtual machine. The issue with the EVM is that the stack is extremely small (1024 positions) and each slot is 256 bits, making them wasteful for small operations and also massively limiting the complexity supported by contracts due to the small overall stack size.
Efficiency:
EVM relies on precompiles (precompiled contracts). When a call for a precompile is issued, EVM will execute a predefined native code and then present the results. These precompiles are specific to a certain protocol for the basic operations, such as signature schemes and hashes.
Even though precompiles make cryptographic computations efficient without consuming loads of gas, they come with issues. The introduction of new precompiles usually demands the network to undergo a system-wide hard fork.
A Provenance Blockchain Marker could be described in a similar way to a precompiled function. However, the Provenance Blockchain protocol and its Markers, as well as WASM, eliminate Ethereum’s reliance on precompiled contracts. Because Provenance Blockchain and WASM is so gas efficient, developers can create smart contracts that are efficient and fast without worrying about potential hard forks.
Programming Language:
In addition to Vyper, EVM commonly uses the Solidity programming language, which is relatively new and has a steep learning curve. WASM supports multiple programming languages, including Rust, C++, and AssemblyScript, which can make it easier for developers to build and deploy smart contracts. Though Rust has a learning curve, it has several major advantages over Solidity, such as memory safety and fewer system bugs.

While EVM has experienced an early rush of popularity and adoption, the benefits of WASM are too valuable to be overlooked. Specifically, the portability, performance, security, and interoperability of the WASM virtual machine, all of which make it a highly attractive solution for building decentralized applications and smart contracts on the blockchain. When you add the benefits of WASM to the core pillars of Provenance Blockchain protocol level, capabilities purpose-built for financial services at the protocol-level, financial institutions and fintechs have a secure future-proof solution for managing the lifecycle of their digital assets.
Transition from EVM to WASM:
First, being purpose-built for finance, many of the smart contract capabilities are built-in to the Provenance Blockchain, which means you can leverage existing capabilities without building your own smart contracts.
Rewriting an EVM smart contract to a WASM smart contract involves a few general steps:
- Understand the differences between the programming languages: EVM is often written in Solidity, while WASM in the Cosmos ecosystem is written in Rust. If you're not familiar with Rust, it's important to learn the language and its syntax.
- Modify smart contract code: EVM and Provenance Blockchain WASM will have different guidelines and directions. For example, Provenance Blockchain provides the benefit of Markers, which you can use with your smart contract. You may need to modify your code to use Markers, and you may also need to modify your code to work with the Rust programming language.
Bonus
To enable a quicker smart contract build, Provenance Blockchain Foundation has already done the majority of the work with this standard contract template. Developers only need to define their messages and plug in any custom logic. The templates include properly documented README, and documented functions that can be used as guidelines, example tests, and implementation.
Test and deploy your updated smart contract on Provenance Blockchain: Once you have modified your smart contract code, you will need to test it to ensure it works as expected. Then you can deploy it on the Provenance Blockchain network. As with Ethereum and other blockchains, any new smart contract code regardless of whether they leverage Markers will need to go through a standard governance vote to help ensure the code does not introduce vulnerabilities and is in alignment with current standards.
It's important to note that these steps may vary depending on the specifics of your smart contract and the requirements of the Provenance Blockchain network. It's also recommended to seek guidance from a developer experienced with both EVM and WASM to ensure a smooth transition.