The Wat section will output the program in WAT (WebAssembly human-readable text) format. You should a line resembling:

(export "_Z4facti" (func $_Z4facti))

Keep note of the text _Z4facti, or whatever else it may be. _Z4facti is the name of the function we compiled; we’ll need the function name so that we may execute the function from our module in Go via. Life.

Make sure to also download the module in *.wasm format by clicking Download.

How do I use Life?

First, let's read the raw byte contents of our *.wasm module (we’ll call it factorial.wasm for this article).

// Read WebAssembly *.wasm file.

bytes, err := ioutil.ReadFile("factorial.wasm")

if err != nil {

panic(err)

}

Now lets initialize our WebAssembly virtual machine and feed in the bytes of our WebAssembly module.

vm, err := exec.NewVirtualMachine(bytes, exec.VMConfig{} , new(exec.NopResolver))

if err != nil {

panic(err)

}

We’ll now get the ID of our function _Z4facti.

id, ok := vm.GetFunctionExport("_Z4facti")

if !ok {

panic("function could not found")

}

Finally, lets pass in a number (say 35) as a parameter to our function, execute it by passing the ID our VM, and print out the result of the function decoded to a float64.

result, err := vm.Run(id, 35)

if err != nil {

vm.PrintStackTrace()

panic(err)

}

fmt.Printf("35! = %f

", math.Float64frombits(uint64(result)))

And that’s all!

You’ve successfully executed a function in your WebAssembly module with a full-blown embeddable WebAssembly VM which you can incorporate in any of your projects.

Feel free to link it up to your Android app, desktop app, Raspberry Pi micro-controller; there are an endless amount of possibilities 😄.

How fast is Life?

We’ve stress-tested Life alongside other WebAssembly implementations on three different tasks and noticed Life to significantly outperform the others.

Closing Remarks

Life was made for the purpose of being the execution environment for all smart contracts and computational tasks in Perlin.

We’ve already tested Life out with complicated programs, and even created a new backend to the open-source deep learning model compiler TVM which allows users to compile PyTorch, Tensorflow, Keras, MXNet, and Caffe models down to WebAssembly*.

A neural network written in PyTorch compiled down to WebAssembly under Perlin.

What does this all mean?

Well, that means Perlin bootstrapped w/ Life now supports any computational task you can imagine. In terms of development progress, one can already run their tasks via. Perlin on the hundreds of millions of idle smart devices out there 😉.

I just want to remind though, that Life isn’t something we’re tailoring to for solely the purposes of just Perlin.

We want to empower other decentralized projects in the space by giving access to the utilities which we’ve built that have empowered ours.

In that process, we realized that a standardized, optimized WebAssembly runtime implementation is something that would significantly benefit both projects from the decentralized space and developer space.

On behalf of the tech team at Perlin, we’re always more than happy to share our work for the sake of bridging the cryptocurrency space and technology space closer together.

To those who really believe in our mission and would love to get to work with us, we are hiring!

To grab our attention, look in the contribution guidelines on our Github, or even feel free to reach out and chat with us on Discord 😄.