Add address generator example

This commit is contained in:
Simon Warta 2020-02-08 20:16:43 +01:00
parent 0b5b4d569e
commit 736b27afaa
2 changed files with 19 additions and 0 deletions

View File

@ -75,6 +75,17 @@ const signedTx: types.StdTx = {
const postResult = await client.postTx(marshalTx(signedTx));
```
## Other example codes
### Create random mnemonic and Cosmos address
```ts
const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
const pen = await Secp256k1Pen.fromMnemonic(mnemonic);
const pubkey = encodeSecp256k1Pubkey(pen.pubkey);
const address = encodeAddress(pubkey, "cosmos");
```
## License
This package is part of the cosmwasm-js repository, licensed under the Apache

View File

@ -0,0 +1,8 @@
const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
const pen = await Secp256k1Pen.fromMnemonic(mnemonic);
const pubkey = encodeSecp256k1Pubkey(pen.pubkey);
const address = encodeAddress(pubkey, "cosmos");
console.info("mnemonic:", mnemonic);
console.info("pubkey:", pubkey);
console.info("address:", address);