# WebAssembly

### **What is WebAssembly?**

[WebAssembly](https://webassembly.org/) (**WASM) is a compilation target that allows to run high-performance code written in compiled languages like C, C++, and Rust to run in a platform-independent way through a sandboxed interpreter.**

The [WebAssembly System Interface ](https://wasi.dev/)(WASI) is the system interface for WebAssembly. It allows to call specific operating system-related services to be called from inside the execution sandbox. WebAssembly programs can **access filesystem data,** **environment variables**, and **program arguments** through this interface. Truebit is compatible with WASM programs that use the WASI version known as 'Snapshot 1'.

#### Limitations

* All ingress/egress networking is disabled – you won't be able to pull data/code/weights/etc from an external source. WASM jobs can access the data by reading from the filesystem.
* There is no multi-threading as WASI Snapshot 1 does not expose any interface for it.

#### Why Do We Use It?

Truebit uses WebAssembly as a foundational technology to ensure security, compatibility, and high-performance execution for its verification protocol.

1. **Portability**: WebAssembly code can run unmodified on various platforms, ensuring compatibility across different systems.
2. **Performance**: WebAssembly's speed is essential for the efficient execution of Truebit's complex verification tasks.
3. **Language Flexibility**: Developers contributing to Truebit can write code in [multiple languages](https://devs.truebit.io/developing-truebit-tasks/how-to-create-function-tasks/supported-languages), thanks to WebAssembly's language-agnostic nature.
