dApps Building Blocks for Web3: SewUp for Writing Ethereum WebAssembly in Rust
In blockchain hackathons around the world this fall, a buzz of excitement permeates the developer community. Developers are building dApps for Web3 applications in DeFi, gaming, NFTs and metaverses using the Rust programming language. A programming language has not created such excitement since JavaScript rose to dominance as the language of the first generation Web in the 1990s.
What’s all the buzz about? Most blockchain applications are built for the Ethereum blockchain. Rust is well-positioned to be the programming language to unseat the most commonly used development language for Ethereum dApps, Solidity.
Rust’s primacy was secured when Ethereum released the SecondState EWasm Utility Program (SewUp) library in September.
What is SewUp?
The SecondState EWasm Utility Program (SewUp) is a library that helps developers to write Ethereum WebAssembly in Rust. The use of WebAssembly as a format for smart contracts has a variety of benefits, including:
- Near-native execution speed for smart contracts
- Support for smart contract development in many traditional programming languages, such as C, C++, and Rust
- Access to a vast developer community and the toolchain surrounding WebAssembly
WebAssembly, widely considered to be the standard for Web3, runs consistently across different systems and platforms and is already used in all major browsers. Using Rust and WebAssembly, developers can run a consistent client over different platforms.
What Are the Advantages of Rust?
Frustrated C++ programmers are embracing Rust. Rust is considered a faster, more reliable and safer program than its main nemesis. With Rust, developers can write high level abstractions like games and web applications without the memory management headaches of C.
- Improves memory management — Rust does not run a garbage collector in the background to manage memory, making it faster and more efficient with a low memory footprint.
- Identifies bugs early — The compiler will stop you from building a program that shares memory in an unsafe fashion, saving time by preventing data races before testing the program.
- Supports zero-cost abstractions — Any code abstraction can be complied to the same assembly without a drag on performance.
- Provides near native performance — Compiles any language into WebAssembly.
- Prevents data races at compile time.
- Supports cross-platform development across operating systems.
Rust + WebAssembly
Rust and WebAssembly are a powerful tour de force. Several studies have clocked 2-figure performance improvements in WebAssembly runtime in Rust over other programming languages such as Java and Python.
SecondState reports the following performance:
- Rust is 2x (200%) faster, but uses only 1% of the memory compared with Java.
- Rust is 150x (15,000%) faster, and uses about the same amount of memory compared with Python.
SecondState has concluded that Rust programs are optimized in WebAssembly virtual machines where they benefit from improved performance, safety, security, and portability.
In a benchmark WebAssembly study conducted by Second State and presented in IEEE Software, ParaState’s Second State Virtual Machine (SSVM) demonstrated cold start and execution times at least 10 times faster than the leading non-WebAssembly runtime solution, Docker.
Based on these benefits. Rust has staged a quiet revolution in the program development world over the last year. Rust was nominated the most loved programming language among developers in 181 countries in the 2021 Developer Survey. Rust used by only 7 percent of developers was the most loved (86.98%) while C++ used by 23 percent of developers was among the most dreaded (49.24%). As use of the blockchain grows, Rust could start closing in on C++ and JavaScript, used by 65 percent of developers.
How to Master SewUp at Hackathons
Given these benefits, developers eager to learn the SewUp toolkit are flocking to the most popular hackathons for Substrate-based blockchains this fall. The developers over at Polkadot have called the Substrate Rust Docs the pillar of the @Polkadot Hackathon 2021.
The foundation of the Polkadot tech stack, Substrate is architected in WebAssembly (Wasm) using Rust, and secondarily JavaScript. The easy-to-use and fast Rust language well suits the goal of Substrate to make building blockchains and dApps as easy as building legos. Substrate is a blockchain-in-a-box, building blocks of common abstractions for creating blockchains, such as network logic and transaction queues, to build blockchains in days rather than months. Wasm is an open source tool allowing for rapid coding and compilation already used in major browsers, and by Google, Apple, and Microsoft, among others.
Using WebAssembly in Rust, developers can run a consistent client over different platforms and devices (PCs, mobile). The runtime can be uploaded to a chain, making it easy to build out Polkadot’s ecosystem of interoperable chains.
Likewise, ParaState’s SSVM virtual machine was built to easily build and migrate Ethereum dApps to high performance Substrate chains. At the ParaState Writing Ethereum WebAssembly in Rust Hackathon, the toolkit includes:
- Rust Sew-up SDK
- BUILDL, a browse-based IDE
- Substrate SSVM node
With these tools, developers can build Ethereum dApps using the SSVM pallet that run on high performance Substrate blockchains like Polkadot.
Hackathon participants are building NFT marketplaces, metaverses, and decentralized exchanges. $100,000 in rewards is up for grabs. Projects must be open source and deployed on the ParaState testnet Plato.
Building with SewUp in Rust does indeed have a Lego building blocks feel to it. At substrate.io, developers can find simple tutorials, How-to-Guides, on how to implement specific tasks in SewUp, such as a basic storage migration or integrate a pallet into your runtime. ParaState provides step-by-step SewUp instructions for building dApps for an NFT marketplaces, storage, and other applications.
Developers can access the SecondState SewUp library on GitHub.
About ParaState
Known as Ethereum on steroids, ParaState is a multi-chain smart contract platform bridging the application and developer ecosystem between Polkadot, Substrate and Ethereum, as well as other chains wanting to provide Ethereum compatibility. While supporting the EVM pallet to provide seamless compatibility with all existing Ethereum applications, ParaState also provides developers with a next-gen smart contract implementation environment, Ethereum-flavored WebAssembly. These two infrastructures are ensured to talk to each other and share the same account system on ParaState.
Join ParaState’s community:
Website | Blog | Twitter | Telegram | Discord | Facebook | Github