Skip to main content

WASI

WASI, or WebAssembly System Interface, is an API specification that provides access to several operating-system-like features such as filesystems, clocks, and random numbers. Wasmbox provides implementations of most WASI functions (see Assets\Plugins\PlaceholderSoftware\Wasmbox\Core\WASI\).

WASI provides controlled access to certain system resources. For example the virtual file system implemented by Wasmbox can provide in-memory files (which are never saved) as well as expose parts of the real file system, allowing you to carefully control exactly what can and cannot be accessed through WASM code. These features can allow untrusted or malicious code to be run safely.

caution

WASM execution is normally completely deterministic. Adding WASI features can easily break this, since it provides access to external resources which are not deterministic.

WASI Features

WASM Assets which require a WASI function will show a WASI indicator next to the function. Hovering over the indicator will show which WASI feature is required to supply this import, clicking the indicator will bring you to this this documentation page. All WASI features are interfaces which you may implement yourself, or you can use one of the built in implementations.

WASI Import

Random number generation is provided by an implementation of IVirtualRandomSource.

var rng = new CryptoRandomSource();
linker.Define(rng);