@spacemesh/address-wasm

This package implements BECH32 address encoder and verifier.
To start using the library you need to install it first:
yarn add @spacemesh/address-wasm
And then start using it in your code:
import Bech32 from '@spacemesh/address-wasm'
(async () => {
Bech32.init();
Bech32.setHRPNetwork('sm');
const publicKey = Uint8Array.from([1, 2, 3, ..., 20]);
const addr = Bech32.generateAddress(publicKey);
console.log(Bech32.verify(addr));
Bech32.setHRPNetwork('smtest');
console.log(Bech32.verify(addr));
console.log(Bech32.parse(addr));
})();
console.log(Bech32.generateAddress(publicKey, 'sm'));
console.log(Bech32.generateAddress(publicKey, 'stest'));
console.log(Bech32.verify(someAddr, 'stest'));
For contributors
This package contains Wasm implementation in golang, that uses spacemeshos/address
implementation inside.
Also, package includes Javascript wrapper over Wasm runner, that provides a clean facade for functions.
You will need to install Go (check out version in go.mod
), NodeJS and yarn.
Then you can just type:
make
To run different build processes — check out Makefile. For example to build only wasm file you can run
make gen-wasm