mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Simplify generate address example
This commit is contained in:
parent
1ac8e429bc
commit
4050cf5ad1
@ -1,8 +1,11 @@
|
|||||||
import { encodeSecp256k1Pubkey, Secp256k1HdWallet } from "@cosmjs/amino";
|
import { encodeSecp256k1Pubkey, Secp256k1HdWallet } from "@cosmjs/amino";
|
||||||
import { Bip39, Random } from "@cosmjs/crypto";
|
|
||||||
|
|
||||||
const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
|
// Configs
|
||||||
const wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic);
|
const prefix = "osmo";
|
||||||
|
const words = 12;
|
||||||
|
|
||||||
|
const wallet = await Secp256k1HdWallet.generate(words, { prefix });
|
||||||
|
const mnemonic = wallet.mnemonic;
|
||||||
const [{ address, pubkey }] = await wallet.getAccounts();
|
const [{ address, pubkey }] = await wallet.getAccounts();
|
||||||
|
|
||||||
console.info("mnemonic:", mnemonic);
|
console.info("mnemonic:", mnemonic);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user