Create a new applet

This step will eventually be a simple wasefire new <applet-name> command out of tree. But for now we will build the applet within the project repository as an example applet. We'll use tutorial as the applet name throughout this tutorial.

You have 2 options to create and populate the applet directory. We'll go over both for pedagogical reasons.

Copy the hello applet

The first step is to copy the hello directory to the tutorial directory:

cp -r examples/rust/hello examples/rust/tutorial

The second step is to update the applet name in the Cargo.toml:

sed -i 's/hello/tutorial/' examples/rust/tutorial/Cargo.toml

Create the applet from scratch

Create the tutorial directory:

mkdir examples/rust/tutorial

Create the Cargo.toml file in the created directory with the following content:

[package]
name = "tutorial"
version = "0.1.0"
edition = "2021"

[dependencies]
wasefire = "*" # use the latest version

The wasefire dependency provides a high-level interface to the Applet API.

Then create the src/lib.rs file in the created directory with the following content:

#![no_std] // needed for building wasm (without wasi)
wasefire::applet!(); // imports the prelude and defines main as entry point

fn main() {
    debug!("hello world");
}

Note that because you need to use core or alloc instead of std.