Adding Keys
Last updated
Last updated
Before you can create chainlets, you will need to add a public/private keypair (aka key) to sagacli
. You have the option to either create a new key, or import a key you have already created previously.
All of the keys are created using the secp256k1
elliptical curve and are securely held in a keyring managed by sagacli
. However, you also have several different options to create your keys e.g. use a different algorithm than the default of secp256k1
.
A full list of options with which to add keys can be viewed by the following command:
sagacli
To create a new key using the default keyring and algorithm, simply type
So, for instance, if you want to generate a new key and call it mykey1
, then you will type
Keep in Mind: If this is your first time creating a key in sagacli
, you will also be prompted for a password for the os
keyring, that secures the keys using this password. Provide a strong password to secure the keyring.
This will generate the following output, and store the key in the default keyring, which is os
.
You will notice that the key mykey1
has been generated and allocated an address, which in this case is saga1tkax73wxs047nc8kaalhfc4ar6gay2sde28crx
. Additionally, from the output above, we can see that this key was generated using the secp256k1
algorithm.
IMPORTANT: Make sure to copy the mnemonic phrase and save it to a safe place. As the output above indicates, should you forget your password, the only way to recover this key would be the mnemonic phrase.
To create a key in a different keyring (other than the default os
keyring), you can specify the --keyring-backend
flag.
For example, to create a key in the test
keyring, type
This will create a key in the test
keyring.
Please bear in mind that not all keyrings are secure. For more information about supported keyrings and their security features, please refer to Key Management Overview.
sagacli
You may have keys that you already use that you want to use with sagacli
. To do so, you will need to import your existing key into sagacli
.
You will need to have access to the BIP39 mnemonic phrase associated with the key you are trying to import.
As long you have the mnemonic phrase, you can import an existing key by:
For example, if you want to import an existing key called test1
into sagacli
, you would type
This will prompt you to enter the BIP39 mnemonic.
The new key is generated and saved to the default keyring, and its address is echoed to the screen.
sagacli
You can configure a default key in sagacli
which will then be used in all transactions and queries unless you override it by using the --address
flag.
The default key can be configured using the following command:
For example, if we have a key called fundkey
and we would like to set it as the default key, we would type
Note: Ensure that the key being tagged as default actually exists in sagacli
.
To view the default key, type
This will display if a default key has been set. In this example using fundkey
, we get