Bech32m
Utility functions for BIP-350 bech32m encoding and decoding.
Examples
Below are some examples demonstrating common usages of the Bech32m module:
Encoding
import { Bech32m } from 'ox'
const encoded = Bech32m.encode('tempo', new Uint8Array(20))Decoding
import { Bech32m } from 'ox'
const { hrp, data } = Bech32m.decode('tempo1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq7w9gdx')Functions
| Name | Description |
|---|---|
Bech32m.decode | Decodes a bech32m string (BIP-350) into a human-readable part and data bytes. |
Bech32m.encode | Encodes data bytes with a human-readable part (HRP) into a bech32m string (BIP-350). |
Errors
| Name | Description |
|---|---|
Bech32m.ExceedsLengthError | Thrown when the encoded string exceeds the length limit. |
Bech32m.InvalidCharacterError | Thrown when a bech32m string contains an invalid character. |
Bech32m.InvalidChecksumError | Thrown when a bech32m string has an invalid checksum. |
Bech32m.InvalidHrpError | Thrown when the HRP is invalid (empty or contains non-ASCII characters). |
Bech32m.InvalidPaddingError | Thrown when the padding bits are invalid during base32 conversion. |
Bech32m.MixedCaseError | Thrown when a bech32m string contains mixed case. |
Bech32m.NoSeparatorError | Thrown when a bech32m string has no separator. |

