rename to scrolls.

This commit is contained in:
fiatjaf
2026-04-02 03:09:12 -03:00
parent 3d7b6d8829
commit d419a60ab5
+9 -9
View File
@@ -1,10 +1,10 @@
# NIP-A5
## WASM Programs
## Scrolls
`draft` `optional`
This NIP defines a standard for publishing self-contained WebAssembly programs as Nostr events. Programs are base64-encoded, executed client-side, and interact with Nostr exclusively through a host-provided handle-based API for building requests, querying relays, and rendering results.
This NIP defines a standard for publishing self-contained WebAssembly programs as Nostr events ("scrolls"). Scrolls are composed of basic metadata (`name`, `description` and `image`) and initial execution parameters defined as tags and a WASM binary, base64-encoded as the content. The binaries are executed in a sandbox inside a "host" (i.e. a proper Nostr client). Scrolls interact with Nostr only through a set of simple APIs provided by the host.
---
@@ -16,8 +16,8 @@ This NIP defines a standard for publishing self-contained WebAssembly programs a
"content": "<base64-encoded WASM binary>",
"tags":
[
["name", "<program-name>"],
["description", "<optional-description>"],
["name", "<name>"],
["description", "<description>"],
["icon", "<image-url>"],
["param", "<... (see below)>"]
]
@@ -70,7 +70,7 @@ The WASM module **must** export its linear memory so the host can read guest str
## Parameters
Programs can declare parameters that the host must provide when calling `run()`. Parameters are declared as tags on the program event.
Scrolls can declare parameters that the host must provide when calling `run()`.
The tag format is `["param", "<name>", "<description>", "<type>", "<required>"]` where:
@@ -85,9 +85,9 @@ A special parameter called `"me"` of type `public_key` can be specified to be au
Parameters of type `event` may take an extra tag item `<supported_kinds>` after `<required>` with a comma-separated list of kinds that are acceptable.
### Example Event
### Example
For example, this program could be displayed as an option to be clicked on any user profile.
For example, this scroll could be displayed as an option to be clicked on any user profile.
```yaml
{
@@ -122,7 +122,7 @@ When the host calls `run()`, it passes a single pointer to a buffer containing a
| `timestamp` | unix timestamp as u32_be | 4 bytes |
| `relay` | relay URL, same as string | 4 + len bytes |
For example: in a program with parameters `[me: public_key, target_event: event, target_relay: relay]` the buffer layout would be:
For example: in a scroll with parameters `[me: public_key, target_event: event, target_relay: relay]` the buffer layout would be:
```
[ 32-byte current user pubkey ][ 4-byte i32 handle ][ 4-byte len for relay URL ][ UTF-8 relay URL ]
@@ -279,7 +279,7 @@ Releases any handle: unconsumed request, active subscription (cancels it), indiv
---
## Example Programs and Host
## Example programs and host code
- JavaScript host runtime example: https://viewsource.win/fiatjaf.com/nprogram/_/2e7d56d1536fcca8c49e7b2e99db8062f8df9ae1/~/src/nprogram-host.ts
- Rust example (basic, just reads from a relay): https://viewsource.win/fiatjaf.com/nprogram/_/2e7d56d1536fcca8c49e7b2e99db8062f8df9ae1/~/examples/basic/src/lib.rs