Key management

Generate new key

To generate new key, use the following command:

swisstronikcli keys add <key_name>

If you got an error "Error: provided algorithm "eth_secp256k1" is not supported", specify an additional parameter for keyring --keyring-backend test or --keyring-backend file

NOTE: This command will generate a mnemonic for a new key, therefore, you should save it in a secure place.

The command above will output the following:

- address: swtr156pzc2rj2xka9cu0gpgkmz3vmal544nlu9mwj7
  name: debug
  pubkey: '{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"AyJHdeTNCnjV4v5ZJEbyFS5UtzBQk1ThkZB4G7QR3Cb6"}'
  type: local


**Important** write this mnemonic phrase in a safe place.
It is the only way to recover your account if you ever forget your password.

picnic explain flower snack lava town marriage search approve increase display angry express peanut peanut mouse noise knock address situate hope pelican advance rather

Restore key from mnemonic

If you got error "Error: provided algorithm "eth_secp256k1" is not supported", specify an additional parameter for keyring --keyring-backend test or --keyring-backend file

If you already have a mnemonic and want to restore a key from it, use the following command:

It will prompt you for your mnemonic. Once you input your mnemonic, your output should look like:

List all accounts

To show all stored accounts, use the following command:

This command should output the following:

If you cannot find your key in the output, try to specify --keyring-backend test or --keyring-backend file

Export ETH private key

Since swisstronikcli operates with eth_secp256k1 private keys, all keys stored in the keyring are Ethereum-compatible private keys. You can export Ethereum private key (for example, to use it in MetaMask) by using the following command:

If you encounter the error "Error: <wallet_name>.info: key not found", try specifying either --keyring-backend test or --keyring-backend file

The command above should output your Ethereum private key, for example:

Convert address

swisstronikcli can work only with bech32-encoded (swtr1) addresses, so if you want to convert your Ethereum address to bech32 format (and vice versa), you can use the following command:

It should output the converted address:

Last updated