Common Prefixes
Encoding and Decoding
@cosmjs/encoding provides three functions:
fromBech32 validates the checksum and throws on invalid input.
normalizeBech32 round-trips through decode/encode, which is safer than calling
toLowerCase() directly.
How Addresses Are Derived from Public Keys
The raw 20-byte address inside a Bech32 string is derived from the public key through hashing. The algorithm depends on the key type:
The
@cosmjs/amino package provides pubkeyToAddress for this: