render_example_test.gno
1.15 Kb · 42 lines
1package b58demo
2
3// ExampleRender pins the realm's Render output as a gno testable example.
4func ExampleRender() {
5 print(Render(""))
6 // Output:
7 // # Base58 (Bitcoin alphabet)
8 //
9 // Demo of the [`p/moul/x/daily/b58`](/p/nym-moultest123/x/daily/b58/v0) library — base conversion from raw bytes (base-256) to base-58, using the Bitcoin alphabet (no `0`, `O`, `I`, `l`), pure byte-slice math, no `math/big`.
10 //
11 // ## Alphabet
12 //
13 // ```
14 // 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
15 // ```
16 //
17 // 58 characters, index 0…57.
18 //
19 // ## Examples
20 //
21 // | input (utf-8) | hex | Base58 |
22 // |---|---|---|
23 // | `(empty)` | `(empty)` | `` |
24 // | `hello world` | `68656c6c6f20776f726c64` | `StV1DL6CwTryKyV` |
25 // | `gno.land` | `676e6f2e6c616e64` | `JJR1f4BQc9H` |
26 // | `Bitcoin` | `426974636f696e` | `3WyEDWjcVB` |
27 //
28 // Leading zero bytes → leading `1`s:
29 //
30 // | bytes | Base58 |
31 // |---|---|
32 // | `[0x00]` | `1` |
33 // | `[0x00 0x00 0x00]` | `111` |
34 //
35 // ## Try it
36 //
37 // Append a hex string to the path to encode/round-trip it:
38 //
39 // - `/68656c6c6f` — the bytes for "hello"
40 // - `/00000000` — four zero bytes
41 // - `/deadbeef`
42}