# Generating mnemonic phrase through CLI

**URL:** <https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908>\
**Category:** Developers\
**Created:** [1 March 2018 19:34 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908 "2018-03-01T19:34:40Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsticco](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nsticco/32/2261_2.png) [@nsticco](https://forum.cardano.org/u/nsticco)\
**Post date:** [1 March 2018 19:34 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/1 "2018-03-01T19:34:40Z")

</div>

It seems like I can generate a wallet using the Cardano SL API by feeding an existing 12 word mnemonic string to it and using this module: [https://cardanodocs.com/technical/wallet/api/#/default/post\_api\_wallets\_new](https://cardanodocs.com/technical/wallet/api/#/default/post_api_wallets_new)

If you use the Daedalus GUI, it generates a 12 word mnemonic for you.

Is there a way to generate the mnemonic through the Cardano SL without using a GUI? Or do I need to build my own function outside of the official tools which will generate a 12 word mnemonic that works with Cardano?

As far as I can tell, the “–backup-phrase PHRASE” option is just for implementing an already existing mnemonic.

---

<div class="post-metadata">

**Author:** ![p-alik](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/p-alik/32/1578_2.png) [@p-alik](https://forum.cardano.org/u/p-alik)\
**Post date:** [1 March 2018 19:56 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/2 "2018-03-01T19:56:39Z")

</div>

> [@nsticco](#):
>
> As far as I can tell, the “–backup-phrase PHRASE” option is just for implementing an already existing mnemonic.

Yes. There is a static mnemonic’s set [https://github.com/input-output-hk/cardano-sl/blob/develop/wallet/src/Pos/Util/Mnemonics.hs#L142-L485](https://github.com/input-output-hk/cardano-sl/blob/develop/wallet/src/Pos/Util/Mnemonics.hs#L142-L485)

> <https://github.com/input-output-hk/cardano-sl/blob/develop/scripts/test/wallet/many-tx-test.sh#L27-L40>

---

<div class="post-metadata">

**Author:** ![nsticco](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nsticco/32/2261_2.png) [@nsticco](https://forum.cardano.org/u/nsticco)\
**Post date:** [1 March 2018 21:01 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/3 "2018-03-01T21:01:06Z")

</div>

Awesome! Thank you!

So, I should be able to write a function that randomly chooses 12 of these words to create wallet phrase strings, right?

---

<div class="post-metadata">

**Author:** ![p-alik](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/p-alik/32/1578_2.png) [@p-alik](https://forum.cardano.org/u/p-alik)\
**Post date:** [1 March 2018 21:33 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/4 "2018-03-01T21:33:39Z")

</div>

I think so.

---

<div class="post-metadata">

**Author:** ![nsticco](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nsticco/32/2261_2.png) [@nsticco](https://forum.cardano.org/u/nsticco)\
**Post date:** [10 May 2018 23:33 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/5 "2018-05-10T23:33:51Z")

</div>

I just came across this:  
[https://cardanodocs.com/technical/wallet/api/v1/#section/Mnemonic-Codes](https://cardanodocs.com/technical/wallet/api/v1/#section/Mnemonic-Codes)

It states, “Note that picking up 12 random words from the list is not enough and leads to poor security”. So, I guess this is not advised? Although I’m a little confused as to why the list even exists in that case.

---

<div class="post-metadata">

**Author:** ![\_ilap](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/_ilap/32/80886_2.png) [@\_ilap](https://forum.cardano.org/u/_ilap)\
**Post date:** [11 May 2018 01:22 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/6 "2018-05-11T01:22:41Z")

</div>

It’s not recommended at all. You need proper randomness to protect your wallet. Choosing 12 words by yourself is not a proper one.

---

<div class="post-metadata">

**Author:** ![nsticco](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nsticco/32/2261_2.png) [@nsticco](https://forum.cardano.org/u/nsticco)\
**Post date:** [12 May 2018 17:58 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/7 "2018-05-12T17:58:06Z")

</div>

So, the preferred method is to use a larger dictionary then?

---

<div class="post-metadata">

**Author:** ![vantuz-subhuman](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/vantuz-subhuman/32/3976_2.png) [@vantuz-subhuman](https://forum.cardano.org/u/vantuz-subhuman)\
**Post date:** [12 May 2018 19:46 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/8 "2018-05-12T19:46:01Z")

</div>

> [@nsticco](#):
>
> So, the preferred method is to use a larger dictionary then?

What do you mean by “larger dictionary”? There are exactly 2048 words that may be used as a mnemonic, as can be seen in this list: [https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt](https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt)

Furthermore - **not all** word combinations may be used as a wallet. There’s a special property of the **checksum** that must be held. Only about 1 in each 256 combinations may be used as a valid wallet.

BIP39 mnemonics are **secondary** and are obtained from generated randomness as explained in this document: [https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)

So just trying to select 12 words from the list **might** work, but not a proper way to create wallets. Proper algorithm looks somewhat like this:

1. Generate 128 bits of randomness
2. Calculate checksum of the resulting bytestring
3. Take first 4 bits of the checksum and append them to the original randomness
4. That will give you the bytestring of 132 bits
5. Split 132 bits into 12 groups of 11 bits
6. Convert each 11-bit word to a decimal number
7. That will give you 12 numbers between 0 and 2047
8. Use standard list or words to select 12 mnemonic words for each number (by index)

That will give you 12 words that you can send to the wallet creation API. You probably might easily find existing BIP39 library for any language of your choice that will allow you to generate those words, or at least indexes.

**Generating proper randomness is not that trivial!** Put some thought into how you’re going to to this part.

---

<div class="post-metadata">

**Author:** ![magnetar](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@magnetar](https://forum.cardano.org/u/magnetar)\
**Post date:** [14 May 2018 22:04 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/9 "2018-05-14T22:04:55Z")

</div>

> [@nsticco](#):
>
> So, the preferred method is to use a larger dictionary then?

Print out a program called diceware. It is a lot of pages. You roll dice to generate random phrases. I recommend printing it and actually rolling dice rather than using the online generator. I sometimes do that to create high entropy pass phrases since keefox doesn’t have that option.  
Of course Daedalus creates a secure mnemonic for you anyway - so why bother ?

[http://world.std.com/~reinhold/diceware.html](http://world.std.com/%7Ereinhold/diceware.html)

That will be random but as per

> [@vantuz-subhuman](#):
>
> Furthermore - **not all** word combinations may be used as a wallet.

---

<div class="post-metadata">

**Author:** ![nsticco](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/nsticco/32/2261_2.png) [@nsticco](https://forum.cardano.org/u/nsticco)\
**Post date:** [14 May 2018 23:57 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/10 "2018-05-14T23:57:55Z")

</div>

I appreciate the helpful responses!

---

<div class="post-metadata">

**Author:** ![oldcryptogeek](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/oldcryptogeek/32/3939_2.png) [@oldcryptogeek](https://forum.cardano.org/u/oldcryptogeek)\
**Post date:** [14 October 2018 10:35 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/11 "2018-10-14T10:35:51Z")

</div>

[https://github.com/input-output-hk/cardano-sl/blob/develop/wallet/src/Pos/Util/Mnemonic.hs](https://github.com/input-output-hk/cardano-sl/blob/develop/wallet/src/Pos/Util/Mnemonic.hs) is the updated link.

---

<div class="post-metadata">

**Author:** ![marty](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@marty](https://forum.cardano.org/u/marty)\
**Post date:** [28 December 2020 08:24 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/12 "2020-12-28T08:24:53Z")

</div>

Is this still possible? I’m trying to generate a key pair (with mnemonic) for a stake pool pledge so i can back it up with a cold storage solution like cryptosteel.

---

<div class="post-metadata">

**Author:** ![adatainment](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/adatainment/32/81481_2.png) [@adatainment](https://forum.cardano.org/u/adatainment)\
**Post date:** [28 December 2020 08:37 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/13 "2020-12-28T08:37:36Z")

</div>

Hey, @marty this thread is super-outdated. I recommend to start a new topic in the stake pool operator category here:

> **[Operate a Stake Pool](https://forum.cardano.org/c/staking-delegation/operators-talk/119)**
>
> How to monitor, update, maintain and grow a Cardano stake pool.

---

<div class="post-metadata">

**Author:** ![marty](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@marty](https://forum.cardano.org/u/marty)\
**Post date:** [28 December 2020 08:38 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/14 "2020-12-28T08:38:58Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![foster\_hj](https://avatars.discourse-cdn.com/v4/letter/f/c37758/32.png) [@foster\_hj](https://forum.cardano.org/u/foster_hj)\
**Post date:** [16 May 2022 20:02 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/15 "2022-05-16T20:02:14Z")

</div>

Hi, I generated my payment and stake keys through CLI method (Coincashew instruction) on TESTNET. Now, I am wondering if I can create a mnemonic phrase for it to monitor the rewards easier.  
on another note, does wallet that is created by mnemonic phrase help you control both pledge and stake rewards?  
Thanks!!

---

<div class="post-metadata">

**Author:** ![HeptaSean](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.cardano.org/heptasean/32/82306_2.png) [@HeptaSean](https://forum.cardano.org/u/HeptaSean)\
**Post date:** [16 May 2022 20:15 UTC](https://forum.cardano.org/t/generating-mnemonic-phrase-through-cli/8908/16 "2022-05-16T20:15:20Z")

</div>

You cannot generate a mnemonic for random keys after the fact. The keys are derived from the mnemonic used as a master secret.

But if you setup with a mnemonic from the beginning, you should be able to derive all keys from that mnemonic.

[https://www.coincashew.com/coins/overview-ada/guide-how-to-build-a-haskell-stakepool-node/part-iii-operation/setting-up-payment-and-stake-keys](https://www.coincashew.com/coins/overview-ada/guide-how-to-build-a-haskell-stakepool-node/part-iii-operation/setting-up-payment-and-stake-keys) also has a tab, how to do it with a mnenomic seed phrase, but I don’t know if that is the best way to do it. (I tend to like `cardano-address` more than `cardano-wallet`, because I do not see, why I should run another server just to derive some keys.)
