./hmy keys add <account-name> [--passphrase]
./hmy.sh -- keys add <account-name1> [--passphrase]
./hmy keys add test-account --passphrase
This creates a keystore at the following directory:
(hmy keys location)/account-name1/UTC--2019-09-16T21-25-35.297331000Z--678e7ea3dcb5f4e9724c0e761843572f10c49b73
When creating keys this way,
hmy will ask you to provide a passphrase. Make sure you keep track of this passphrase for future use because the passphrase is used to decrypt the keystore when signing transactions. Also make sure you save the seed phrase, also called a mnemonic.
To know where your wallet file has been created, run the following command:
./hmy keys location
./hmy.sh -- keys location
You can check the list of wallets (local accounts) with the following command:
./hmy keys list
./hmy.sh -- keys list
You might have an existing keystore made by Harmony's old
wallet.sh program that ends with ".key" in the file name (example):
Or that starts with "UTC" in the file name (example):
Both these files can be imported into
hmy using the command
import-ks as shown below.
./hmy keys import-ks <absolute_path_to_keystore> --passphrase
./hmy.sh -- keys import-ks <absolute_path_to_keystore> --passphrase
./hmy keys import-ks /home/harmony/one16qsd5ant9v94jrs89mruzx62h7ekcfxmduh2rx.key --passphrase./hmy keys import-ks /home/harmony/UTC--2020-01-15T01-02-06.606670000Z--9689a0711642bf08ea92ed98d552f0c1b8c8cefb --passphrase
Keep in mind that you should know the passphrase associated with the imported keystore and pass it as a parameter as shown in the commands above. For keystores created by Harmony's
wallet.sh, the default passphrase is an empty string; this matters for signing transactions.
Sometimes you might have a secp256k1 private key, such as the one generated from the following command:
openssl ecparam -genkey -name secp256k1 -text -noout -outform DER | xxd -p -c 1000 | sed 's/41534e31204f49443a20736563703235366b310a30740201010420/PrivKey: /' | sed 's/a00706052b8104000aa144034200/\'$'\nPubKey: /'
You can import the key with an optional name and passphrase
./hmy keys import-private-key <secp256k1_private_key> [wallet_name] [--passphrase]
./hmy.sh -- keys import-private-key <secp256k1_private_key> [wallet_name] [--passphrase]
./hmy keys import-private-key b8798ca0a56ce16517ea37c6b1229cbb67cf0e022c423b044fe8f537830d8be5 my_wallet_name_here --passphrase
If no account name is provided, a random word concatenated with
-imported will be used. If no passphrase is provided, the default passphrase will be used (which is blank). Note that the CLI currently only supports importing secp256k1 private keys.
You can recover lost wallet keys by entering the mnemonic words you received (and hopefully saved) when creating it:
./hmy keys recover-from-mnemonic [wallet_name]
./hmy.sh -- keys recover-from-mnemonic [wallet_name]
./hmy keys recover-from-mnemonic nameofyourkey