Simplify generate address example

This commit is contained in:
Simon Warta 2023-03-01 13:41:14 +01:00
parent 1ac8e429bc
commit 4050cf5ad1

View File

@ -1,8 +1,11 @@
import { encodeSecp256k1Pubkey, Secp256k1HdWallet } from "@cosmjs/amino";
import { Bip39, Random } from "@cosmjs/crypto";
const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
const wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic);
// Configs
const prefix = "osmo";
const words = 12;
const wallet = await Secp256k1HdWallet.generate(words, { prefix });
const mnemonic = wallet.mnemonic;
const [{ address, pubkey }] = await wallet.getAccounts();
console.info("mnemonic:", mnemonic);