Skip to content

Base58

Utility functions for working with Base58 values.

Examples

Below are some examples demonstrating common usages of the Base58 module:

Encoding to Base58

Values can be encoded to Base58 with:

import { Base58 } from 'ox'
 
const value_string = Base58.fromString('Hello World!')
'2NEpo7TZRRrLZSi2U'
const value_bytes = Base58.fromBytes(new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))
'2NEpo7TZRRrLZSi2U'
const value_hex = Base58.fromHex('0x48656c6c6f20576f726c6421')
'2NEpo7TZRRrLZSi2U'

Decoding Base58

Values can be decoded from Base58 with:

import { Base58 } from 'ox'
 
const value_string = Base58.toString('2NEpo7TZRRrLZSi2U')
'Hello World!'
const value_bytes = Base58.toBytes('2NEpo7TZRRrLZSi2U')
Uint8Array [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]
const value_hex = Base58.toHex('2NEpo7TZRRrLZSi2U')
'0x48656c6c6f20576f726c6421'

Functions

NameDescription
Base58.fromBytesEncodes a Bytes.Bytes to a Base58-encoded string.
Base58.fromHexEncodes a Hex.Hex to a Base58-encoded string.
Base58.fromStringEncodes a string to a Base58-encoded string.
Base58.toBytesDecodes a Base58-encoded string to a Bytes.Bytes.
Base58.toHexDecodes a Base58-encoded string to Hex.Hex.
Base58.toStringDecodes a Base58-encoded string to a string.