2020-06-05 13:58:22 +02:00
|
|
|
# @cosmjs/encoding
|
|
|
|
|
|
|
|
[](https://www.npmjs.com/package/@cosmjs/encoding)
|
|
|
|
|
|
|
|
This package is an extension to the JavaScript standard library that is not
|
|
|
|
bound to blockchain products. It provides basic hex/base64/ascii encoding to
|
|
|
|
Uint8Array that doesn't rely on Buffer and also provides better error messages
|
|
|
|
on invalid input.
|
|
|
|
|
|
|
|
## Convert between bech32 and hex addresses
|
|
|
|
|
|
|
|
```
|
2022-02-22 14:05:34 +01:00
|
|
|
>> toBech32("tiov", fromHex("1234ABCD0000AA0000FFFF0000AA00001234ABCD"))
|
2020-06-05 13:58:22 +02:00
|
|
|
'tiov1zg62hngqqz4qqq8lluqqp2sqqqfrf27dzrrmea'
|
2022-02-22 14:05:34 +01:00
|
|
|
>> toHex(fromBech32("tiov1zg62hngqqz4qqq8lluqqp2sqqqfrf27dzrrmea").data)
|
2020-06-05 13:58:22 +02:00
|
|
|
'1234abcd0000aa0000ffff0000aa00001234abcd'
|
|
|
|
```
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
2020-06-18 09:49:52 +02:00
|
|
|
This package is part of the cosmjs repository, licensed under the Apache License
|
2021-01-19 23:37:10 +01:00
|
|
|
2.0 (see [NOTICE](https://github.com/cosmos/cosmjs/blob/main/NOTICE) and
|
|
|
|
[LICENSE](https://github.com/cosmos/cosmjs/blob/main/LICENSE)).
|