encode method

String encode()

Encodes a bech32 string

Implementation

String encode() {

  if (_encodedCache != null) return _encodedCache!;

  final wordsWithChecksum = [
    ...words, ..._checksum(
      hrp, words,
      type == Bech32Type.bech32 ? bech32CheckConst : bech32mCheckConst,
    ),
  ];
  final encodedWords = wordsWithChecksum.map((w) => alphabet[w]).join();
  return _encodedCache = "${hrp}1$encodedWords";

}