const Alphabet
Alphabet is the Bitcoin Base58 alphabet.
Package b58 ports the core of Bitcoin's Base58 codec (à la mr-tron/base58 and btcutil/base58) to gno — as a reusable ...
gno.land/p/moul/x/daily/b58/v0Base58 (Bitcoin alphabet) codec — Encode, Decode, IsValid, Alphabet.
Pure byte-slice math (the classic div/mod-by-58 carry loop), no math/big;
leading zero bytes ↔ leading 1s. Ported from mr-tron/base58 / btcutil/base58.
1import "gno.land/p/moul/x/daily/b58/v0"
2
3s := b58.Encode([]byte("hello")) // "Cn8eVZg"
4b := b58.Decode(s) // []byte("hello") (nil if s has a non-alphabet char)
Live demo: r/moul/x/daily/b58demo
· render it at /r/moul/x/daily/b58demo/v0.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.
Package b58 ports the core of Bitcoin's Base58 codec (à la mr-tron/base58 and btcutil/base58) to gno — as a reusable pure package.
Base58 is a base conversion from base-256 (raw bytes) to base-58 using an alphabet that omits the visually ambiguous characters 0 (zero), O (capital o), I (capital i) and l (lower L). The conversion is done with pure byte-slice math — the classic div/mod-by-58 carry loop — so it needs no math/big. Leading zero bytes map to leading '1' characters and back, exactly like the reference implementations.
A live demo of this package (an interactive encoder / round-tripper) is at r/moul/x/daily/b58demo(/r/moul/x/daily/b58demo/v0).
Decode converts a Base58 string back to the original byte slice. It returns nil if the string contains a character outside the alphabet.
Algorithm: the mirror of Encode — treat the string as a big base-58 integer and convert it back to base-256 bytes with a carry loop. Each leading '1' becomes a leading zero byte.
Encode converts a byte slice to its Base58 string representation.
Algorithm: treat the input as a big base-256 integer and repeatedly convert it into base-58 digits via a carry loop, most-significant digit first. Each leading zero byte becomes a leading '1'.
IsValid reports whether every character of s belongs to the Base58 alphabet.