In the documentation of Cosmos SDK and everywhere in the internet what’s described is how to generate a wallet out of a mnemonic phrase:
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
const my_mnemonic = "<..........>";
const wallet_1 = await DirectSecp256k1HdWallet.fromMnemonic(my_mnemonic, {prefix: 'abcd'});
What I need, however, is to do it out of a private key instead of a mnemonic phrase.
How?
2
Answers
You would just provide the key. I don’t recommend this though:
In order to generate a wallet from a private key in Cosmos SDK, you can use the DirectSecp256k1Wallet instead of DirectSecp256k1HdWallet.
Here’s an example code snippet: