Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

/base58 package

Overview

Package base58 ports the core of Bitcoin's Base58 codec (à la mr-tron/base58 and btcutil/base58) to a gno.land realm.

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 here 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.

Functions

Decode

func Decode(s string) []byte

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.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/base58.Decode()"

Result

Encode

func Encode(input []byte) string

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'.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/base58.Encode()"

Result

IsValid

func IsValid(s string) bool

IsValid reports whether every character of s belongs to the Base58 alphabet.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/base58.IsValid()"

Result

Render

func Render(path string) string

Render produces the gnoweb Markdown view.

  • "/" → the alphabet + a small gallery of worked examples.
  • "/<hex>" → decode the hex input to bytes, show its Base58, and the hex-encoded decoded round-trip to prove Encode/Decode are inverse.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/base58.Render()"

Result