Kit
Functions

getBase58Codec

getBase58Codec(): VariableSizeCodec<string>

Returns a codec for encoding and decoding base-58 strings.

This codec serializes strings using a base-58 encoding scheme, commonly used in cryptocurrency addresses and other compact representations.

Returns

VariableSizeCodec<string>

A VariableSizeCodec<string> for encoding and decoding base-58 strings.

Example

Encoding and decoding a base-58 string.

const codec = getBase58Codec();
const bytes = codec.encode('heLLo'); // 0x1b6a3070
const value = codec.decode(bytes);   // "heLLo"

Remarks

This codec does not enforce a size boundary. It will encode and decode all bytes necessary to represent the string.

If you need a fixed-size base-58 codec, consider using fixCodecSize.

const codec = fixCodecSize(getBase58Codec(), 8);

If you need a size-prefixed base-58 codec, consider using addCodecSizePrefix.

const codec = addCodecSizePrefix(getBase58Codec(), getU32Codec());

Separate getBase58Encoder and getBase58Decoder functions are available.

const bytes = getBase58Encoder().encode('heLLo');
const value = getBase58Decoder().decode(bytes);

See

On this page