InterchainJS (Beta ⚡️)
Advanced Documentation
Wallet

Wallet

Easy to Construct Wallet

Wallet can be constructed using fromMnemonic.

import { Secp256k1HDWallet } from "@interchainjs/cosmos/wallets/secp256k1hd";
import { HDPath } from "@interchainjs/types";
 
// init wallet with two accounts using two hd paths
const wallet = Secp256k1HDWallet.fromMnemonic(
  "<MNEMONIC_WORDS>",
  // use cosmos hdpath built by HDPath
  // we can get cosmos hdpath "m/44'/118'/0'/0/0" and "m/44'/118'/0'/0/1" by this:
  [0, 1].map((i) => ({
    prefix: "cosmos",
    hdPath: HDPath.cosmos(0, 0, i).toString(),
  }))
);

Moreover, to construct OfflineSigner object from Wallet to hide private key.

protoSigner = wallet.toOfflineDirectSigner();
address = (await protoSigner.getAccounts())[0].address;