TL;DR? gWasm is our new use-case AND a core part of the Golem API, and developers can already build their Golem integrations through it. As the Golem API/Task API development progresses, both gWasm and the API will get better.



We have mentioned a couple of times that one of our upcoming use-cases was going to be a WebAssembly integration. Today, we would like to explain what it is, what it enables and how developers will be able to build applications on top of Golem thanks to it.

For clarity, gWasm is the name of this new use-case, so from here, we’re going to call it that way. Without further ado, let’s start.

What is Wasm?



WebAssembly, or Wasm for short, originally coming from the world of web browsers, is a relatively new, OS-independent binary format (much like Java in fact) that allows arbitrary applications to be compiled to a form that allows them to be executed with close-to-native performance in a cleanly sandboxed environment on a variety of hardware and software systems.



What is gWasm? How does it fit into Golem?



gWasm brings Wasm to Golem. As mentioned in the header of this blogpost, it is a first step towards a larger Golem API, and gWasm enables the community to develop and run their own apps compiled to Wasm on Golem network with as little fuss as possible!

In the process of integrating Wasm with Golem, we came up with a slogan describing the experience we hope to achieve with gWasm: if you can compile it to Wasm, you can distribute it on Golem network!

This is best described with an example: with gWasm, you can now leverage cool open-source projects such as a text-to-speech project flite, to do your bidding distributed over Golem network! In fact, for flite, we have come up with a simple CLI g-flite that is meant to showcase how flite can be distributed over Golem network with gWasm. We encourage you to take a closer look and let us know what you think!



How is it useful for me?



If you design an algorithm (C/Rust) that can be executed in parallel, it is very likely that it can be computed with gWasm. The potential applications range from scientific and molecular computations, BOINC alike, to graph algorithms, etc. All you need to do is cross-compile your code to Wasm, create a Golem task and run it.

As a developer, gWasm offers you the possibility to use Golem as a computing backend for your app. Your app could then consist of a front-end (client) of your own design (a GUI or CLI or whatnot) which would use Golem network to execute any heavy tasks encapsulated as Wasm binaries. This way, your users need to have the Golem node up and running, and only need to know how to use your app rather than delve deep into the intricacies of launching a Wasm task in Golem. We provide an example for just that in the form of g-flite app.

If you are a service provider, you can support your services with gWasm as your backend. Having your own cluster or buying cloud instances is not necessary. You can run your services with a small infrastructure and delegate high performance tasks such as gWasm tasks to Golem network, and your users do not even need to have Golem nodes up and running.



What does it facilitate?



Until very recently, people mainly associated WebAssembly with web browsers. This trend is changing rapidly thanks to standardisation efforts in the form of WebAssembly System Interface (or WASI) which will essentially allow WebAssembly to be run on the server. gWasm is a nod in that direction, taking Wasm from the browser environment and enabling server-side computations. This implies that gWasm will not run in a web browser but on the different Golem Nodes. Note that while gWasm is currently not WASI compatible, we are actively participating in WASI’s development together with Mozilla Foundation, and when it’s tagged stable (currently, still experimental), we will make gWasm WASI compatible as well.

Wasm was designed with memory-safety and security in mind. Without going into the gory details, Wasm executes in a sandboxed environment protecting the server from any malicious code trying to escape via memory violations, etc. This offers a good level of security for the providers so you can run gWasm confident that you are safe.

The portability that Wasm offers means that the same code can be executed on different OSes, making gWasm a “meta use-case” or platform, allowing developers to build/run your applications in Wasm on top of the Golem Network, adding arbitrary code to Golem.



How is gWasm different than all the Wasm products out there?



The beauty is that it is not. gWasm currently employs a very successful JavaScript engine developed by Mozilla Foundation, SpiderMonkey, to execute Wasm securely and efficiently on a Golem node. So in terms of Wasm, gWasm doesn’t offer anything beyond what’s already available. However, in terms of distributed computing, gWasm offers a very powerful concept of distributed secure arbitrary computing in Golem. What this essentially implies is that if you can compile it to Wasm, you can distribute it on Golem network!



Okay! Where can I find more information?



Great that you ask! As per usual, our docs are a good place to start in familiarising yourself with gWasm task structure, how to launch such a task in Golem, etc. The link to this resource. Additionally, as already mentioned, if you would like to bundle your shiny new gWasm use-case with a cool GUI/CLI client, g-flite is a good place to start to see how it all ties together.

On a more technical note, if you would like to explore the actual Wasm sandbox that gWasm uses, have a look here.



When will you launch gWasm on mainnet and what do you plan to grow the userbase?



Launch on mainnet is predicated on two critical bits that Golem client needs to provide: integrated verification by redundancy and pay-as-you-use (or Pay-as-you-Golem as it’s referred to by our userbase now). We are not able to provide an exact date when that happens, but we envision gWasm being available on mainnet within the next couple releases, so stay tuned!

As far as growing the userbase is concerned, we’ve already taken some preliminary steps in providing as many complete examples as possible, g-flite client being one of them. Having said that though, if you can think of a good gWasm app, get in touch and we’ll be more than happy to offer mentorship and help you out in integrating your app with Golem!



Did we spark your interest and you’re wondering what to do next?



If you are an interested dev - reach out - contribute to our repos: