Addition WAT
Addition WAT example
This is a simple addition example. It takes two numbers as inputs and returns their sum. For this example we can use the standard proplet deployment without any additional configuration. The example is written in WebAssembly Text format then compiled to wasm and also encoded in base64.
Source Code
The source code is available in the examples/addition-wat directory.
Loading...
Create Task
To create a task for this example, we need to build the example to wasm and then create a task with the wasm file.
cd propeller
make addition-watNow we can create a task with the wasm file:
curl -X POST "http://localhost:7070/tasks" \
-H "Content-Type: application/json" \
-d '{"name": "main", "inputs": [10, 20]}'Your output should look like this:
{
"id": "b8fabc60-1156-4883-a2cd-4b70380ea5df",
"name": "main",
"kind": "standard",
"state": 0,
"cli_args": null,
"inputs": [10, 20],
"daemon": false,
"encrypted": false,
"start_time": "0001-01-01T00:00:00Z",
"finish_time": "0001-01-01T00:00:00Z",
"created_at": "2026-02-13T11:22:07.606945932Z",
"updated_at": "0001-01-01T00:00:00Z",
"next_run": "0001-01-01T00:00:00Z",
"priority": 50
}Upload Wasm
Now we need to upload the wasm file:
curl --location --request PUT 'http://localhost:7070/tasks/b8fabc60-1156-4883-a2cd-4b70380ea5df' \
--header 'Content-Type: application/json' \
--data '{
"file": "AGFzbQEAAAABBwFgAn9/AX8DAgEABwgBBG1haW4AAAoJAQcAIAAgAWoL"
}'Your output should look like this:
{
"id": "b8fabc60-1156-4883-a2cd-4b70380ea5df",
"name": "main",
"kind": "standard",
"state": 0,
"file": "AGFzbQEAAAABBwFgAn9/AX8DAgEABwgBBG1haW4AAAoJAQcAIAAgAWoL",
"cli_args": null,
"inputs": [10, 20],
"daemon": false,
"encrypted": false,
"start_time": "0001-01-01T00:00:00Z",
"finish_time": "0001-01-01T00:00:00Z",
"created_at": "2026-02-13T11:22:07.606945932Z",
"updated_at": "2026-02-13T11:23:17.032020218Z",
"next_run": "0001-01-01T00:00:00Z",
"priority": 50
}Start Task
Now we can start the task:
curl -X POST "http://localhost:7070/tasks/b8fabc60-1156-4883-a2cd-4b70380ea5df/start"Your output should look like this:
{ "started": true }The results of the task will be something like this.
curl -X GET "http://localhost:7070/tasks/b8fabc60-1156-4883-a2cd-4b70380ea5df"Your output should look like this:
{
"id": "b8fabc60-1156-4883-a2cd-4b70380ea5df",
"name": "main",
"kind": "standard",
"state": 3,
"file": "AGFzbQEAAAABBwFgAn9/AX8DAgEABwgBBG1haW4AAAoJAQcAIAAgAWoL",
"cli_args": null,
"inputs": [10, 20],
"daemon": false,
"encrypted": false,
"proplet_id": "a95517f9-5655-4cf5-a7c8-aa00290b3895",
"results": "30\n",
"start_time": "2026-02-13T11:23:42.950717055Z",
"finish_time": "2026-02-13T11:23:43.088030778Z",
"created_at": "2026-02-13T11:22:07.606945932Z",
"updated_at": "2026-02-13T11:23:43.088030678Z",
"next_run": "0001-01-01T00:00:00Z",
"priority": 50
}Invoking Using WasmTime
wasmtime --invoke add ./build/addition-wat.wasm 10 20The results of the task will be something like this.
warning: using `--invoke` with a function that takes arguments is experimental and may break in the future
warning: using `--invoke` with a function that returns values is experimental and may break in the future
30