Using Mnemonic

Using mnemonic or seed phrase instead of private key directly when developing blockchain application

You can use seed phrase or mnemonic when developing smart contract. You don't have to use private key directly. Mnemonic is something like 12 words English. But it can be 15, or 18, or 21, or 24 words. The language can be other than English, such as Italian or Czech.

To generate seed phrase, you can run Mamba CLI command:


(.venv) $ mamba generate_mnemonic
ecology snack blush nice era start soap fragile space hospital brass blade
(.venv) $ mamba generate_mnemonic --language french --num_words 21
aviateur vernir envahir adjuger réserve ficeler lutter atome attaque junior ruiner prologue cuivre étagère ponctuel tapis boulon aubaine rouleau bronzer éloge

When you compile a smart contract, your migration file (for example: migrations/deploy_HelloWorld.py) by default will use mnemonic.


mnemonic = "coral allow abandon recipe top tray caught video climb similar prepare bracket antenna rubber announce gauge volume hub hood burden skill immense add acid"
private_key = Authentication.get_private_key_from_mnemonic(mnemonic)

You should change that mnemonic and put it in configuration file or environment variable. The Authentication.get_private_key_from_mnemonic method accepts additional two parameters, which are passphrase and hdpath (for deriving child key from parent), such as m/44'/60'/0'/0/0.