From 93dcd8033f50bbc127bfd927b8de3804630a260c Mon Sep 17 00:00:00 2001 From: fiatjaf_ Date: Sun, 5 Apr 2026 12:08:24 -0300 Subject: byte order clarification Co-authored-by: Awiteb --- 5C.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/5C.md b/5C.md index 37197e1..f4b8e64 100644 --- a/5C.md +++ b/5C.md @@ -34,6 +34,10 @@ Unless noted otherwise (i.e. for hex pubkeys and ids), the module passes strings For example, if `nostr.get_content(handle)` returns `7165` that will be a pointer to a buffer at location `7165`. If that buffer starts with `[ 00 00 00 03 ]` that means it contains 3 bytes (aside from the initial four), so we can keep reading it `[ 00 00 00 03 66 6f 6f ]` and conclude that the string is `"foo"`. +## Numbers Convention + +All numbers written by the host must use **Little-endian** byte order, matching WASM's default endianness. This applies consistently: write string length prefixes as Little-endian numbers, write number parameters as Little-endian + ## Memory Management Convention In order to keep the size of WASM programs small (<10kb) we recommend not including any type of garbage collector or complex allocator. Just use the simplest possible bump allocator and do not free any memory -- programs will not use a lot of memory anyway, at most they will receive a bunch of `i32` event handles from the host, which are cheap. -- cgit v1.2.3