Skip to content

Bech32m.encode

Encodes data bytes with a human-readable part (HRP) into a bech32m string (BIP-350).

Imports

Named
import { Bech32m } from 'ox'

Examples

import { Bech32m } from 'ox'
 
const encoded = Bech32m.encode('tempo', new Uint8Array(20))
'tempo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwa7xtm'

Definition

function encode(
  hrp: string,
  data: Uint8Array,
  options?: encode.Options,
): string

Source: src/core/Bech32m.ts

Parameters

hrp

  • Type: string

The human-readable part (e.g. "tempo", "tempoz").

data

  • Type: Uint8Array

The data bytes to encode.

options

  • Type: encode.Options
  • Optional

options.limit

  • Type: number
  • Optional

Maximum length of the encoded string.

Return Type

The bech32m-encoded string.

string